Files
test-repo/jest.config.js
T

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

87 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-07-16 21:49:37 +10:00
"use strict";
2020-04-18 01:24:22 +08:00
const path = require("path");
2021-09-09 18:53:31 +08:00
const installPrettier = require("./tests/config/install-prettier.js");
2020-04-18 01:24:22 +08:00
const PROJECT_ROOT = __dirname;
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 = [];
let transform = {};
2020-09-17 01:08:44 +09:00
if (TEST_STANDALONE) {
testPathIgnorePatterns.push("<rootDir>/tests/integration/");
}
if (isProduction) {
// `esm` bundles need transform
transform = {
"(?:\\.mjs|codeSamples\\.js)$": [
"babel-jest",
{
presets: [
[
"@babel/env",
2020-09-25 00:51:55 +08:00
{
targets: { node: "current" },
exclude: [
"transform-async-to-generator",
"transform-classes",
"proposal-async-generator-functions",
"transform-regenerator",
],
},
2020-09-17 01:08:44 +09:00
],
],
},
],
};
} else {
// Only test bundles for production
testPathIgnorePatterns.push(
"<rootDir>/tests/integration/__tests__/bundle.js"
);
}
2017-07-16 21:49:37 +10:00
module.exports = {
2020-08-28 10:02:08 +08:00
setupFiles: ["<rootDir>/tests/config/setup.js"],
snapshotSerializers: [
"jest-snapshot-serializer-raw",
"jest-snapshot-serializer-ansi",
],
snapshotFormat: {
escapeString: false,
},
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",
],
2020-09-17 01:08:44 +09:00
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
};