@@ -9,60 +9,117 @@ import {
9
9
} from '@nx/e2e/utils' ;
10
10
11
11
describe ( 'React Router Applications' , ( ) => {
12
- beforeAll ( ( ) => {
13
- newProject ( { packages : [ '@nx/react' ] } ) ;
14
- ensureCypressInstallation ( ) ;
15
- } ) ;
12
+ describe ( 'TS paths' , ( ) => {
13
+ const appName = uniq ( 'app' ) ;
14
+ beforeAll ( ( ) => {
15
+ newProject ( { packages : [ '@nx/react' ] } ) ;
16
+ ensureCypressInstallation ( ) ;
17
+ runCLI (
18
+ `generate @nx/react:app ${ appName } --use-react-router --routing --linter=eslint --unit-test-runner=vitest --no-interactive`
19
+ ) ;
20
+ } ) ;
16
21
17
- afterAll ( ( ) => cleanupProject ( ) ) ;
22
+ afterAll ( ( ) => cleanupProject ( ) ) ;
18
23
19
- it ( 'should generate a react-router application' , async ( ) => {
20
- const appName = uniq ( 'app' ) ;
21
- runCLI (
22
- `generate @nx/react:app ${ appName } --use-react-router --routing --no-interactive`
23
- ) ;
24
-
25
- const packageJson = JSON . parse ( readFile ( 'package.json' ) ) ;
26
- expect ( packageJson . dependencies [ 'react-router' ] ) . toBeDefined ( ) ;
27
- expect ( packageJson . dependencies [ '@react-router/node' ] ) . toBeDefined ( ) ;
28
- expect ( packageJson . dependencies [ '@react-router/serve' ] ) . toBeDefined ( ) ;
29
- expect ( packageJson . dependencies [ 'isbot' ] ) . toBeDefined ( ) ;
30
-
31
- checkFilesExist ( `${ appName } /app/app.tsx` ) ;
32
- checkFilesExist ( `${ appName } /app/entry.client.tsx` ) ;
33
- checkFilesExist ( `${ appName } /app/entry.server.tsx` ) ;
34
- checkFilesExist ( `${ appName } /app/routes.tsx` ) ;
35
- checkFilesExist ( `${ appName } /react-router.config.ts` ) ;
36
- checkFilesExist ( `${ appName } /vite.config.ts` ) ;
37
- } ) ;
24
+ it ( 'should generate a react-router application' , async ( ) => {
25
+ const packageJson = JSON . parse ( readFile ( 'package.json' ) ) ;
26
+ expect ( packageJson . dependencies [ 'react-router' ] ) . toBeDefined ( ) ;
27
+ expect ( packageJson . dependencies [ '@react-router/node' ] ) . toBeDefined ( ) ;
28
+ expect ( packageJson . dependencies [ '@react-router/serve' ] ) . toBeDefined ( ) ;
29
+ expect ( packageJson . dependencies [ 'isbot' ] ) . toBeDefined ( ) ;
38
30
39
- it ( 'should be able to build a react-router application' , async ( ) => {
40
- const appName = uniq ( 'app' ) ;
41
- runCLI (
42
- `generate @nx/react:app ${ appName } --use-react-router --routing --no-interactive`
43
- ) ;
31
+ checkFilesExist ( `${ appName } /app/app.tsx` ) ;
32
+ checkFilesExist ( `${ appName } /app/entry.client.tsx` ) ;
33
+ checkFilesExist ( `${ appName } /app/entry.server.tsx` ) ;
34
+ checkFilesExist ( `${ appName } /app/routes.tsx` ) ;
35
+ checkFilesExist ( `${ appName } /react-router.config.ts` ) ;
36
+ checkFilesExist ( `${ appName } /vite.config.ts` ) ;
37
+ } ) ;
44
38
45
- const buildResult = runCLI ( `build ${ appName } ` ) ;
46
- expect ( buildResult ) . toContain ( 'Successfully ran target build' ) ;
47
- } ) ;
39
+ it ( 'should be able to build a react-router application' , async ( ) => {
40
+ const buildResult = runCLI ( `build ${ appName } ` ) ;
41
+ expect ( buildResult ) . toContain ( 'Successfully ran target build' ) ;
42
+ } ) ;
48
43
49
- it ( 'should be able to lint a react-router application' , async ( ) => {
50
- const appName = uniq ( 'app' ) ;
51
- runCLI (
52
- `generate @nx/react:app ${ appName } --use-react-router --routing --linter=eslint --no-interactive`
53
- ) ;
44
+ it ( 'should be able to lint a react-router application' , async ( ) => {
45
+ const lintResult = runCLI ( `lint ${ appName } ` ) ;
46
+ expect ( lintResult ) . toContain ( 'Successfully ran target lint' ) ;
47
+ } ) ;
54
48
55
- const buildResult = runCLI ( `lint ${ appName } ` ) ;
56
- expect ( buildResult ) . toContain ( 'Successfully ran target lint' ) ;
57
- } ) ;
49
+ it ( 'should be able to test and typecheck a react-router application' , async ( ) => {
50
+ const typeCheckResult = runCLI ( `typecheck ${ appName } ` ) ;
51
+ expect ( typeCheckResult ) . toContain ( 'Successfully ran target typecheck' ) ;
52
+ } ) ;
53
+
54
+ it ( 'should be able to test and typecheck a react-router application with jest' , async ( ) => {
55
+ const jestApp = uniq ( 'jestApp' ) ;
56
+ runCLI (
57
+ `generate @nx/react:app ${ jestApp } --use-react-router --routing --unit-test-runner=jest --no-interactive`
58
+ ) ;
59
+
60
+ const testResult = runCLI ( `test ${ jestApp } ` ) ;
61
+ expect ( testResult ) . toContain ( 'Successfully ran target test' ) ;
58
62
59
- it ( 'should be able to test a react-router application' , async ( ) => {
63
+ const typeCheckResult = runCLI ( `typecheck ${ jestApp } ` ) ;
64
+ expect ( typeCheckResult ) . toContain ( 'Successfully ran target typecheck' ) ;
65
+ } ) ;
66
+ } ) ;
67
+ describe ( 'TS Solution' , ( ) => {
60
68
const appName = uniq ( 'app' ) ;
61
- runCLI (
62
- `generate @nx/react:app ${ appName } --use-react-router --routing --unit-test-runner=vitest --no-interactive`
63
- ) ;
69
+ beforeAll ( ( ) => {
70
+ newProject ( { preset : 'ts' , packages : [ '@nx/react' ] } ) ;
71
+ ensureCypressInstallation ( ) ;
72
+ runCLI (
73
+ `generate @nx/react:app ${ appName } --use-react-router --routing --linter=eslint --unit-test-runner=vitest --no-interactive`
74
+ ) ;
75
+ } ) ;
76
+
77
+ afterAll ( ( ) => cleanupProject ( ) ) ;
78
+
79
+ it ( 'should generate a react-router application' , async ( ) => {
80
+ const packageJson = JSON . parse ( readFile ( 'package.json' ) ) ;
81
+ expect ( packageJson . dependencies [ 'react-router' ] ) . toBeDefined ( ) ;
82
+ expect ( packageJson . dependencies [ '@react-router/node' ] ) . toBeDefined ( ) ;
83
+ expect ( packageJson . dependencies [ '@react-router/serve' ] ) . toBeDefined ( ) ;
84
+ expect ( packageJson . dependencies [ 'isbot' ] ) . toBeDefined ( ) ;
85
+
86
+ checkFilesExist ( `${ appName } /app/app.tsx` ) ;
87
+ checkFilesExist ( `${ appName } /app/entry.client.tsx` ) ;
88
+ checkFilesExist ( `${ appName } /app/entry.server.tsx` ) ;
89
+ checkFilesExist ( `${ appName } /app/routes.tsx` ) ;
90
+ checkFilesExist ( `${ appName } /react-router.config.ts` ) ;
91
+ checkFilesExist ( `${ appName } /vite.config.ts` ) ;
92
+ } ) ;
93
+
94
+ it ( 'should be able to build a react-router application' , async ( ) => {
95
+ const buildResult = runCLI ( `build ${ appName } ` ) ;
96
+ expect ( buildResult ) . toContain ( 'Successfully ran target build' ) ;
97
+ } ) ;
98
+
99
+ it ( 'should be able to lint a react-router application' , async ( ) => {
100
+ const lintResult = runCLI ( `lint ${ appName } ` ) ;
101
+ expect ( lintResult ) . toContain ( 'Successfully ran target lint' ) ;
102
+ } ) ;
103
+
104
+ it ( 'should be able to test and typecheck a react-router application' , async ( ) => {
105
+ const testResult = runCLI ( `test ${ appName } ` ) ;
106
+ expect ( testResult ) . toContain ( 'Successfully ran target test' ) ;
107
+
108
+ const typeCheckResult = runCLI ( `typecheck ${ appName } ` ) ;
109
+ expect ( typeCheckResult ) . toContain ( 'Successfully ran target typecheck' ) ;
110
+ } ) ;
111
+
112
+ it ( 'should be able to test and typecheck a react-router application with jest' , async ( ) => {
113
+ const jestApp = uniq ( 'jestApp' ) ;
114
+ runCLI (
115
+ `generate @nx/react:app ${ jestApp } --use-react-router --routing --unit-test-runner=jest --no-interactive`
116
+ ) ;
117
+
118
+ const testResult = runCLI ( `test ${ jestApp } ` ) ;
119
+ expect ( testResult ) . toContain ( 'Successfully ran target test' ) ;
64
120
65
- const buildResult = runCLI ( `test ${ appName } ` ) ;
66
- expect ( buildResult ) . toContain ( 'Successfully ran target test' ) ;
121
+ const typeCheckResult = runCLI ( `typecheck ${ jestApp } ` ) ;
122
+ expect ( typeCheckResult ) . toContain ( 'Successfully ran target typecheck' ) ;
123
+ } ) ;
67
124
} ) ;
68
125
} ) ;
0 commit comments