chore: use jest for testing instead of react-scripts

This commit is contained in:
Saleel
2023-05-27 13:54:00 +05:30
parent 18c5d10391
commit 37dcd223be
5 changed files with 3781 additions and 80 deletions

View File

@@ -1,5 +1,8 @@
import fs from 'fs';
import path from 'path';
const getUncompressedTestFile = (): ArrayBuffer => {
const buffer = fs.readFileSync(`${__dirname}/../__fixtures__/compressed-files/uncompressed-value.txt`);
const buffer = fs.readFileSync(path.join(__dirname, `../src/__fixtures__/compressed-files/uncompressed-value.txt`));
return buffer;
}

7
babel.config.js Normal file
View File

@@ -0,0 +1,7 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
'@babel/preset-react'
],
};

View File

@@ -63,12 +63,11 @@
"serve": "vite preview",
"both-build": "react-scripts build && next build",
"next-build": "next build",
"test": "react-scripts test --runInBand --testPathIgnorePatterns='e2e|src/contracts/lib' --reporters=default --reporters=jest-junit",
"test": "jest --runInBand --testPathIgnorePatterns='e2e|src/contracts/lib' --reporters=default --reporters=jest-junit",
"test:browserstack": "browserstack-node-sdk jest src/ --runInBand --testPathIgnorePatterns='e2e|src/contracts/lib' --reporters=default --reporters=jest-junit",
"start-e2e-test-server": "serve -s build -p 3000",
"test:e2e-ui": "CI=true react-scripts test --runInBand --testPathPattern='e2e-ui' --reporters=default --reporters=jest-junit",
"test:e2e-zkp": "CI=true react-scripts test --runInBand --testPathPattern='e2e-dl-zkp' --reporters=default --reporters=jest-junit",
"eject": "react-scripts eject",
"test:e2e-ui": "CI=true jest test --runInBand --testPathPattern='e2e-ui' --reporters=default --reporters=jest-junit",
"test:e2e-zkp": "CI=true jest test --runInBand --testPathPattern='e2e-dl-zkp' --reporters=default --reporters=jest-junit",
"compile": "node circuits/scripts/compile.js",
"gen-input": "npx tsx src/scripts/generate_input.ts",
"compile-all": "yarn gen-input && yarn compile email true",
@@ -95,6 +94,9 @@
]
},
"devDependencies": {
"@babel/preset-env": "^7.22.2",
"@babel/preset-react": "^7.22.0",
"@babel/preset-typescript": "^7.21.5",
"@types/atob": "^2.1.2",
"@types/jest": "^29.4.0",
"@types/node": "^18.0.6",
@@ -102,6 +104,8 @@
"browserstack-local": "^1.5.1",
"browserstack-node-sdk": "^1.6.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "^15.0.0",
"madge": "^6.0.0",
"msw": "^1.0.1",
@@ -110,13 +114,13 @@
"selenium-webdriver": "^4.8.1",
"ts-node-dev": "^2.0.0",
"vite-plugin-commonjs": "^0.7.0",
"vite-plugin-ngmi-polyfill": "^0.0.2",
"vite-preset-react": "^2.3.0"
"vite-plugin-ngmi-polyfill": "^0.0.2"
},
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!@rainbow-me/rainbowkit)"
]
],
"testEnvironment": "jsdom"
},
"packageManager": "yarn@3.2.3"
}

View File

@@ -1,17 +1,27 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';
import commonjs from 'vite-plugin-commonjs';
import { NgmiPolyfill } from 'vite-plugin-ngmi-polyfill';
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import viteTsconfigPaths from "vite-tsconfig-paths";
import svgrPlugin from "vite-plugin-svgr";
import commonjs from "vite-plugin-commonjs";
import { NgmiPolyfill } from "vite-plugin-ngmi-polyfill";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
viteTsconfigPaths(),
svgrPlugin(),
commonjs(),
NgmiPolyfill(),
],
plugins: [
react(),
viteTsconfigPaths(),
svgrPlugin(),
commonjs(),
NgmiPolyfill(),
],
server: {
port: 3000,
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/setupTests.js',
include: "src/**/*.test.*",
exclude: "src/contracts/**/*.test.*|src/e2e**.test.*",
},
});

3795
yarn.lock

File diff suppressed because it is too large Load Diff