Files
test-repo/jest.config.mjs
T

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

61 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-11-29 10:07:11 +08:00
import path from "node:path";
import createEsmUtils from "esm-utils";
import installPrettier from "./tests/config/install-prettier.mjs";
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);
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"
);
}
2021-11-29 10:07:11 +08:00
const config = {
2020-08-28 10:02:08 +08:00
setupFiles: ["<rootDir>/tests/config/setup.js"],
snapshotSerializers: [
"jest-snapshot-serializer-raw",
"jest-snapshot-serializer-ansi",
],
2017-07-16 21:49:37 +10:00
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
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/doc-debug.js",
],
2020-03-23 17:56:02 +08:00
coverageReporters: ["text", "lcov"],
moduleNameMapper: {
2020-09-18 14:05:29 +08:00
"prettier-local": "<rootDir>/tests/config/require-prettier.js",
"prettier-standalone": "<rootDir>/tests/config/require-standalone.js",
},
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;