1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
import {
compile,
getCompiler,
getErrors,
getModuleSource,
getResultFromBrowser,
getWarnings,
} from "./helpers";
describe('"esModule" option', () => {
it("should work and generate ES module syntax by default", async () => {
const compiler = getCompiler("./basic/entry.js");
const stats = await compile(compiler);
// const result = await getResultFromBrowser(stats);
expect(getModuleSource("./basic/worker.js", stats)).toMatchSnapshot(
"module"
);
// expect(result).toMatchSnapshot('result');
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with "true" value', async () => {
const compiler = getCompiler("./basic/entry.js", {
esModule: true,
});
const stats = await compile(compiler);
const result = await getResultFromBrowser(stats);
expect(getModuleSource("./basic/worker.js", stats)).toMatchSnapshot(
"module"
);
expect(result).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with "false" value', async () => {
const compiler = getCompiler("./basic/entry.js", {
esModule: false,
});
const stats = await compile(compiler);
const result = await getResultFromBrowser(stats);
expect(getModuleSource("./basic/worker.js", stats)).toMatchSnapshot(
"module"
);
expect(result).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});
|