mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
fb3f6005c0
Fix tests whether errors are thrown correctly because they are successful when error doesn't get thrown. PR-URL: https://github.com/nodejs/node/pull/27333 Fixes: https://github.com/nodejs/node/issues/26385 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
29 lines
449 B
JavaScript
29 lines
449 B
JavaScript
// Flags: --experimental-modules
|
|
|
|
'use strict';
|
|
|
|
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;
|
|
}
|
|
);
|
|
})();
|