-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* eslint-disable local-rules/no-uncategorized-errors */ | ||
import { WebpackCompilationError } from './server-errors'; | ||
|
||
describe('WebpackCompilationError', () => { | ||
it('should correctly handle error with error property', () => { | ||
const error = new Error('Custom error message'); | ||
const data = { | ||
error, | ||
}; | ||
|
||
const webpackError = new WebpackCompilationError(data); | ||
|
||
expect(webpackError.message).toBe(error.message); | ||
}); | ||
|
||
it('should correctly handle error with error within error', () => { | ||
const error = new Error('Custom error message'); | ||
const data = { | ||
error: new Error(), | ||
}; | ||
data.error = error; | ||
|
||
const webpackError = new WebpackCompilationError(data); | ||
|
||
expect(webpackError.message).toBe(error.message); | ||
}); | ||
|
||
it('should correctly handle error with stats.compilation.errors', () => { | ||
const compilationErrors = [new Error('Error 1 message'), new Error('Error 2 message')]; | ||
const data = new Error() as Error & { | ||
error: Error & { stats?: { compilation: { errors: Error[] } } }; | ||
}; | ||
data.error = new Error(); | ||
data.error.stats = { | ||
compilation: { | ||
errors: compilationErrors, | ||
}, | ||
}; | ||
|
||
const webpackError = new WebpackCompilationError(data); | ||
|
||
expect(webpackError.message).toMatchInlineSnapshot(` | ||
"Error: Error 1 message | ||
Error: Error 2 message" | ||
`); | ||
}); | ||
|
||
it('should correctly handle error without specific format', () => { | ||
const errorMessage = 'Generic error message'; | ||
const data = new Error() as Error & { | ||
error: Error; | ||
}; | ||
|
||
data.error = new Error(errorMessage); | ||
|
||
const webpackError = new WebpackCompilationError(data); | ||
|
||
expect(webpackError.message).toBe(errorMessage); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters