11import {
22 checkFilesExist ,
33 ensureNxProject ,
4- readJson ,
54 runNxCommandAsync ,
65 uniq ,
76} from '@nrwl/nx-plugin/testing' ;
87
8+ import {
9+ runCommandUntil ,
10+ promisifiedTreeKill ,
11+ killPort ,
12+ } from '@qwikifiers/e2e/utils' ;
13+
914describe ( 'qwik-nx e2e' , ( ) => {
1015 // Setting up individual workspaces per
1116 // test can cause e2e runs to take a long time.
@@ -23,34 +28,41 @@ describe('qwik-nx e2e', () => {
2328 runNxCommandAsync ( 'reset' ) ;
2429 } ) ;
2530
26- it ( 'should create qwik-nx' , async ( ) => {
27- const project = uniq ( 'qwik-nx' ) ;
28- await runNxCommandAsync ( `generate qwik-nx:app ${ project } ` ) ;
29- const result = await runNxCommandAsync ( `build ${ project } ` ) ;
30- expect ( result . stdout ) . toContain ( 'Executor ran' ) ;
31- } , 120000 ) ;
32-
33- describe ( '--directory' , ( ) => {
34- it ( 'should create src in the specified directory' , async ( ) => {
35- const project = uniq ( 'qwik-nx' ) ;
31+ describe ( 'Basic behavior' , ( ) => {
32+ let project : string ;
33+ beforeAll ( async ( ) => {
34+ project = uniq ( 'qwik-nx' ) ;
3635 await runNxCommandAsync (
37- `generate qwik-nx:app ${ project } --directory subdir`
36+ `generate qwik-nx:app ${ project } --no-interactive`
37+ ) ;
38+ } , 200000 ) ;
39+ it ( 'should create qwik-nx' , async ( ) => {
40+ const result = await runNxCommandAsync ( `build-ssr ${ project } ` ) ;
41+ expect ( result . stdout ) . toContain (
42+ `Successfully ran target build-ssr for project ${ project } `
3843 ) ;
3944 expect ( ( ) =>
40- checkFilesExist ( `libs/subdir /${ project } /src/index.ts ` )
45+ checkFilesExist ( `dist/apps /${ project } /client/q-manifest.json ` )
4146 ) . not . toThrow ( ) ;
42- } , 120000 ) ;
43- } ) ;
47+ expect ( ( ) =>
48+ checkFilesExist ( `dist/apps/${ project } /server/entry.preview.mjs` )
49+ ) . not . toThrow ( ) ;
50+ } , 200000 ) ;
4451
45- describe ( '--tags' , ( ) => {
46- it ( 'should add tags to the project' , async ( ) => {
47- const projectName = uniq ( 'qwik-nx' ) ;
48- ensureNxProject ( 'qwik-nx' , 'dist/packages/qwik-nx' ) ;
49- await runNxCommandAsync (
50- `generate qwik-nx:app ${ projectName } --tags e2etag,e2ePackage`
52+ it ( 'should serve application in dev mode with custom port' , async ( ) => {
53+ const port = 4212 ;
54+ const p = await runCommandUntil (
55+ `run ${ project } :serve --port=${ port } ` ,
56+ ( output ) => {
57+ return output . includes ( 'Local:' ) && output . includes ( `:${ port } ` ) ;
58+ }
5159 ) ;
52- const project = readJson ( `libs/${ projectName } /project.json` ) ;
53- expect ( project . tags ) . toEqual ( [ 'e2etag' , 'e2ePackage' ] ) ;
54- } , 120000 ) ;
60+ try {
61+ await promisifiedTreeKill ( p . pid , 'SIGKILL' ) ;
62+ await killPort ( port ) ;
63+ } catch {
64+ // ignore
65+ }
66+ } , 200000 ) ;
5567 } ) ;
5668} ) ;
0 commit comments