Refactor integration test files to use ES Module (#11891)
This commit is contained in:
1 parent
0d6d47b30a
commit
8ffbcbbcae
70 files changed
+197
-282
No files matched your search
@@ -1,31 +1,39 @@
|
||||
"use strict";
|
||||
import path from "node:path";
|
||||
import globby from "globby";
|
||||
import createEsmUtils from "esm-utils";
|
||||
import { projectRoot } from "../env.js";
|
||||
import coreOptions from "../../../src/main/core-options.js";
|
||||
import codeSamples from "../../../website/playground/codeSamples.mjs";
|
||||
import jestPathSerializer from "../path-serializer.js";
|
||||
|
||||
const path = require("path");
|
||||
const globby = require("globby");
|
||||
const { projectRoot } = require("../env.js");
|
||||
const coreOptions = require("../../../src/main/core-options.js");
|
||||
const codeSamples =
|
||||
require("../../../website/playground/codeSamples.js").default;
|
||||
const { require } = createEsmUtils(import.meta);
|
||||
|
||||
expect.addSnapshotSerializer(jestPathSerializer);
|
||||
|
||||
const parserNames = coreOptions.options.parser.choices.map(
|
||||
({ value }) => value
|
||||
);
|
||||
const distDirectory = path.join(projectRoot, "dist");
|
||||
|
||||
let esmStandalone;
|
||||
let esmPlugins;
|
||||
beforeAll(async () => {
|
||||
({ default: esmStandalone } = await import(
|
||||
path.join(distDirectory, "esm/standalone.mjs")
|
||||
));
|
||||
esmPlugins = await Promise.all(
|
||||
globby
|
||||
.sync(["esm/parser-*.mjs"], { cwd: distDirectory, absolute: true })
|
||||
.map(async (file) => (await import(file)).default)
|
||||
);
|
||||
});
|
||||
|
||||
describe("standalone", () => {
|
||||
const standalone = require(path.join(distDirectory, "standalone.js"));
|
||||
const plugins = globby
|
||||
.sync(["parser-*.js"], { cwd: distDirectory, absolute: true })
|
||||
.map((file) => require(file));
|
||||
|
||||
const esmStandalone = require(path.join(
|
||||
distDirectory,
|
||||
"esm/standalone.mjs"
|
||||
)).default;
|
||||
const esmPlugins = globby
|
||||
.sync(["esm/parser-*.mjs"], { cwd: distDirectory, absolute: true })
|
||||
.map((file) => require(file).default);
|
||||
|
||||
for (const parser of parserNames) {
|
||||
test(parser, () => {
|
||||
const input = codeSamples(parser);
|
||||
|
||||
Reference in new issue
Block a user