mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-06 21:11:41 -07:00
test: setup automated tests with jest
This commit is contained in:
parent
8785b94392
commit
23be268630
4 changed files with 745 additions and 15 deletions
32
frontend/jest.config.js
Normal file
32
frontend/jest.config.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// Add any custom config to be passed to Jest
|
||||||
|
const customJestConfig = {
|
||||||
|
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
|
||||||
|
moduleDirectories: ["node_modules", "<rootDir>/"],
|
||||||
|
transform: {
|
||||||
|
// Use babel-jest to transpile tests with the below presets
|
||||||
|
// https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object
|
||||||
|
"^.+\\.(js|jsx|ts|tsx)$": [
|
||||||
|
"babel-jest",
|
||||||
|
{
|
||||||
|
presets: [
|
||||||
|
"@babel/preset-env",
|
||||||
|
[
|
||||||
|
"@babel/preset-react",
|
||||||
|
{
|
||||||
|
runtime: "automatic",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
testEnvironment: "jest-environment-jsdom",
|
||||||
|
moduleNameMapper: {
|
||||||
|
"^uuid$": require.resolve("uuid"),
|
||||||
|
"^@fontsource/roboto$": "identity-obj-proxy",
|
||||||
|
"\\.(png)$": "identity-obj-proxy",
|
||||||
|
},
|
||||||
|
testPathIgnorePatterns: ["<rootDir>/cypress/"],
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = customJestConfig;
|
6
frontend/jest.setup.js
Normal file
6
frontend/jest.setup.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// Optional: configure or set up a testing framework before each test.
|
||||||
|
// If you delete this file, remove `setupFilesAfterEnv` from `jest.config.js`
|
||||||
|
|
||||||
|
// Used for __tests__/testing-library.js
|
||||||
|
// Learn more: https://github.com/testing-library/jest-dom
|
||||||
|
import "@testing-library/jest-dom/extend-expect";
|
|
@ -23,12 +23,17 @@
|
||||||
"styled-components": "^5.3.5"
|
"styled-components": "^5.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
|
"@testing-library/react": "12.1.5",
|
||||||
|
"axios-mock-adapter": "^1.21.2",
|
||||||
|
"jest-transform-css": "^6.0.0",
|
||||||
"source-map-explorer": "^2.5.2"
|
"source-map-explorer": "^2.5.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "BROWSER=none react-scripts start",
|
"start": "BROWSER=none react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"analyze": "source-map-explorer 'build/static/js/*.js'"
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||||
|
"test:unit": "npx jest --coverage --testPathPattern='unit'"
|
||||||
},
|
},
|
||||||
"homepage": "/app",
|
"homepage": "/app",
|
||||||
"proxy": "http://127.0.0.1:4000",
|
"proxy": "http://127.0.0.1:4000",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue