Run tests in a native Node.js ESM environment (#13966)

This commit is contained in:
Nicolò Ribaudo
2021-12-03 15:32:58 +01:00
committed by GitHub
parent 578ab22fb7
commit 2d989a983d
159 changed files with 1283 additions and 611 deletions

View File

@@ -6,8 +6,7 @@ import { fileURLToPath } from "url";
runFixtureTestsWithoutExactASTMatch(
path.join(path.dirname(fileURLToPath(import.meta.url)), "fixtures"),
(input, options = {}) => {
options.plugins = options.plugins || [];
options.plugins.push("estree");
return parse(input, options);
const plugins = options.plugins || [];
return parse(input, { ...options, plugins: plugins.concat("estree") });
},
);

View File

@@ -218,7 +218,7 @@ function runTest(test, parseFunction, compareErrorsOnly = false) {
return save(test, ast);
}
if (ast.errors?.length) {
if (ast.errors && ast.errors.length) {
throw new Error(
`Expected non-recoverable error message: ${
opts.throws

View File

@@ -0,0 +1 @@
{ "type": "module" }