add test ci script

This commit is contained in:
Pritimay Sarkar
2024-01-21 11:38:34 +05:30
parent d327fecf8c
commit b69791c246
8 changed files with 10336 additions and 3226 deletions

18
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,18 @@
stages:
- test
unit-test:
image: node:latest
stage: test
before_script:
- npm install
script:
- npm run test-ci
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
artifacts:
paths:
- coverage/
when: always
reports:
junit:
- junit.xml

1
__mocks__/styleMock.js Normal file
View File

@@ -0,0 +1 @@
module.exports = {};

1
__mocks__/svgMock.js Normal file
View File

@@ -0,0 +1 @@
module.exports = 'test-file-stub';

4
babel.config.json Normal file
View File

@@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"]
}

19
jest.config.js Normal file
View File

@@ -0,0 +1,19 @@
module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
transform: {
"^.+\\.jsx?$": "babel-jest",
'^.+\\.mjs': 'babel-jest',
},
transformIgnorePatterns: [
'/node_modules/',
'node_modules/(?!(d3|other-module-to-transform)/)',
'\\.css$',
],
moduleNameMapper: {
'\\.(svg)$': '<rootDir>/__mocks__/svgMock.js',
'\\.(css|less|sass|scss)$': '<rootDir>/__mocks__/styleMock.js',
'^d3$': '<rootDir>/node_modules/d3/src/index.js',
},
};

13507
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,7 +37,8 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"deploy": "npm run build && firebase deploy",
"coverage": "react-scripts test --coverage"
"coverage": "react-scripts test --coverage",
"test-ci": "jest --testPathIgnorePatterns=src/tests/ --passWithNoTests --ci --bail"
},
"eslintConfig": {
"extends": [
@@ -58,7 +59,13 @@
]
},
"devDependencies": {
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"csv-parser": "^3.0.0",
"html-pdf-node": "^1.0.8"
"html-pdf-node": "^1.0.8",
"jest-environment-jsdom": "^29.7.0",
"ts-jest": "^29.1.1"
}
}

View File

@@ -3,3 +3,4 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
// import '@testing-library/jest-dom/extend-expect';