0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/es-module/test-esm-error-cache.js
Masashi Hirano fb3f6005c0 test: fix ineffective error tests
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>
2019-04-24 10:07:09 +02:00

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;
}
);
})();