Skip to content

Commit

Permalink
Fix windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Oct 28, 2020
1 parent c49a7a2 commit 444b0c9
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions packages/babel-core/test/async.js
@@ -1,4 +1,4 @@
import path from "path";
import { join } from "path";
import * as babel from "..";

const nodeGte8 = (...args) => {
Expand All @@ -8,7 +8,7 @@ const nodeGte8 = (...args) => {
};

describe("asynchronicity", () => {
const base = path.join(__dirname, "fixtures", "async");
const base = join(__dirname, "fixtures", "async");
let cwd;

beforeEach(function () {
Expand Down Expand Up @@ -106,14 +106,17 @@ describe("asynchronicity", () => {
});
});

const path = (...parts) => join(base, ...parts).replace(/\\/g, "\\\\");

describe("plugin", () => {
describe("factory function", () => {
nodeGte8("called synchronously", () => {
process.chdir("plugin");

expect(() => babel.transformSync("")).toThrow(
`[BABEL] unknown: You appear to be using an async plugin/preset, but Babel has been` +
` called synchronously (While processing: "${__dirname}/fixtures/async/plugin/plugin.js")`,
`[BABEL] unknown: You appear to be using an async plugin/preset, but Babel` +
` has been called synchronously (While processing: ` +
`"${path("plugin", "plugin.js")}")`,
);
});

Expand Down Expand Up @@ -185,7 +188,7 @@ describe("asynchronicity", () => {
expect(() => babel.transformSync("")).toThrow(
`[BABEL] unknown: You appear to be using an async plugin/preset, but Babel has been` +
` called synchronously (While processing: ` +
`"${__dirname}/fixtures/async/plugin-inherits/plugin.js$inherits")`,
`"${path("plugin-inherits", "plugin.js")}$inherits")`,
);
});

Expand All @@ -208,7 +211,7 @@ describe("asynchronicity", () => {
expect(() => babel.transformSync("")).toThrow(
`[BABEL]: You appear to be using a native ECMAScript module plugin, which is` +
` only supported when running Babel asynchronously. (While processing: ` +
`${__dirname}/fixtures/async/plugin-mjs/plugin.mjs)`,
`${path("plugin-mjs", "plugin.mjs")})`,
);
});

Expand All @@ -229,8 +232,9 @@ describe("asynchronicity", () => {
process.chdir("preset");

expect(() => babel.transformSync("")).toThrow(
`[BABEL] unknown: You appear to be using an async plugin/preset, but Babel has been` +
` called synchronously (While processing: "${__dirname}/fixtures/async/preset/preset.js")`,
`[BABEL] unknown: You appear to be using an async plugin/preset, ` +
`but Babel has been called synchronously ` +
`(While processing: "${path("preset", "preset.js")}")`,
);
});

Expand All @@ -248,21 +252,23 @@ describe("asynchronicity", () => {
process.chdir("preset-plugin-promise");

expect(() => babel.transformSync("")).toThrow(
`[BABEL] unknown: You appear to be using a promise as a plugin, which your current version` +
` of Babel does not support. If you're using a published plugin, you may need to upgrade` +
` your @babel/core version. As an alternative, you can prefix the promise with "await". ` +
`(While processing: "${__dirname}/fixtures/async/preset-plugin-promise/preset.js$0")`,
`[BABEL] unknown: You appear to be using a promise as a plugin, which your` +
` current version of Babel does not support. If you're using a published` +
` plugin, you may need to upgrade your @babel/core version. As an` +
` alternative, you can prefix the promise with "await". (While processing:` +
` "${path("preset-plugin-promise", "preset.js")}$0")`,
);
});

nodeGte8("called asynchronously", async () => {
process.chdir("preset-plugin-promise");

await expect(babel.transformAsync("")).rejects.toThrow(
`[BABEL] unknown: You appear to be using a promise as a plugin, which your current version` +
` of Babel does not support. If you're using a published plugin, you may need to upgrade` +
` your @babel/core version. As an alternative, you can prefix the promise with "await". ` +
`(While processing: "${__dirname}/fixtures/async/preset-plugin-promise/preset.js$0")`,
`[BABEL] unknown: You appear to be using a promise as a plugin, which your` +
` current version of Babel does not support. If you're using a published` +
` plugin, you may need to upgrade your @babel/core version. As an` +
` alternative, you can prefix the promise with "await". (While processing:` +
` "${path("preset-plugin-promise", "preset.js")}$0")`,
);
});
});
Expand All @@ -277,7 +283,7 @@ describe("asynchronicity", () => {
expect(() => babel.transformSync("")).toThrow(
`[BABEL]: You appear to be using a native ECMAScript module preset, which is` +
` only supported when running Babel asynchronously. (While processing: ` +
`${__dirname}/fixtures/async/preset-mjs/preset.mjs)`,
`${path("preset-mjs", "preset.mjs")})`,
);
});

Expand All @@ -292,10 +298,8 @@ describe("asynchronicity", () => {
nodeGte8("must use the 'default' export", async () => {
process.chdir("preset-mjs-named-exports");

await expect(
babel.transformAsync(""),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Unexpected falsy value: undefined"`,
await expect(babel.transformAsync("")).rejects.toThrow(
`Unexpected falsy value: undefined`,
);
});
}
Expand Down

0 comments on commit 444b0c9

Please sign in to comment.