diff --git a/package.json b/package.json index 198147fb..722fa84c 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "esprima": "latest", "esprima-fb": "^8001.2001.0-dev-harmony-fb", "json-diff": "^0.5.4", - "leche": "^2.3.0", "mocha": "^8.3.1", "npm-run-all": "^4.1.5", "nyc": "^14.1.1", diff --git a/tests/lib/ecma-features.js b/tests/lib/ecma-features.js index 7eac4b07..5ffeb200 100644 --- a/tests/lib/ecma-features.js +++ b/tests/lib/ecma-features.js @@ -8,7 +8,6 @@ //------------------------------------------------------------------------------ import assert from "assert"; -import leche from "leche"; import path from "path"; import * as espree from "../../espree.js"; import shelljs from "shelljs"; @@ -57,31 +56,32 @@ describe("ecmaFeatures", () => { ecmaFeatures: {} }; }); + testFiles.forEach(filename => { + describe(filename, () => { - leche.withData(testFiles, filename => { + // Uncomment and fill in filename to focus on a single file + // var filename = "jsx/invalid-matching-placeholder-in-closing-tag"; + const feature = path.dirname(filename), + isPermissive = !shouldThrowInTestsWhenEnabled(feature), + code = shelljs.cat(`${path.resolve(FIXTURES_DIR, filename)}.src.js`); - // Uncomment and fill in filename to focus on a single file - // var filename = "jsx/invalid-matching-placeholder-in-closing-tag"; - const feature = path.dirname(filename), - isPermissive = !shouldThrowInTestsWhenEnabled(feature), - code = shelljs.cat(`${path.resolve(FIXTURES_DIR, filename)}.src.js`); + it(`should parse correctly when ${feature} is ${isPermissive}`, async () => { + config.ecmaFeatures[feature] = isPermissive; - it(`should parse correctly when ${feature} is ${isPermissive}`, async () => { - config.ecmaFeatures[feature] = isPermissive; + // eslint-disable-next-line node/no-unsupported-features/es-syntax + const expected = await import(`${pathToFileURL(path.resolve(__dirname, "../../", FIXTURES_DIR, filename)).href}.result.js`); - // eslint-disable-next-line node/no-unsupported-features/es-syntax - const expected = await import(`${pathToFileURL(path.resolve(__dirname, "../../", FIXTURES_DIR, filename)).href}.result.js`); + tester.assertMatches(code, config, expected.default); + }); - tester.assertMatches(code, config, expected.default); - }); + it(`should throw an error when ${feature} is ${!isPermissive}`, () => { + config.ecmaFeatures[feature] = !isPermissive; - it(`should throw an error when ${feature} is ${!isPermissive}`, () => { - config.ecmaFeatures[feature] = !isPermissive; + assert.throws(() => { + espree.parse(code, config); + }); - assert.throws(() => { - espree.parse(code, config); }); - }); }); }); diff --git a/tests/lib/ecma-version.js b/tests/lib/ecma-version.js index 36072d51..9a264811 100644 --- a/tests/lib/ecma-version.js +++ b/tests/lib/ecma-version.js @@ -8,7 +8,6 @@ //------------------------------------------------------------------------------ import fs from "fs"; -import leche from "leche"; import path from "path"; import shelljs from "shelljs"; import tester from "./tester.js"; @@ -59,22 +58,23 @@ describe("ecmaVersion", () => { }); describe("Scripts", () => { + scriptOnlyTestFiles.forEach(filename => { + describe(filename, () => { + const version = filename.slice(1, filename.indexOf("/", 1)); - leche.withData(scriptOnlyTestFiles, filename => { - const version = filename.slice(1, filename.indexOf("/", 1)); + // Uncomment and fill in filename to focus on a single file + // var filename = "newTarget/simple-new-target"; + const code = shelljs.cat(`${FIXTURES_DIR}/${filename}.src.js`); - // Uncomment and fill in filename to focus on a single file - // var filename = "newTarget/simple-new-target"; - const code = shelljs.cat(`${FIXTURES_DIR}/${filename}.src.js`); + it("should parse correctly when sourceType is script", async () => { + config.ecmaVersion = Number(version); - it("should parse correctly when sourceType is script", async () => { - config.ecmaVersion = Number(version); - - const absolutePath = path.resolve(__dirname, FIXTURES_DIR, filename.slice(1)); - // eslint-disable-next-line node/no-unsupported-features/es-syntax - const expected = await import(`${pathToFileURL(absolutePath).href}.result.js`); + const absolutePath = path.resolve(__dirname, FIXTURES_DIR, filename.slice(1)); + // eslint-disable-next-line node/no-unsupported-features/es-syntax + const expected = await import(`${pathToFileURL(absolutePath).href}.result.js`); - tester.assertMatches(code, config, expected.default); + tester.assertMatches(code, config, expected.default); + }); }); }); @@ -83,37 +83,38 @@ describe("ecmaVersion", () => { describe("Modules", () => { + moduleTestFiles.forEach(filename => { + describe(filename, () => { + const version = filename.slice(1, filename.indexOf("/", 1)); + const code = shelljs.cat(`${FIXTURES_DIR}/${filename}.src.js`); + + it("should parse correctly when sourceType is module", async () => { + const absolutePath = path.resolve(__dirname, FIXTURES_DIR, filename.slice(1)); + + let expected; + + try { + // eslint-disable-next-line node/no-unsupported-features/es-syntax + expected = await import(`${pathToFileURL(absolutePath).href}.module-result.js`); + } catch { + // eslint-disable-next-line node/no-unsupported-features/es-syntax + expected = await import(`${pathToFileURL(absolutePath).href}.result.js`); + } - leche.withData(moduleTestFiles, filename => { - const version = filename.slice(1, filename.indexOf("/", 1)); - const code = shelljs.cat(`${FIXTURES_DIR}/${filename}.src.js`); - - it("should parse correctly when sourceType is module", async () => { - const absolutePath = path.resolve(__dirname, FIXTURES_DIR, filename.slice(1)); - - let expected; - - try { - // eslint-disable-next-line node/no-unsupported-features/es-syntax - expected = await import(`${pathToFileURL(absolutePath).href}.module-result.js`); - } catch { - // eslint-disable-next-line node/no-unsupported-features/es-syntax - expected = await import(`${pathToFileURL(absolutePath).href}.result.js`); - } - - if (expected) { - expected = expected.default; - } + if (expected) { + expected = expected.default; + } - config.ecmaVersion = Number(version); - config.sourceType = "module"; + config.ecmaVersion = Number(version); + config.sourceType = "module"; - // set sourceType of program node to module - if (expected.type === "Program") { - expected.sourceType = "module"; - } + // set sourceType of program node to module + if (expected.type === "Program") { + expected.sourceType = "module"; + } - tester.assertMatches(code, config, expected); + tester.assertMatches(code, config, expected); + }); }); }); diff --git a/tests/lib/libraries.js b/tests/lib/libraries.js index 2167eec2..b69105fb 100644 --- a/tests/lib/libraries.js +++ b/tests/lib/libraries.js @@ -7,7 +7,6 @@ // Requirements //------------------------------------------------------------------------------ -import leche from "leche"; import path from "path"; import shelljs from "shelljs"; import tester from "./tester.js"; @@ -30,24 +29,24 @@ const testFiles = shelljs.find(`${__dirname}/../fixtures/libraries`).filter(file //------------------------------------------------------------------------------ describe("Libraries", () => { + testFiles.forEach(filename => { + describe(filename, () => { - leche.withData(testFiles, filename => { + // var filename = "angular-1.2.5.js"; - // var filename = "angular-1.2.5.js"; + it("should produce correct AST when parsed", () => { + const output = shelljs.cat(`${filename}.result.json`); + const input = shelljs.cat(filename); - it("should produce correct AST when parsed", () => { - const output = shelljs.cat(`${filename}.result.json`); - const input = shelljs.cat(filename); + const result = JSON.stringify(tester.getRaw(espree.parse(input, { + loc: true, + range: true, + tokens: true + }))); - const result = JSON.stringify(tester.getRaw(espree.parse(input, { - loc: true, - range: true, - tokens: true - }))); - - assert.strictEqual(result, output); + assert.strictEqual(result, output); + }); }); - }); - + }); });