Skip to content

Commit

Permalink
fix: πŸ› e2e config should override jest config (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-guzman authored Nov 23, 2024
1 parent 168ecbb commit 7ddd744
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
10 changes: 8 additions & 2 deletions src/configs/testing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { testingConfig } from "./testing";

describe("testingConfig", () => {
it("should create default config w/ vitest overrides", async () => {
const [, vitest] = await testingConfig({}, false);
const [vitest] = await testingConfig({}, false);

expect(vitest?.rules).toStrictEqual(
expect.objectContaining({
Expand All @@ -19,7 +19,7 @@ describe("testingConfig", () => {
});

it("should create default config w/o vitest overrides", async () => {
const [, jest] = await testingConfig({ framework: "jest" }, false);
const [jest] = await testingConfig({ framework: "jest" }, false);

expect(jest?.rules).toStrictEqual(
expect.not.objectContaining({
Expand All @@ -33,4 +33,10 @@ describe("testingConfig", () => {
}),
);
});

it("should create e2e config last", async () => {
const configs = await testingConfig({ framework: "jest" }, false);

expect(configs.at(-1)?.name).toBe("jimmy.codes/e2e");
});
});
22 changes: 11 additions & 11 deletions src/configs/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,7 @@ export const testingConfig = async (
const isVitest = autoDetect ? hasVitest() : framework === "vitest";
const isJest = framework === "jest" || (autoDetect && hasJest());

const configs: TypedConfigItem[] = [
{
files: GLOB_E2E,
name: "jimmy.codes/e2e",
rules: {
"jest/expect-expect": "off",
"jest/no-deprecated-functions": "off",
"jest/require-hook": "off",
} satisfies Rules,
},
];
const configs: TypedConfigItem[] = [];

if (isVitest) {
const jestPlugin = await interopDefault(import("eslint-plugin-jest"));
Expand All @@ -47,5 +37,15 @@ export const testingConfig = async (
});
}

configs.push({
files: GLOB_E2E,
name: "jimmy.codes/e2e",
rules: {
"jest/expect-expect": "off",
"jest/no-deprecated-functions": "off",
"jest/require-hook": "off",
} satisfies Rules,
});

return configs;
};

0 comments on commit 7ddd744

Please sign in to comment.