Run tests in a native Node.js ESM environment (#13966)
This commit is contained in:
@@ -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") });
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
1
packages/babel-parser/test/package.json
Normal file
1
packages/babel-parser/test/package.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "type": "module" }
|
||||
Reference in New Issue
Block a user