@@ -26,7 +26,7 @@ describe('ember addon <the addon> -b <this blueprint>', () => {
2626 let result = await execa (
2727 'ember' ,
2828 [ 'addon' , name , '-b' , blueprintPath , '--skip-npm' , '--skip-git' , ...args ] ,
29- { ...options , env : { ...options . env , EMBER_CLI_PNPM : 'true' } }
29+ { ...options , env : { ...options . env , EMBER_CLI_PNPM : 'true' } , preferLocal : true }
3030 ) ;
3131
3232 // Light work-around for an upstream `@babel/core` peer issue
@@ -133,91 +133,65 @@ describe('ember addon <the addon> -b <this blueprint>', () => {
133133 expect ( exitCode ) . toEqual ( 0 ) ;
134134 } ) ;
135135 } ) ;
136- } ) ;
137-
138- describe ( '--typescript' , ( ) => {
139- let cwd = '' ;
140- let tmpDir = '' ;
141- let distDir = '' ;
142- let distTypesDir = '' ;
143136
144- beforeAll ( async ( ) => {
145- tmpDir = await createTmp ( ) ;
137+ describe ( '--typescript' , ( ) => {
138+ let cwd = '' ;
139+ let tmpDir = '' ;
140+ let distDir = '' ;
146141
147- /**
148- * We can't use yarn here, because it does the wrong thing with the types from
149- * test-helpers:
150- *
151- * [!] (plugin Typescript) TS2688: Cannot find type definition file for 'ember__test-helpers'.
152- * The file is in the program because:
153- * Entry point for implicit type library 'ember__test-helpers'
154- */
155- let { name } = await createAddon ( {
156- args : [ '--typescript' , '--pnpm=true' , '--skip-npm' ] ,
157- options : { cwd : tmpDir } ,
158- } ) ;
142+ beforeAll ( async ( ) => {
143+ tmpDir = await createTmp ( ) ;
159144
160- cwd = path . join ( tmpDir , name ) ;
161- distDir = path . join ( cwd , name , 'dist' ) ;
162- distTypesDir = path . join ( cwd , name , 'declarations' ) ;
163-
164- // Remove because ember-cli ignores --skip-npm.
165- // At present, ember-cli installs `ember-cli-typescript`, which then
166- // further installs other things. This chaining of relying on the package-manager
167- // makes doing anything statically, and with *any* package manager, hard.
168- // Additionally, this behavior makes setting up the v2 addon blueprint,
169- // and testing with it *extremely* slow.
170- await fse . rm ( path . join ( cwd , 'yarn.lock' ) , { force : true } ) ;
171- await fse . rm ( path . join ( cwd , 'node_modules' ) , { recursive : true , force : true } ) ;
172- await fse . rm ( path . join ( cwd , name , 'node_modules' ) , { recursive : true , force : true } ) ;
173- await fse . rm ( path . join ( cwd , 'test-app' , 'node_modules' ) , { recursive : true , force : true } ) ;
174- await install ( { cwd, packageManager : 'pnpm' , skipPrepare : true } ) ;
175- } ) ;
145+ let { name } = await createAddon ( {
146+ args : [ '--typescript' , `--${ packageManager } =true` , '--skip-npm' ] ,
147+ options : { cwd : tmpDir } ,
148+ } ) ;
176149
177- afterAll ( async ( ) => {
178- await fs . rm ( tmpDir , { recursive : true , force : true } ) ;
179- } ) ;
150+ cwd = path . join ( tmpDir , name ) ;
151+ distDir = path . join ( cwd , name , 'dist' ) ;
180152
181- it ( 'was generated correctly' , async ( ) => {
182- await runScript ( { cwd , script : 'build' , packageManager : 'pnpm' } ) ;
153+ await install ( { cwd , packageManager , skipPrepare : true } ) ;
154+ } ) ;
183155
184- assertGeneratedCorrectly ( { projectRoot : cwd } ) ;
185- } ) ;
156+ afterAll ( async ( ) => {
157+ await fs . rm ( tmpDir , { recursive : true , force : true } ) ;
158+ } ) ;
186159
187- it ( 'builds the addon ' , async ( ) => {
188- let { exitCode } = await runScript ( { cwd, script : 'build' , packageManager : 'pnpm' } ) ;
160+ it ( 'was generated correctly ' , async ( ) => {
161+ await runScript ( { cwd, script : 'build' , packageManager : 'pnpm' } ) ;
189162
190- expect ( exitCode ) . toEqual ( 0 ) ;
163+ assertGeneratedCorrectly ( { projectRoot : cwd } ) ;
164+ } ) ;
191165
192- let contents = await dirContents ( distDir ) ;
166+ it ( 'builds the addon' , async ( ) => {
167+ let { exitCode } = await runScript ( { cwd, script : 'build' , packageManager : 'pnpm' } ) ;
193168
194- expect ( contents ) . to . deep . equal ( [
195- 'index.js' ,
196- 'index.js.map' ,
197- 'template-registry.js' ,
198- 'template-registry.js.map' ,
199- ] ) ;
169+ expect ( exitCode ) . toEqual ( 0 ) ;
200170
201- let typesContents = await dirContents ( distTypesDir ) ;
171+ let contents = await dirContents ( distDir ) ;
202172
203- expect ( typesContents ) . to . deep . equal ( [
204- 'index.d.ts' ,
205- 'index.d.ts.map' ,
206- 'template-registry.d.ts' ,
207- 'template-registry.d.ts.map' ,
208- ] ) ;
209- } ) ;
173+ expect ( contents ) . to . deep . equal ( [
174+ 'index.d.ts' ,
175+ 'index.d.ts.map' ,
176+ 'index.js' ,
177+ 'index.js.map' ,
178+ 'template-registry.d.ts' ,
179+ 'template-registry.js' ,
180+ 'template-registry.js.map' ,
181+ ] ) ;
182+ } ) ;
210183
211- it ( 'runs tests' , async ( ) => {
212- let { exitCode } = await runScript ( { cwd, script : 'test' , packageManager : 'pnpm' } ) ;
184+ it ( 'runs tests' , async ( ) => {
185+ let { exitCode } = await runScript ( { cwd, script : 'test' , packageManager : 'pnpm' } ) ;
213186
214- expect ( exitCode ) . toEqual ( 0 ) ;
215- } ) ;
187+ expect ( exitCode ) . toEqual ( 0 ) ;
188+ } ) ;
216189
217- it ( 'lints all pass' , async ( ) => {
218- let { exitCode } = await runScript ( { cwd, script : 'lint' , packageManager : 'pnpm' } ) ;
190+ it ( 'lints all pass' , async ( ) => {
191+ let { exitCode } = await runScript ( { cwd, script : 'lint' , packageManager : 'pnpm' } ) ;
219192
220- expect ( exitCode ) . toEqual ( 0 ) ;
193+ expect ( exitCode ) . toEqual ( 0 ) ;
194+ } ) ;
221195 } ) ;
222196 } ) ;
223197
0 commit comments