@@ -20,7 +20,7 @@ describe('loader', function() {
20
20
esModuleSharedExamples ( 'js' , true ) ;
21
21
} ) ;
22
22
23
- describe ( 'When the extnesion is not supported by import()' , function ( ) {
23
+ describe ( 'When the extension is not supported by import()' , function ( ) {
24
24
it ( 'falls back to require()' , async function ( ) {
25
25
const error = new TypeError ( ) ;
26
26
error . code = 'ERR_UNKNOWN_FILE_EXTENSION' ;
@@ -155,9 +155,15 @@ function esModuleSharedExamples(extension, alwaysImport) {
155
155
const underlyingError = new SyntaxError ( 'some details but no filename, not even in the stack trace' ) ;
156
156
const loader = new Loader ( { importShim : ( ) => Promise . reject ( underlyingError ) } ) ;
157
157
158
- await expectAsync ( loader . load ( `foo.${ extension } ` , alwaysImport ) ) . toBeRejectedWithError (
159
- `While loading foo.${ extension } : SyntaxError: some details but no filename, not even in the stack trace`
160
- ) ;
158
+ try {
159
+ await loader . load ( `foo.${ extension } ` , alwaysImport ) ;
160
+ fail ( 'Expected loader to throw but it did not' ) ;
161
+ } catch ( thrown ) {
162
+ expect ( thrown . message ) . toEqual (
163
+ `While loading foo.${ extension } : SyntaxError: some details but no filename, not even in the stack trace`
164
+ ) ;
165
+ expect ( thrown . cause ) . toBe ( underlyingError ) ;
166
+ }
161
167
} ) ;
162
168
163
169
it ( 'does not modify errors that are not SyntaxError instances' , async function ( ) {
0 commit comments