use ts for jest config, use transformIgnorePatterns, jsdom env by default

This commit is contained in:
Paul Mineev
2022-07-01 12:22:57 -05:00
committed by Umputun
parent 30d68b2d1e
commit 02f782a5ab
3 changed files with 1234 additions and 8 deletions
@@ -1,6 +1,9 @@
module.exports = {
import type { Config } from 'jest';
const config: Config = {
testEnvironment: 'jsdom',
transform: {
'^.+\\.(t|j)sx?$': [
'^.+\\.(t|j|mj)sx?$': [
'@swc/jest',
{
jsc: {
@@ -20,18 +23,13 @@ module.exports = {
},
],
},
transformIgnorePatterns: ['node_modules/(?!(@testing-library/preact|preact|@github))'],
moduleDirectories: ['node_modules', 'app'],
moduleNameMapper: {
'\\.css': 'identity-obj-proxy',
'\\.svg': '<rootDir>/app/__stubs__/svg.tsx',
'^react$': 'preact/compat',
'^react-dom$': 'preact/compat',
/**
* "transformIgnorePatterns" just don't work for modules down below
* If you know how to handle it better PR welcome
*/
'^@github/markdown-toolbar-element$': 'identity-obj-proxy',
'^@github/text-expander-element$': 'identity-obj-proxy',
},
setupFiles: ['<rootDir>/jest.setup.ts'],
setupFilesAfterEnv: [
@@ -49,3 +47,5 @@ module.exports = {
'!app/tests',
],
};
export default config;
+1224
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -92,6 +92,7 @@
"identity-obj-proxy": "^3.0.0",
"incstr": "^1.2.3",
"jest": "^28.1.2",
"jest-environment-jsdom": "^28.1.2",
"jest-fetch-mock": "^3.0.3",
"jest-localstorage-mock": "^2.4.21",
"lint-staged": "^13.0.3",
@@ -110,6 +111,7 @@
"stylelint-config-standard": "^26.0.0",
"stylelint-value-no-unknown-custom-properties": "^4.0.0",
"ts-loader": "^9.3.1",
"ts-node": "^10.8.1",
"tsconfig-paths-webpack-plugin": "^3.5.2",
"typescript": "^4.7.4",
"url-loader": "^4.1.1",