From 5538f993a03d0b7809bf1f9c523e14ccaa0f4c58 Mon Sep 17 00:00:00 2001 From: artus9033 Date: Thu, 15 Aug 2024 01:05:42 +0200 Subject: [PATCH] fix(test): move jest configuration options unallowed in project config to global --- jest.config.ts | 13 ++++++++++++- tests/__config__/commonJestConfig.ts | 5 +---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 6a19ff44e..fd4e3b142 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,12 +1,23 @@ import type { Config } from "jest"; +import { testPathIgnorePatterns } from "./tests/__config__/commonJestConfig"; + // since jest projects don't inherit from root config, we instead use tests/__config__/commonJestConfig.ts // thus, here we want just to define projects' configs; see https://github.com/jestjs/jest/issues/10991 -const config: Pick = { +const config: Pick< + Config, + | "projects" + | "coverageReporters" + | "collectCoverageFrom" + | "coveragePathIgnorePatterns" +> = { projects: [ "/tests/unit/jest.unit.config.ts", "/tests/integration/jest.integration.config.ts", ], + collectCoverageFrom: ["src/*.{js,ts,jsx,tsx}"], + coverageReporters: ["lcov", "json"], + coveragePathIgnorePatterns: testPathIgnorePatterns, }; export default config; diff --git a/tests/__config__/commonJestConfig.ts b/tests/__config__/commonJestConfig.ts index 8e773f077..655901c89 100644 --- a/tests/__config__/commonJestConfig.ts +++ b/tests/__config__/commonJestConfig.ts @@ -1,6 +1,6 @@ import { Config } from "jest"; -const testPathIgnorePatterns: string[] = [ +export const testPathIgnorePatterns: string[] = [ "__utils__", "__fixtures__", "__mocks__", @@ -29,9 +29,6 @@ const config: Config = { testEnvironmentOptions: { customExportConditions: ["node", "node-addons"], }, - collectCoverageFrom: ["src/*.{js,ts,jsx,tsx}"], - coverageReporters: ["lcov", "json"], - coveragePathIgnorePatterns: testPathIgnorePatterns, }; export default config;