Skip to content

Commit aab91cc

Browse files
committed
Migrate jest tests
1 parent f506c96 commit aab91cc

File tree

10 files changed

+2231
-36
lines changed

10 files changed

+2231
-36
lines changed

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
extends: ['plugin:@api3/eslint-plugin-commons/universal'],
2+
extends: ['plugin:@api3/eslint-plugin-commons/universal', 'plugin:@api3/eslint-plugin-commons/jest'],
33
parserOptions: {
44
project: ['./tsconfig.json'],
55
},
@@ -9,8 +9,11 @@ module.exports = {
99

1010
'functional/no-try-statements': 'off',
1111

12+
'jest/no-conditional-in-test': 'off',
13+
1214
'lodash/prefer-constant': 'off',
1315
'lodash/prefer-lodash-typecheck': 'off',
16+
'lodash/prefer-noop': 'off',
1417

1518
'unicorn/filename-case': 'off',
1619
'unicorn/no-anonymous-default-export': 'off',

jest.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property and type check, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
module.exports = {
6+
collectCoverage: true,
7+
coverageDirectory: 'coverage',
8+
coverageProvider: 'v8',
9+
modulePathIgnorePatterns: ['<rootDir>/.build', '<rootDir>/dist/', '<rootDir>/build/'],
10+
preset: 'ts-jest',
11+
restoreMocks: true,
12+
testEnvironment: 'jest-environment-node',
13+
};

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@
5252
"prettier": "prettier --write \"./**/*.{js,ts,md,json,sol}\"",
5353
"postpack": "./postpack.sh",
5454
"survey-roles": "hardhat run scripts/survey-roles.ts",
55-
"test": "hardhat test --parallel",
56-
"test:coverage": "hardhat coverage",
57-
"test:extended": "EXTENDED_TEST=TRUE hardhat test --parallel",
58-
"test:gas": "REPORT_GAS=TRUE hardhat test",
55+
"test": "pnpm test:hardhat && pnpm test:jest",
56+
"test:harhat": "hardhat test --parallel",
57+
"test:hardhat:coverage": "hardhat coverage",
58+
"test:hardhat:extended": "EXTENDED_TEST=TRUE hardhat test --parallel",
59+
"test:hardhat:gas": "REPORT_GAS=TRUE hardhat test",
60+
"test:jest": "jest",
5961
"validate-deployments": "hardhat run scripts/validate-deployments.ts",
6062
"verify-deployments": "hardhat run scripts/verify-deployments.ts",
6163
"verify-vendor-contracts": "hardhat run scripts/verify-vendor-contracts.ts",
@@ -74,6 +76,7 @@
7476
"@typechain/ethers-v6": "^0.5.1",
7577
"@typechain/hardhat": "^9.1.0",
7678
"@types/chai": "^4.3.20",
79+
"@types/jest": "^29.5.14",
7780
"@types/mocha": "^10.0.10",
7881
"@types/node": "^20.17.11",
7982
"@types/yargs": "^17.0.33",
@@ -86,10 +89,12 @@
8689
"hardhat": "^2.22.17",
8790
"hardhat-deploy": "^0.14.0",
8891
"hardhat-gas-reporter": "^2.2.2",
92+
"jest": "^29.7.0",
8993
"prettier": "^3.4.2",
9094
"prettier-plugin-solidity": "^1.4.1",
9195
"solhint": "^5.0.4",
9296
"solidity-coverage": "^0.8.14",
97+
"ts-jest": "^29.2.5",
9398
"ts-node": "^10.9.2",
9499
"typechain": "^8.3.2",
95100
"typescript": "^5.7.2",

0 commit comments

Comments
 (0)