Skip to content

Commit 7736cb2

Browse files
authored
chore: migrate from jest to vitest (#895)
* chore: remove jest dependencies * chore: add vitest * test: refactor tests from jest to vitest * test: refactor to use assert.fail * style: consistent test file names * chore: add vitest vscode extension recommendation * test: enable skipped test
1 parent 11bcd3b commit 7736cb2

File tree

112 files changed

+744
-1862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+744
-1862
lines changed

.vscode/extensions.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"recommendations": ["streetsidesoftware.code-spell-checker"]
2+
"recommendations": [
3+
"streetsidesoftware.code-spell-checker",
4+
"vitest.explorer"
5+
]
36
}

jest.config.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

package.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"start": "rollup -c --watch",
2222
"build": "rollup -c",
2323
"build:prod": "rollup -c --environment BUILD:production",
24-
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
25-
"test:path": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathPattern",
26-
"test:cov": "NODE_OPTIONS=--experimental-vm-modules jest --collect-coverage=true",
27-
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
24+
"test": "vitest run",
25+
"test:path": "vitest --watch --testNamePattern",
26+
"test:cov": "vitest run --coverage",
27+
"test:watch": "vitest watch",
2828
"lint": "eslint --fix --ignore-path .gitignore \"./**/*.ts*\"",
2929
"lint:check": "eslint --ignore-path .gitignore \"./**/*.ts*\"",
3030
"typecheck": "tsc --skipLibCheck --noEmit",
@@ -45,7 +45,6 @@
4545
"devDependencies": {
4646
"@commitlint/cli": "17.7.1",
4747
"@commitlint/config-conventional": "17.7.0",
48-
"@jest/globals": "29.7.0",
4948
"@rollup/plugin-node-resolve": "15.2.3",
5049
"@rollup/plugin-terser": "0.4.3",
5150
"@rollup/plugin-typescript": "11.1.6",
@@ -54,7 +53,6 @@
5453
"@semantic-release/git": "10.0.1",
5554
"@semantic-release/github": "9.2.6",
5655
"@semantic-release/npm": "11.0.2",
57-
"@types/jest": "29.5.11",
5856
"@types/node": "20.11.10",
5957
"@typescript-eslint/eslint-plugin": "6.18.1",
6058
"@typescript-eslint/parser": "6.18.1",
@@ -66,17 +64,15 @@
6664
"eslint-plugin-prettier": "4.2.1",
6765
"ethers": "6.11.0",
6866
"husky": "8.0.3",
69-
"jest": "29.7.0",
70-
"jest-mock": "29.7.0",
7167
"lint-staged": "15.2.2",
7268
"node-fetch": "3.3.2",
7369
"prettier": "2.8.7",
7470
"rollup": "4.9.6",
7571
"rollup-plugin-filesize": "10.0.0",
7672
"semantic-release": "21.0.1",
77-
"ts-jest": "29.2.5",
7873
"ts-node": "10.9.2",
79-
"typescript": "5.3.3"
74+
"typescript": "5.3.3",
75+
"vitest": "^2.1.4"
8076
},
8177
"packageManager": "[email protected]",
8278
"engines": {

src/crypto/bls.spec.ts renamed to src/crypto/bls.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { stringToBytes } from '@scure/base';
2+
import { describe, it, expect } from 'vitest';
3+
24
import { hexToBuffer } from '../utils/buffer';
35
import * as bls from './bls';
46

src/crypto/secp256k1.spec.ts renamed to src/crypto/secp256k1.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { sha256 } from '@noble/hashes/sha256';
2+
import { describe, it, expect } from 'vitest';
3+
24
import { base58check } from '../utils/base58';
35
import { bufferToHex, hexToBuffer } from '../utils/buffer';
46
import * as secp256k1 from './secp256k1';

src/fixtures/utils/expectTx.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { expect } from 'vitest';
2+
13
export const expectTxs = (result: any, expected: any) => {
24
expect(JSON.stringify(result, null, 2)).toEqual(
35
JSON.stringify(expected, null, 2),

src/fixtures/utils/makeList.spec.ts renamed to src/fixtures/utils/makeList.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { concatBytes } from '../../utils/buffer';
2+
import { describe, it, expect } from 'vitest';
3+
24
import { address, addressBytes } from '../common';
35
import { bytesForInt } from './bytesFor';
46
import { makeList, makeListBytes } from './makeList';

src/fixtures/utils/serializable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type { Codec } from '../../serializable/codec';
2+
import { describe, it, expect } from 'vitest';
3+
24
import type {
35
Serializable,
46
SerializableStatic,
File renamed without changes.

src/serializable/avax/signedTx.spec.ts renamed to src/serializable/avax/signedTx.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { signedTx, signedTxBytes } from '../../fixtures/avax';
2+
import { describe, it, expect } from 'vitest';
3+
24
import { getAVMManager } from '../avm/codec';
35
import { SignedTx } from './signedTx';
46

0 commit comments

Comments
 (0)