Skip to content

Commit

Permalink
Use file extension to signal skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 24, 2021
1 parent c9123d3 commit 63f5f79
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 67 deletions.
4 changes: 4 additions & 0 deletions jest.config.js
@@ -1,4 +1,5 @@
const supportsESM = parseInt(process.versions.node) >= 12;
const isPublishBundle = process.env.IS_PUBLISH;

module.exports = {
collectCoverageFrom: [
Expand All @@ -23,6 +24,9 @@ module.exports = {
"<rootDir>/build/",
"<rootDir>/.history/", // local directory for VSCode Extension - https://marketplace.visualstudio.com/items?itemName=xyz.local-history
"_browser\\.js",
// Some tests require internal files of bundled packages, which are not available
// in production builds. They are marked using the .skip-bundled.js extension.
...(isPublishBundle ? ["\\.skip-bundled\\.js$"] : []),
],
testEnvironment: "node",
setupFilesAfterEnv: ["<rootDir>/test/testSetupFile.js"],
Expand Down
@@ -1,13 +1,6 @@
const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("token types", () => {
let tt, tokenOperatorPrecedence;
beforeAll(async () => {
({ tt, tokenOperatorPrecedence } = await import(
"../../../lib/tokenizer/types.js"
));
});
import { tt, tokenOperatorPrecedence } from "../../../lib/tokenizer/types.js";

describe("token types", () => {
it("should check if the binOp for relational === in", () => {
expect(tokenOperatorPrecedence(tt.relational)).toEqual(
tokenOperatorPrecedence(tt._in),
Expand Down
@@ -1,13 +1,9 @@
const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("identifier", () => {
let isKeyword, keywordRelationalOperator;
beforeAll(async () => {
({ isKeyword, keywordRelationalOperator } = await import(
"../../../lib/util/identifier.js"
));
});
import {
isKeyword,
keywordRelationalOperator,
} from "../../../lib/util/identifier.js";

describe("identifier", () => {
describe("isKeyword", () => {
it("break is a keyword", () => {
expect(isKeyword("break")).toBe(true);
Expand Down
@@ -1,11 +1,6 @@
const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("getLineInfo", () => {
let getLineInfo;
beforeAll(async () => {
({ getLineInfo } = await import("../../../lib/util/location.js"));
});
import { getLineInfo } from "../../../lib/util/location.js";

describe("getLineInfo", () => {
const input = "a\nb\nc\nd\ne\nf\ng\nh\ni";

it("reports correct position", () => {
Expand Down
@@ -1,4 +1,5 @@
import { parseSync, traverse } from "@babel/core";
import { shouldTransform } from "../lib/util.ts";

function getPath(input, parserOpts = {}) {
let targetPath;
Expand All @@ -18,14 +19,7 @@ function getPath(input, parserOpts = {}) {
return targetPath;
}

const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("shouldTransform", () => {
let shouldTransform;
beforeAll(async () => {
({ shouldTransform } = await import("../lib/util.js"));
});

describe("shouldTransform", () => {
const positiveCases = [
"(function a([a]) {})",
"({ b: function a([a]) {} })",
Expand Down
@@ -1,4 +1,5 @@
import { parseSync, traverse } from "@babel/core";
import { shouldTransform } from "../lib/util.ts";

function getPath(input, parserOpts = {}) {
let targetPath;
Expand All @@ -19,14 +20,7 @@ function getPath(input, parserOpts = {}) {
return targetPath;
}

const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("shouldTransform", () => {
let shouldTransform;
beforeAll(async () => {
({ shouldTransform } = await import("../lib/util.js"));
});

describe("shouldTransform", () => {
const positiveCases = [
"fn?.(...[], 0)",
"fn?.(...[], ...[])",
Expand Down
@@ -1,3 +1,4 @@
import { willPathCastToBoolean } from "../lib/util.js";
import { parseSync, traverse } from "@babel/core";

function getPath(input, parserOpts) {
Expand All @@ -12,14 +13,7 @@ function getPath(input, parserOpts) {
return targetPath;
}

const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("willPathCastToBoolean", () => {
let willPathCastToBoolean;
beforeAll(async () => {
({ willPathCastToBoolean } = await import("../lib/util.js"));
});

describe("willPathCastToBoolean", () => {
const positiveCases = [
"if(a?.b) {}",
"while(a?.b) {}",
Expand Down
@@ -1,13 +1,6 @@
const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("normalize options", () => {
let normalizeOptions;
beforeAll(async () => {
({ default: normalizeOptions } = await import(
"../lib/normalize-options.js"
));
});
import normalizeOptions from "../lib/normalize-options.js";

describe("normalize options", () => {
(process.env.BABEL_8_BREAKING ? describe : describe.skip)("Babel 8", () => {
it("should throw on unknown options", () => {
expect(() => normalizeOptions({ throwIfNamespaces: true })).toThrowError(
Expand Down
@@ -1,13 +1,6 @@
const describeSkipPublish = process.env.IS_PUBLISH ? describe.skip : describe;

describeSkipPublish("normalize options", () => {
let normalizeOptions;
beforeAll(async () => {
({ default: normalizeOptions } = await import(
"../lib/normalize-options.js"
));
});
import normalizeOptions from "../lib/normalize-options.js";

describe("normalize options", () => {
(process.env.BABEL_8_BREAKING ? describe : describe.skip)("Babel 8", () => {
it("should throw on unknown options", () => {
expect(() => normalizeOptions({ allowNamespace: true })).toThrowError(
Expand Down

0 comments on commit 63f5f79

Please sign in to comment.