@@ -19,29 +19,24 @@ import '../support'
19
19
import { scaffoldMigrationProject } from '../test-helpers/scaffoldProject'
20
20
21
21
chai . use ( chaiPromise )
22
-
23
22
describe ( 'angularHandler' , function ( ) {
24
23
this . timeout ( 1000 * 60 )
25
-
26
24
it ( 'sources the config from angular-13' , async ( ) => {
27
25
const projectRoot = await scaffoldMigrationProject ( 'angular-13' )
28
26
29
27
process . chdir ( projectRoot )
30
-
31
28
const devServerConfig = {
32
29
cypressConfig : {
33
30
projectRoot,
34
31
specPattern : 'src/**/*.cy.ts' ,
35
32
} as Cypress . PluginConfigOptions ,
36
33
framework : 'angular' ,
37
34
} as AngularWebpackDevServerConfig
38
-
39
35
const { frameworkConfig : webpackConfig , sourceWebpackModulesResult } = await angularHandler ( devServerConfig )
40
36
41
37
expect ( webpackConfig ) . to . exist
42
38
expect ( ( webpackConfig ?. entry as any ) . main ) . to . be . undefined
43
39
expect ( sourceWebpackModulesResult . framework ?. importPath ) . to . include ( path . join ( '@angular-devkit' , 'build-angular' ) )
44
-
45
40
const { buildOptions } = await expectNormalizeProjectConfig ( projectRoot )
46
41
47
42
await expectLoadsAngularJson ( projectRoot )
@@ -54,21 +49,18 @@ describe('angularHandler', function () {
54
49
const projectRoot = await scaffoldMigrationProject ( 'angular-14' )
55
50
56
51
process . chdir ( projectRoot )
57
-
58
52
const devServerConfig = {
59
53
cypressConfig : {
60
54
projectRoot,
61
55
specPattern : 'src/**/*.cy.ts' ,
62
56
} as Cypress . PluginConfigOptions ,
63
57
framework : 'angular' ,
64
58
} as AngularWebpackDevServerConfig
65
-
66
59
const { frameworkConfig : webpackConfig , sourceWebpackModulesResult } = await angularHandler ( devServerConfig )
67
60
68
61
expect ( webpackConfig ) . to . exist
69
62
expect ( ( webpackConfig ?. entry as any ) . main ) . to . be . undefined
70
63
expect ( sourceWebpackModulesResult . framework ?. importPath ) . to . include ( path . join ( '@angular-devkit' , 'build-angular' ) )
71
-
72
64
const { buildOptions } = await expectNormalizeProjectConfig ( projectRoot )
73
65
74
66
await expectLoadsAngularJson ( projectRoot )
@@ -81,21 +73,18 @@ describe('angularHandler', function () {
81
73
const projectRoot = await scaffoldMigrationProject ( 'angular-15' )
82
74
83
75
process . chdir ( projectRoot )
84
-
85
76
const devServerConfig = {
86
77
cypressConfig : {
87
78
projectRoot,
88
79
specPattern : 'src/**/*.cy.ts' ,
89
80
} as Cypress . PluginConfigOptions ,
90
81
framework : 'angular' ,
91
82
} as AngularWebpackDevServerConfig
92
-
93
83
const { frameworkConfig : webpackConfig , sourceWebpackModulesResult } = await angularHandler ( devServerConfig )
94
84
95
85
expect ( webpackConfig ) . to . exist
96
86
expect ( ( webpackConfig ?. entry as any ) . main ) . to . be . undefined
97
87
expect ( sourceWebpackModulesResult . framework ?. importPath ) . to . include ( path . join ( '@angular-devkit' , 'build-angular' ) )
98
-
99
88
const { buildOptions } = await expectNormalizeProjectConfig ( projectRoot )
100
89
101
90
await expectLoadsAngularJson ( projectRoot )
@@ -129,7 +118,6 @@ describe('angularHandler', function () {
129
118
const projectRoot = await scaffoldMigrationProject ( 'angular-custom-config' )
130
119
131
120
process . chdir ( projectRoot )
132
-
133
121
const devServerConfig = {
134
122
framework : 'angular' ,
135
123
cypressConfig : {
@@ -140,13 +128,11 @@ describe('angularHandler', function () {
140
128
projectConfig : customProjectConfig ,
141
129
} ,
142
130
} as unknown as AngularWebpackDevServerConfig
143
-
144
131
const { frameworkConfig : webpackConfig , sourceWebpackModulesResult } = await angularHandler ( devServerConfig )
145
132
146
133
expect ( webpackConfig ) . to . exist
147
134
expect ( ( webpackConfig ?. entry as any ) . main ) . to . be . undefined
148
135
expect ( sourceWebpackModulesResult . framework ?. importPath ) . to . include ( path . join ( '@angular-devkit' , 'build-angular' ) )
149
-
150
136
await expectLoadsAngularJson ( projectRoot )
151
137
await expectLoadsAngularCLiModules ( projectRoot )
152
138
await expectGeneratesTsConfig ( devServerConfig , customProjectConfig . buildOptions )
@@ -181,28 +167,22 @@ const expectNormalizeProjectConfig = async (projectRoot: string) => {
181
167
182
168
return projectConfig
183
169
}
184
-
185
170
const expectLoadsAngularJson = async ( projectRoot : string ) => {
186
171
const angularJson = await getAngularJson ( projectRoot )
187
172
188
173
expect ( angularJson ) . to . not . be . null
189
-
190
174
await expect ( getAngularJson ( path . join ( '..' , projectRoot ) ) ) . to . be . rejected
191
175
}
192
-
193
176
const expectLoadsAngularCLiModules = async ( projectRoot : string ) => {
194
177
const angularCliModules = await getAngularCliModules ( projectRoot )
195
178
196
179
expect ( angularCliModules . generateBrowserWebpackConfigFromContext ) . to . not . be . null
197
180
expect ( angularCliModules . getStylesConfig ) . to . not . be . null
198
181
expect ( angularCliModules . getCommonConfig ) . to . not . be . null
199
-
200
182
await expect ( getAngularCliModules ( path . join ( '..' , projectRoot ) ) ) . to . be . rejected
201
183
}
202
-
203
184
const expectLoadsAngularBuildOptions = ( buildOptions : BuildOptions ) => {
204
185
const tsConfig = 'tsconfig.cypress.json'
205
-
206
186
let finalBuildOptions = getAngularBuildOptions ( buildOptions , tsConfig )
207
187
208
188
expect ( finalBuildOptions . aot ) . to . be . false
@@ -211,7 +191,6 @@ const expectLoadsAngularBuildOptions = (buildOptions: BuildOptions) => {
211
191
expect ( finalBuildOptions . outputHashing ) . to . equal ( 'none' )
212
192
expect ( finalBuildOptions . budgets ) . to . be . undefined
213
193
}
214
-
215
194
const expectGeneratesTsConfig = async ( devServerConfig : AngularWebpackDevServerConfig , buildOptions : any ) => {
216
195
const { projectRoot } = devServerConfig . cypressConfig
217
196
let tsConfigPath = await generateTsConfig ( devServerConfig , buildOptions )
@@ -228,11 +207,16 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC
228
207
outDir : toPosix ( path . join ( projectRoot , 'out-tsc/cy' ) ) ,
229
208
allowSyntheticDefaultImports : true ,
230
209
skipLibCheck : true ,
210
+ typeRoots : [
211
+ toPosix ( path . join ( projectRoot , 'node_modules' ) ) ,
212
+ ] ,
213
+ types : [
214
+ 'cypress' ,
215
+ ] ,
231
216
} ,
232
217
include : [
233
218
toPosix ( path . join ( projectRoot , 'src/**/*.cy.ts' ) ) ,
234
219
toPosix ( path . join ( projectRoot , 'src/polyfills.ts' ) ) ,
235
- toPosix ( path . join ( projectRoot , 'node_modules/cypress/types/index.d.ts' ) ) ,
236
220
] ,
237
221
} )
238
222
@@ -256,11 +240,16 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC
256
240
outDir : toPosix ( path . join ( projectRoot , 'out-tsc/cy' ) ) ,
257
241
allowSyntheticDefaultImports : true ,
258
242
skipLibCheck : true ,
243
+ typeRoots : [
244
+ toPosix ( path . join ( projectRoot , 'node_modules' ) ) ,
245
+ ] ,
246
+ types : [
247
+ 'cypress' ,
248
+ ] ,
259
249
} ,
260
250
include : [
261
251
toPosix ( path . join ( projectRoot , 'src/**/*.cy.ts' ) ) ,
262
252
toPosix ( supportFile ) ,
263
- toPosix ( path . join ( projectRoot , 'node_modules/cypress/types/index.d.ts' ) ) ,
264
253
] ,
265
254
} )
266
255
}
0 commit comments