Files
test-repo/jest.config.mjs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.2 KiB
JavaScript
Raw Normal View History

2021-11-29 10:07:11 +08:00
import path from "node:path";
import createEsmUtils from "esm-utils";
2022-01-04 17:00:25 +08:00
import installPrettier from "./tests/config/install-prettier.js";
2020-04-18 01:24:22 +08:00
2021-11-29 10:07:11 +08:00
const { dirname: PROJECT_ROOT } = createEsmUtils(import.meta);
2020-09-17 01:08:44 +09:00
const isProduction = process.env.NODE_ENV === "production";
2021-02-01 13:14:04 +08:00
const ENABLE_CODE_COVERAGE = Boolean(process.env.ENABLE_CODE_COVERAGE);
const TEST_STANDALONE = Boolean(process.env.TEST_STANDALONE);
const INSTALL_PACKAGE = Boolean(process.env.INSTALL_PACKAGE);
2022-04-25 14:28:27 +08:00
const SKIP_TESTS_WITH_NEW_SYNTAX = process.versions.node.startsWith("12.");
let PRETTIER_DIR = isProduction
? path.join(PROJECT_ROOT, "dist")
: PROJECT_ROOT;
if (INSTALL_PACKAGE || (isProduction && !TEST_STANDALONE)) {
PRETTIER_DIR = installPrettier(PRETTIER_DIR);
2020-04-18 01:24:22 +08:00
}
process.env.PRETTIER_DIR = PRETTIER_DIR;
2017-07-16 21:49:37 +10:00
2020-09-17 01:08:44 +09:00
const testPathIgnorePatterns = [];
if (TEST_STANDALONE) {
testPathIgnorePatterns.push("<rootDir>/tests/integration/");
}
if (!isProduction) {
2020-09-17 01:08:44 +09:00
// Only test bundles for production
testPathIgnorePatterns.push(
"<rootDir>/tests/integration/__tests__/bundle.js"
);
}
2022-04-22 20:51:41 +08:00
if (SKIP_TESTS_WITH_NEW_SYNTAX) {
testPathIgnorePatterns.push(
2022-04-27 17:34:29 +08:00
"<rootDir>/tests/integration/__tests__/help-options.js",
"<rootDir>/tests/format/misc/empty/jsfmt.spec.js"
2022-04-22 20:51:41 +08:00
);
}
2021-11-29 10:07:11 +08:00
const config = {
2022-01-12 08:47:55 +08:00
projects: [
"<rootDir>/jest-format-test.config.mjs",
2022-02-11 09:56:58 +08:00
isProduction && "<rootDir>/jest-integration-test.config.mjs",
].filter(Boolean),
snapshotSerializers: [
"jest-snapshot-serializer-raw",
"jest-snapshot-serializer-ansi",
],
snapshotFormat: {
escapeString: false,
printBasicPrototype: false,
},
2020-09-17 01:08:44 +09:00
testPathIgnorePatterns,
2018-12-18 08:16:32 +08:00
collectCoverage: ENABLE_CODE_COVERAGE,
2020-08-21 09:43:24 +08:00
collectCoverageFrom: ["<rootDir>/src/**/*.js", "<rootDir>/bin/**/*.js"],
2020-09-17 07:35:33 +08:00
coveragePathIgnorePatterns: [
"<rootDir>/src/standalone.js",
"<rootDir>/src/document/debug.js",
2020-09-17 07:35:33 +08:00
],
2020-03-23 17:56:02 +08:00
coverageReporters: ["text", "lcov"],
moduleNameMapper: {
2022-02-12 15:39:16 +08:00
"prettier-local": "<rootDir>/tests/config/prettier-entry.js",
2022-01-04 17:00:25 +08:00
"prettier-standalone": "<rootDir>/tests/config/require-standalone.cjs",
},
2021-09-07 14:53:45 +09:00
modulePathIgnorePatterns: [
"<rootDir>/dist",
"<rootDir>/website",
"<rootDir>/scripts/release",
],
transform: {},
2018-07-04 21:54:39 +02:00
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
2018-07-07 12:11:04 -04:00
],
2017-07-16 21:49:37 +10:00
};
2021-11-29 10:07:11 +08:00
export default config;