Skip to content

Commit 125a4f7

Browse files
committed
breaking: Extend jest config from @patternslib/dev.
1 parent aea3681 commit 125a4f7

File tree

5 files changed

+21
-136
lines changed

5 files changed

+21
-136
lines changed

jest.config.js

+3-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
const path = require("path");
2+
const config = require("@patternslib/dev/jest.config.js");
23

3-
// Set the default roots to "./src", which would work in most projects following
4-
// Patternslib conventions which extend this jest.config.js.
5-
const roots = ["./src"];
4+
config.setupFilesAfterEnv.push(path.resolve(__dirname, "./src/setup-tests.js"));
65

7-
// When testing in Patternslib, also add "./webpack" to roots.
8-
if (process.env.TEST_ENV === "patternslib") {
9-
roots.push("./webpack");
10-
}
11-
12-
module.exports = {
13-
roots: roots,
14-
setupFilesAfterEnv: [path.resolve(__dirname, "./src/setupTests.js")],
15-
watchPlugins: ["jest-watch-typeahead/filename", "jest-watch-typeahead/testname"],
16-
transform: {
17-
"^.+\\.[t|j]sx?$": "babel-jest",
18-
"\\.(html|xml|svg)$": path.resolve(__dirname, "./webpack/jest-raw-loader.js"),
19-
},
20-
moduleNameMapper: {
21-
"\\.(css|less|sass|scss)$": "identity-obj-proxy",
22-
},
23-
testEnvironment: "jsdom",
24-
transformIgnorePatterns: [
25-
"/node_modules/(?!patternslib/)(?!preact/)(?!screenfull/).+\\.[t|j]sx?$",
26-
],
27-
};
6+
module.exports = config;

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"build": "NODE_ENV=production webpack --config webpack/webpack.dist.js",
4949
"build:dev": "NODE_ENV=development webpack --config webpack/webpack.dist.js",
5050
"build:stats": "NODE_ENV=production webpack --config webpack/webpack.dist.js --json > stats.json",
51-
"test": "TEST_ENV=patternslib jest --watch",
52-
"testonce": "TEST_ENV=patternslib jest"
51+
"test": "jest --watch",
52+
"testonce": "jest"
5353
},
5454
"engines": {
5555
"node": ">=12.20.0"

src/setup-tests.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Extra test setup.
2+
3+
import jquery from "jquery";
4+
global.$ = global.jQuery = jquery;
5+
6+
// Do not output error messages
7+
import logging from "./core/logging";
8+
logging.setLevel(50);
9+
// level: FATAL
10+
11+
// patch dom.is_visible to not rely on jest-unavailable offsetWidth/Height but
12+
// simply on el.hidden.
13+
import dom from "./core/dom";
14+
dom.is_visible = (el) => {
15+
return !el.hidden;
16+
};

src/setupTests.js

-101
This file was deleted.

webpack/jest-raw-loader.js

-9
This file was deleted.

0 commit comments

Comments
 (0)