@@ -7,44 +7,65 @@ jest.setTimeout(1000 * 60 * 2)
7
7
8
8
const appDir = join ( __dirname , '..' )
9
9
const nextConfigFile = new File ( join ( appDir , 'next.config.js' ) )
10
+ const tsConfigFile = new File ( join ( appDir , 'tsconfig.json' ) )
10
11
11
12
describe ( 'TypeScript with error handling options' , ( ) => {
12
13
// Dev can no longer show errors (for now), logbox will cover this in the
13
14
// future.
14
- for ( const ignoreBuildErrors of [ false , true ] ) {
15
- describe ( `ignoreBuildErrors: ${ ignoreBuildErrors } ` , ( ) => {
16
- beforeAll ( ( ) => {
17
- const nextConfig = {
18
- typescript : { ignoreBuildErrors } ,
19
- }
20
- nextConfigFile . write ( 'module.exports = ' + JSON . stringify ( nextConfig ) )
21
- } )
22
- afterAll ( ( ) => {
23
- nextConfigFile . restore ( )
24
- } )
15
+ for ( const incremental of [ false , true ] ) {
16
+ for ( const ignoreBuildErrors of [ false , true ] ) {
17
+ describe ( `ignoreBuildErrors: ${ ignoreBuildErrors } ` , ( ) => {
18
+ beforeAll ( ( ) => {
19
+ const nextConfig = {
20
+ typescript : { ignoreBuildErrors } ,
21
+ }
22
+ nextConfigFile . write ( 'module.exports = ' + JSON . stringify ( nextConfig ) )
23
+ const tsconfig = JSON . parse ( tsConfigFile . originalContent )
24
+ tsConfigFile . write (
25
+ JSON . stringify (
26
+ {
27
+ ...tsconfig ,
28
+ compilerOptions : {
29
+ ...tsconfig . compilerOptions ,
30
+ incremental,
31
+ } ,
32
+ } ,
33
+ null ,
34
+ 2
35
+ )
36
+ )
37
+ } )
38
+ afterAll ( ( ) => {
39
+ nextConfigFile . restore ( )
40
+ tsConfigFile . restore ( )
41
+ } )
25
42
26
- it (
27
- ignoreBuildErrors
28
- ? 'Next builds the application despite type errors'
29
- : 'Next fails to build the application despite type errors' ,
30
- async ( ) => {
31
- const { stdout, stderr } = await nextBuild ( appDir , [ ] , {
32
- stdout : true ,
33
- stderr : true ,
34
- } )
43
+ it (
44
+ ( ignoreBuildErrors
45
+ ? 'Next builds the application despite type errors'
46
+ : 'Next fails to build the application despite type errors' ) +
47
+ ( incremental
48
+ ? ' in incremental mode'
49
+ : ' without incremental mode' ) ,
50
+ async ( ) => {
51
+ const { stdout, stderr } = await nextBuild ( appDir , [ ] , {
52
+ stdout : true ,
53
+ stderr : true ,
54
+ } )
35
55
36
- if ( ignoreBuildErrors ) {
37
- expect ( stdout ) . toContain ( 'Compiled successfully' )
38
- expect ( stderr ) . not . toContain ( 'Failed to compile.' )
39
- expect ( stderr ) . not . toContain ( "not assignable to type 'boolean'" )
40
- } else {
41
- expect ( stdout ) . not . toContain ( 'Compiled successfully' )
42
- expect ( stderr ) . toContain ( 'Failed to compile.' )
43
- expect ( stderr ) . toContain ( './pages/index.tsx:2:31' )
44
- expect ( stderr ) . toContain ( "not assignable to type 'boolean'" )
56
+ if ( ignoreBuildErrors ) {
57
+ expect ( stdout ) . toContain ( 'Compiled successfully' )
58
+ expect ( stderr ) . not . toContain ( 'Failed to compile.' )
59
+ expect ( stderr ) . not . toContain ( "not assignable to type 'boolean'" )
60
+ } else {
61
+ expect ( stdout ) . not . toContain ( 'Compiled successfully' )
62
+ expect ( stderr ) . toContain ( 'Failed to compile.' )
63
+ expect ( stderr ) . toContain ( './pages/index.tsx:2:31' )
64
+ expect ( stderr ) . toContain ( "not assignable to type 'boolean'" )
65
+ }
45
66
}
46
- }
47
- )
48
- } )
67
+ )
68
+ } )
69
+ }
49
70
}
50
71
} )
0 commit comments