Turn test setup file to lazy load (#9080)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-08-28 10:02:08 +08:00
1 parent f2e3cb7f3b
commit fadd93571d
3 files changed
+12 -3

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ if (process.env.NODE_ENV === "production" || process.env.INSTALL_PACKAGE) {
const { TEST_STANDALONE } = process.env;
module.exports = {
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
setupFiles: ["<rootDir>/tests_config/setup.js"],
snapshotSerializers: [
"jest-snapshot-serializer-raw",
"jest-snapshot-serializer-ansi",
+4 -2
View File
@@ -82,7 +82,7 @@ const shouldThrowOnVerify = (filename, options) => {
const isTestDirectory = (dirname, name) =>
dirname.startsWith(path.join(__dirname, "../tests", name));
global.run_spec = (fixtures, parsers, options) => {
function runSpec(fixtures, parsers, options) {
fixtures = typeof fixtures === "string" ? { dirname: fixtures } : fixtures;
const { dirname } = fixtures;
@@ -307,7 +307,7 @@ global.run_spec = (fixtures, parsers, options) => {
}
});
}
};
}
function parse(source, options) {
return prettier.__debug.parse(source, options, /* massage */ true).ast;
@@ -356,3 +356,5 @@ function format(text, options) {
eolVisualizedOutput,
};
}
module.exports = runSpec;
+7
View File
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(global, "run_spec", {
get() {
return require("./run_spec.js");
},
});