Skip to content

Commit

Permalink
fix: filter irrelevant options from jest configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
vCaisim committed Jul 24, 2024
1 parent a8d3686 commit 77c1aac
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 12 deletions.
2 changes: 0 additions & 2 deletions packages/cmd/src/discovery/jest/args/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { omit } from "lodash";
const ignoredOptions = [
"bail", // causes unexpected behaviour
"clearCache",
"clearMocks",
"collectCoverage",
"collectCoverageFrom",
"color",
Expand All @@ -29,7 +28,6 @@ const ignoredOptions = [
"notifyMode",
"openHandlesTimeout",
"outputFile",
"prettierPath",
"reporters",
"runner",
"shard",
Expand Down
68 changes: 58 additions & 10 deletions packages/cmd/src/discovery/jest/args/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,77 @@ export async function getConfigFilePath(
explicitConfigFilePath
);

const parsedConfigObject = omit(initialConfig, [
const configOptionsToAvoid = [
// from docs: https://jestjs.io/docs/configuration
"collectCoverage",
"collectCoverageFrom",
"coverageDirectory",
"coveragePathIgnorePatterns",
"coverageProvider",
"coverageReporters",
"coverageThreshold",
"errorOnDeprecated",
"forceCoverageMatch",
"notify",
"notifyMode",
"openHandlesTimeout",
"reporters",
"runner",
"showSeed",
"testFailureExitCode",
"verbose",
"watchPathIgnorePatterns",
"watchPlugins",
"watchman",

// from Config type
"bail", // causes unexpected behaviour
"clearCache",
"color",
"colors",
"debug",
"detectLeaks",
"detectOpenHandles",
"reporters",
"logHeapUsage",
"expand",
"forceExit",
"json",
"listTests",
"notify",
"notifyMode",
"logHeapUsage",
"noStackTrace",
"outputFile",
"shard",
"showConfig",
"silent",
"verbose",
"testNamePattern",
"waitNextEventLoopTurnForUnhandledRejectionEvents",
"watch",
"watchAll",
"watchman",
"watchPlugins",
"shard",
]);
];

// from InitialProjectOptions type
const projectConfigOptionsToAvoid = [
"collectCoverageFrom",
"coverageDirectory",
"coveragePathIgnorePatterns",
"detectLeaks",
"detectOpenHandles",
"errorOnDeprecated",
"forceCoverageMatch",
"openHandlesTimeout",
"runner",
"watchPathIgnorePatterns",
];

const parsedConfigObject = omit(initialConfig, configOptionsToAvoid);

if (parsedConfigObject.projects) {
parsedConfigObject.projects = parsedConfigObject.projects.map(
(project) =>
typeof project !== "string"
? omit(project, projectConfigOptionsToAvoid)
: project
);
}

if (
parsedConfigObject.rootDir &&
Expand Down

0 comments on commit 77c1aac

Please sign in to comment.