Convert Jest configuration to TypeScript (#561)

This commit is contained in:
Jon Koops 2021-04-30 14:26:06 +02:00 committed by GitHub
parent c6122eea93
commit 8fa10a5919
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 760 additions and 533 deletions

View file

@ -1,8 +0,0 @@
module.exports = {
...require("@snowpack/app-scripts-react/jest.config.js")(),
"snapshotSerializers": ["enzyme-to-json/serializer"],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/src/__mocks__/styleMock.js"
}
};

16
jest.config.ts Normal file
View file

@ -0,0 +1,16 @@
// See: https://github.com/snowpackjs/snowpack/issues/3242
// @ts-ignore
import snowpackConfig from "@snowpack/app-scripts-react/jest.config.js";
import { Config } from "@jest/types";
const config: Config.InitialOptions = {
...snowpackConfig(),
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
snapshotSerializers: ["enzyme-to-json/serializer"],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/src/__mocks__/styleMock.js"
}
};
export default config;

View file

@ -26,4 +26,5 @@ import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
// eslint-disable-next-line no-undef
// @ts-ignore
global.MutationObserver = window.MutationObserver;

View file

@ -41,6 +41,7 @@
"devDependencies": {
"@babel/core": "^7.10.5",
"@babel/preset-typescript": "^7.10.4",
"@jest/types": "^26.6.2",
"@snowpack/app-scripts-react": "^1.10.0",
"@snowpack/plugin-postcss": "1.0.4",
"@snowpack/plugin-webpack": "2.0.12",
@ -57,6 +58,7 @@
"@testing-library/react": "^10.4.6",
"@types/dot": "^1.1.4",
"@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/file-saver": "^2.0.1",
"@types/jest": "^26.0.4",
"@types/lodash": "^4.14.165",
@ -77,7 +79,7 @@
"eslint-plugin-react": "^7.20.5",
"grunt": "^1.2.1",
"grunt-contrib-copy": "^1.0.0",
"jest": "^25.4.0",
"jest": "^26.6.3",
"mutationobserver-shim": "^0.3.7",
"postcss": "^7.0.32",
"postcss-cli": "^7.1.1",
@ -86,6 +88,7 @@
"react-is": "^16.13.1",
"react-scripts": "^3.4.1",
"snowpack": "2.11.1",
"ts-node": "^9.1.1",
"typescript": "^3.8.3"
}
}

1263
yarn.lock

File diff suppressed because it is too large Load diff