This repository was archived by the owner on Oct 1, 2020. It is now read-only.
File tree 5 files changed +30
-24
lines changed
5 files changed +30
-24
lines changed Original file line number Diff line number Diff line change @@ -22,19 +22,21 @@ Oops...we found an error preparing this test file:
22
22
23
23
The error was:
24
24
25
+ Error: Webpack Compilation Error
25
26
./cypress/tests/e2e/compile-error.js
26
27
Module build failed (from ./node_modules/babel-loader/lib/index.js):
27
- SyntaxError: /[cwd]/cypress/tests/e2e/compile-error.js: Unexpected token, expected "," (12 :27)
28
+ SyntaxError: /[cwd]/cypress/tests/e2e/compile-error.js: Unexpected token, expected "," (14 :27)
28
29
29
- 10 |
30
- 11 | describe('foo', ()=>{
31
- > 12 | it('has syntax error' () => {}})
30
+ 12 |
31
+ 13 | describe('foo', ()=>{
32
+ > 14 | it('has syntax error' () => {}})
32
33
| ^
33
- 13 | })
34
- 14 |
34
+ 15 | })
35
+ 16 |
35
36
36
37
@ multi ./cypress/tests/e2e/compile-error.js main[0]
37
38
39
+
38
40
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
39
41
40
42
- A missing file or dependency
Original file line number Diff line number Diff line change 5
5
/* EXPECT: {
6
6
expectedResults: {
7
7
totalFailed: 1
8
- }
8
+ },
9
+ // https://github.com/cypress-io/cypress-webpack-preprocessor/issues/64
10
+ stdoutInclude: 'Webpack Compilation Error'
9
11
} */
10
12
11
13
describe ( 'foo' , ( ) => {
Original file line number Diff line number Diff line change @@ -108,8 +108,6 @@ const preprocessor = (options = {}) => {
108
108
109
109
const rejectWithErr = ( err ) => {
110
110
err . filePath = filePath
111
- // backup the original stack before it's potentially modified by bluebird
112
- err . originalStack = err . stack
113
111
debug ( `errored bundling ${ outputPath } ` , err )
114
112
latestBundle . reject ( err )
115
113
}
@@ -125,7 +123,14 @@ const preprocessor = (options = {}) => {
125
123
126
124
if ( stats . hasErrors ( ) ) {
127
125
err = new Error ( 'Webpack Compilation Error' )
128
- err . stack = jsonStats . errors . join ( '\n\n' )
126
+
127
+ const errorsToAppend = jsonStats . errors
128
+ // remove stack trace lines since they're useless for debugging
129
+ . map ( ( err ) => err . replace ( / \n \s * a t .* / g, '' ) . replace ( / F r o m p r e v i o u s e v e n t : \n ? / g, '' ) )
130
+ // multiple errors separated by newline
131
+ . join ( '\n\n' )
132
+
133
+ err . message += `\n${ errorsToAppend } `
129
134
130
135
return rejectWithErr ( err )
131
136
}
Original file line number Diff line number Diff line change @@ -65,13 +65,17 @@ exports.runTest = async (options = {}) => {
65
65
expectedResults : {
66
66
totalFailed : 0 ,
67
67
} ,
68
- expectedStdout : null ,
68
+ stdoutInclude : null ,
69
69
browser : 'electron' ,
70
70
exit : true ,
71
71
} )
72
72
73
73
_ . merge ( opts , parsedSpecOptions )
74
74
75
+ if ( _ . isString ( opts . stdoutInclude ) ) {
76
+ opts . stdoutInclude = [ opts . stdoutInclude ]
77
+ }
78
+
75
79
console . log ( chalk . cyanBright ( `starting test run: ${ opts . spec } ` ) )
76
80
77
81
const stdio = captureStdio ( process . stdout )
@@ -106,8 +110,8 @@ exports.runTest = async (options = {}) => {
106
110
expect ( res ) . includes ( opts . expectedResults )
107
111
} )
108
112
. then ( ( ) => {
109
- if ( opts . expectedStdout ) {
110
- _ . forEach ( opts . expectedStdout , ( v ) => {
113
+ if ( opts . stdoutInclude ) {
114
+ _ . forEach ( opts . stdoutInclude , ( v ) => {
111
115
expect ( stdout ) . include ( v )
112
116
console . log ( `${ chalk . bold ( 'run matched stdout:' ) } \n${ v } ` )
113
117
} )
Original file line number Diff line number Diff line change @@ -273,8 +273,9 @@ describe('webpack preprocessor', function () {
273
273
} )
274
274
} )
275
275
276
- it ( 'it rejects with joined errors when a stats err' , function ( ) {
277
- const errs = [ 'foo' , 'bar' , 'baz' ]
276
+ it ( 'it rejects with joined errors when a stats err and strips stacktrace' , function ( ) {
277
+ const errs = [ 'foo\nat Object.foo' , 'bar' , 'baz' ]
278
+ const errsNoStack = [ 'foo' , 'bar' , 'baz' ]
278
279
279
280
this . statsApi = {
280
281
hasErrors ( ) {
@@ -288,15 +289,7 @@ describe('webpack preprocessor', function () {
288
289
this . compilerApi . run . yields ( null , this . statsApi )
289
290
290
291
return this . run ( ) . catch ( ( err ) => {
291
- expect ( err . stack ) . to . equal ( errs . join ( '\n\n' ) )
292
- } )
293
- } )
294
-
295
- it ( 'backs up stack as originalStack' , function ( ) {
296
- this . compilerApi . run . yields ( this . err )
297
-
298
- return this . run ( ) . catch ( ( err ) => {
299
- expect ( err . originalStack ) . to . equal ( this . err . stack )
292
+ expect ( err . message ) . to . equal ( `Webpack Compilation Error\n${ errsNoStack . join ( '\n\n' ) } ` )
300
293
} )
301
294
} )
302
295
} )
You can’t perform that action at this time.
0 commit comments