node/test/es-module/test-esm-error-cache.js
Anna Henningsen 2c4ebe0426
test: use .then(common.mustCall()) for all async IIFEs
This makes sure that all async functions finish as expected.

PR-URL: https://github.com/nodejs/node/pull/34363
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-07-20 18:13:28 +02:00

27 lines
454 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const file = '../fixtures/syntax/bad_syntax.mjs';
let error;
(async () => {
try {
await import(file);
} catch (e) {
assert.strictEqual(e.name, 'SyntaxError');
error = e;
}
assert(error);
await assert.rejects(
() => import(file),
(e) => {
assert.strictEqual(error, e);
return true;
}
);
})().then(common.mustCall());