Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 4cba2fe

Browse files
committed
append error to error.message instead of stack
1 parent 1fecb5b commit 4cba2fe

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

__snapshots__/e2e.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Oops...we found an error preparing this test file:
2222
2323
The error was:
2424
25+
Error: Webpack Compilation Error
2526
./cypress/tests/e2e/compile-error.js
2627
Module build failed (from ./node_modules/babel-loader/lib/index.js):
2728
SyntaxError: /[cwd]/cypress/tests/e2e/compile-error.js: Unexpected token, expected "," (12:27)
@@ -35,6 +36,7 @@ SyntaxError: /[cwd]/cypress/tests/e2e/compile-error.js: Unexpected token, expect
3536
3637
@ multi ./cypress/tests/e2e/compile-error.js main[0]
3738
39+
3840
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
3941
4042
- A missing file or dependency

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff 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,11 @@ const preprocessor = (options = {}) => {
125123

126124
if (stats.hasErrors()) {
127125
err = new Error('Webpack Compilation Error')
128-
err.stack = jsonStats.errors.join('\n\n')
126+
err.message += `\n${jsonStats.errors
127+
// remove stack trace lines since they're useless for debugging
128+
.map((err) => err.replace(/\n\s*at.*/g, '').replace(/From previous event:\n?/g, ''))
129+
// multiple errors separated by newline
130+
.join('\n\n')}`
129131

130132
return rejectWithErr(err)
131133
}

0 commit comments

Comments
 (0)