This repository was archived by the owner on Oct 1, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +30
-24
lines changed Expand file tree Collapse file tree 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:
2222
2323The error was:
2424
25+ Error: Webpack Compilation Error
2526./cypress/tests/e2e/compile-error.js
2627Module 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)
2829
29- 10 |
30- 11 | describe('foo', ()=>{
31- > 12 | it('has syntax error' () => {}})
30+ 12 |
31+ 13 | describe('foo', ()=>{
32+ > 14 | it('has syntax error' () => {}})
3233 | ^
33- 13 | })
34- 14 |
34+ 15 | })
35+ 16 |
3536
3637 @ multi ./cypress/tests/e2e/compile-error.js main[0]
3738
39+
3840This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
3941
4042- A missing file or dependency
Original file line number Diff line number Diff line change 55/* EXPECT: {
66 expectedResults: {
77 totalFailed: 1
8- }
8+ },
9+ // https://github.com/cypress-io/cypress-webpack-preprocessor/issues/64
10+ stdoutInclude: 'Webpack Compilation Error'
911} */
1012
1113describe ( 'foo' , ( ) => {
Original file line number Diff line number Diff line change @@ -108,8 +108,6 @@ const preprocessor = (options = {}) => {
108108
109109 const rejectWithErr = ( err ) => {
110110 err . filePath = filePath
111- // backup the original stack before it's potentially modified by bluebird
112- err . originalStack = err . stack
113111 debug ( `errored bundling ${ outputPath } ` , err )
114112 latestBundle . reject ( err )
115113 }
@@ -125,7 +123,14 @@ const preprocessor = (options = {}) => {
125123
126124 if ( stats . hasErrors ( ) ) {
127125 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 } `
129134
130135 return rejectWithErr ( err )
131136 }
Original file line number Diff line number Diff line change @@ -65,13 +65,17 @@ exports.runTest = async (options = {}) => {
6565 expectedResults : {
6666 totalFailed : 0 ,
6767 } ,
68- expectedStdout : null ,
68+ stdoutInclude : null ,
6969 browser : 'electron' ,
7070 exit : true ,
7171 } )
7272
7373 _ . merge ( opts , parsedSpecOptions )
7474
75+ if ( _ . isString ( opts . stdoutInclude ) ) {
76+ opts . stdoutInclude = [ opts . stdoutInclude ]
77+ }
78+
7579 console . log ( chalk . cyanBright ( `starting test run: ${ opts . spec } ` ) )
7680
7781 const stdio = captureStdio ( process . stdout )
@@ -106,8 +110,8 @@ exports.runTest = async (options = {}) => {
106110 expect ( res ) . includes ( opts . expectedResults )
107111 } )
108112 . then ( ( ) => {
109- if ( opts . expectedStdout ) {
110- _ . forEach ( opts . expectedStdout , ( v ) => {
113+ if ( opts . stdoutInclude ) {
114+ _ . forEach ( opts . stdoutInclude , ( v ) => {
111115 expect ( stdout ) . include ( v )
112116 console . log ( `${ chalk . bold ( 'run matched stdout:' ) } \n${ v } ` )
113117 } )
Original file line number Diff line number Diff line change @@ -273,8 +273,9 @@ describe('webpack preprocessor', function () {
273273 } )
274274 } )
275275
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' ]
278279
279280 this . statsApi = {
280281 hasErrors ( ) {
@@ -288,15 +289,7 @@ describe('webpack preprocessor', function () {
288289 this . compilerApi . run . yields ( null , this . statsApi )
289290
290291 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' ) } ` )
300293 } )
301294 } )
302295 } )
You can’t perform that action at this time.
0 commit comments