1
1
import {
2
2
checkFilesExist ,
3
3
ensureNxProject ,
4
- readJson ,
5
4
runNxCommandAsync ,
6
5
uniq ,
7
6
} from '@nrwl/nx-plugin/testing' ;
8
7
8
+ import {
9
+ runCommandUntil ,
10
+ promisifiedTreeKill ,
11
+ killPort ,
12
+ } from '@qwikifiers/e2e/utils' ;
13
+
9
14
describe ( 'qwik-nx e2e' , ( ) => {
10
15
// Setting up individual workspaces per
11
16
// test can cause e2e runs to take a long time.
@@ -23,34 +28,41 @@ describe('qwik-nx e2e', () => {
23
28
runNxCommandAsync ( 'reset' ) ;
24
29
} ) ;
25
30
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' ) ;
36
35
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 } `
38
43
) ;
39
44
expect ( ( ) =>
40
- checkFilesExist ( `libs/subdir /${ project } /src/index.ts ` )
45
+ checkFilesExist ( `dist/apps /${ project } /client/q-manifest.json ` )
41
46
) . not . toThrow ( ) ;
42
- } , 120000 ) ;
43
- } ) ;
47
+ expect ( ( ) =>
48
+ checkFilesExist ( `dist/apps/${ project } /server/entry.preview.mjs` )
49
+ ) . not . toThrow ( ) ;
50
+ } , 200000 ) ;
44
51
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
+ }
51
59
) ;
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 ) ;
55
67
} ) ;
56
68
} ) ;
0 commit comments