Skip to content

Commit b781b1d

Browse files
committed
jest -> vitest
1 parent c1a86be commit b781b1d

27 files changed

+2298
-607
lines changed

jest.config.js

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

package-lock.json

Lines changed: 2092 additions & 426 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,14 @@
2222
"prepack": "rm -rf build && npx tsc -p ./tsconfig-build.json && npx ts-add-js-extension --dir=build"
2323
},
2424
"devDependencies": {
25-
"@types/jest": "^29.5.13",
2625
"@types/node": "^20.12.7",
2726
"@typescript-eslint/eslint-plugin": "^5.62.0",
2827
"@typescript-eslint/parser": "^5.62.0",
2928
"eslint": "^8.57.0",
3029
"eslint-plugin-jest": "^27.9.0",
31-
"jest": "^29.7.0",
3230
"ts-add-js-extension": "^1.6.4",
33-
"ts-jest": "^29.2.5",
34-
"ts-node": "^10.9.2",
35-
"typescript": "^5.6.2"
31+
"typescript": "^5.6.2",
32+
"vitest": "^3.0.8"
3633
},
3734
"files": [
3835
"build"

tests/arrayBlock.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, expect, it, vi } from 'vitest';
2+
13
import * as de from '../lib' ;
24

35
import {
@@ -8,8 +10,6 @@ import {
810
getTimeout,
911
} from './helpers' ;
1012

11-
import { describe, it, expect, jest } from '@jest/globals';
12-
1313
// --------------------------------------------------------------------------------------------------------------- //
1414

1515
describe('de.array', () => {
@@ -273,12 +273,12 @@ describe('de.array', () => {
273273
describe('cancel', () => {
274274

275275
it('cancel object, subblocks cancelled too #1', async() => {
276-
const actionFooSpy = jest.fn();
276+
const actionFooSpy = vi.fn();
277277
const blockFoo = getResultBlock(null, 150, {
278278
onCancel: actionFooSpy,
279279
});
280280

281-
const actionBarSpy = jest.fn();
281+
const actionBarSpy = vi.fn();
282282
const blockBar = getResultBlock(null, 150, {
283283
onCancel: actionBarSpy,
284284
});
@@ -310,12 +310,12 @@ describe('de.array', () => {
310310
});
311311

312312
it('cancel object, subblocks cancelled too #2', async() => {
313-
const actionFooSpy = jest.fn();
313+
const actionFooSpy = vi.fn();
314314
const blockFoo = getResultBlock(null, 50, {
315315
onCancel: actionFooSpy,
316316
});
317317

318-
const actionBarSpy = jest.fn();
318+
const actionBarSpy = vi.fn();
319319
const blockBar = getResultBlock(null, 150, {
320320
onCancel: actionBarSpy,
321321
});
@@ -351,7 +351,7 @@ describe('de.array', () => {
351351
const errorFoo = de.error('SOME_ERROR');
352352
const blockFoo = getErrorBlock(errorFoo, 50);
353353

354-
const actionBarSpy = jest.fn();
354+
const actionBarSpy = vi.fn();
355355
const blockBar = getResultBlock(null, 150, {
356356
onCancel: actionBarSpy,
357357
});

tests/cache.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, expect, it } from 'vitest';
2+
13
import * as de from '../lib';
24

35
import { waitForValue } from './helpers';

tests/cancel.test.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, expect, it, vi } from 'vitest';
2+
13
import * as de from '../lib';
24
// --------------------------------------------------------------------------------------------------------------- //
35

@@ -6,7 +8,7 @@ describe('de.Cancel', () => {
68
it('cancel', () => {
79
const cancel = new de.Cancel();
810

9-
const spy = jest.fn();
11+
const spy = vi.fn();
1012
cancel.subscribe(spy);
1113

1214
const error = de.error('SOME_ERROR');
@@ -18,7 +20,7 @@ describe('de.Cancel', () => {
1820
it('cancel with plain object', () => {
1921
const cancel = new de.Cancel();
2022

21-
const spy = jest.fn();
23+
const spy = vi.fn();
2224
cancel.subscribe(spy);
2325

2426
const error = 'SOME_ERROR';
@@ -32,7 +34,7 @@ describe('de.Cancel', () => {
3234
it('cancel after cancel', () => {
3335
const cancel = new de.Cancel();
3436

35-
const spy = jest.fn();
37+
const spy = vi.fn();
3638
cancel.subscribe(spy);
3739

3840
const error1 = de.error('SOME_ERROR_1');
@@ -46,7 +48,7 @@ describe('de.Cancel', () => {
4648
it('cancel after close', () => {
4749
const cancel = new de.Cancel();
4850

49-
const spy = jest.fn();
51+
const spy = vi.fn();
5052
cancel.subscribe(spy);
5153

5254
cancel.close();
@@ -87,7 +89,7 @@ describe('de.Cancel', () => {
8789

8890
cancel.close();
8991

90-
const spy = jest.fn();
92+
const spy = vi.fn();
9193
cancel.subscribe(spy);
9294

9395
expect(spy.mock.calls).toHaveLength(0);
@@ -99,7 +101,7 @@ describe('de.Cancel', () => {
99101
const error = de.error('SOME_ERROR');
100102
cancel.cancel(error);
101103

102-
const spy = jest.fn();
104+
const spy = vi.fn();
103105
cancel.subscribe(spy);
104106

105107
expect(spy.mock.calls[ 0 ][ 0 ]).toBe(error);
@@ -149,7 +151,7 @@ describe('de.Cancel', () => {
149151
const parentCancel = new de.Cancel();
150152
const childCancel = parentCancel.create();
151153

152-
const spy = jest.fn();
154+
const spy = vi.fn();
153155
childCancel.subscribe(spy);
154156

155157
const error = de.error('SOME_ERROR');
@@ -163,7 +165,7 @@ describe('de.Cancel', () => {
163165
parentCancel.close();
164166
const childCancel = parentCancel.create();
165167

166-
const spy = jest.fn();
168+
const spy = vi.fn();
167169
childCancel.subscribe(spy);
168170

169171
const error = de.error('SOME_ERROR');
@@ -177,7 +179,7 @@ describe('de.Cancel', () => {
177179
parentCancel.close();
178180
const childCancel = parentCancel.create();
179181

180-
const spy = jest.fn();
182+
const spy = vi.fn();
181183
childCancel.subscribe(spy);
182184

183185
const error = de.error('SOME_ERROR');
@@ -193,7 +195,7 @@ describe('de.Cancel', () => {
193195

194196
const childCancel = parentCancel.create();
195197

196-
const spy = jest.fn();
198+
const spy = vi.fn();
197199
childCancel.subscribe(spy);
198200

199201
expect(spy.mock.calls[ 0 ][ 0 ]).toBe(error);

tests/descript.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, expect, it } from 'vitest';
2+
13
import * as de from '../lib';
24

35
describe('descript', () => {

tests/error.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, expect, it, vi } from 'vitest';
2+
13
/* eslint-disable no-console */
24
/* eslint-disable jest/no-conditional-expect */
35

tests/expect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { gunzipSync } from 'node:zlib' ;
2-
import { expect } from '@jest/globals';
2+
import { expect } from 'vitest';
33

44
expect.extend({
55
toBeValidGzip(received) {

tests/firstBlock.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import { describe, expect, it, vi } from 'vitest';
2+
13
/* eslint-disable jest/no-conditional-expect */
24

35
import * as de from '../lib';
46

57
describe('de.first', () => {
68

7-
it('first block is successful', async() => {
9+
it.only('first block is successful', async() => {
810
let result1;
9-
const spy1 = jest.fn<any, any>(() => {
11+
const spy1 = vi.fn<(...args: Array<any>) => any>(() => {
1012
result1 = {
1113
a: 1,
1214
};
@@ -16,7 +18,7 @@ describe('de.first', () => {
1618
block: spy1,
1719
});
1820

19-
const spy2 = jest.fn();
21+
const spy2 = vi.fn();
2022
const block2 = de.func({
2123
block: spy2,
2224
});
@@ -34,7 +36,7 @@ describe('de.first', () => {
3436

3537
it('first block throws', async() => {
3638
let error1;
37-
const spy1 = jest.fn(() => {
39+
const spy1 = vi.fn(() => {
3840
error1 = de.error({
3941
id: 'ERROR',
4042
});
@@ -45,7 +47,7 @@ describe('de.first', () => {
4547
});
4648

4749
let result2;
48-
const spy2 = jest.fn<any, any>(() => {
50+
const spy2 = vi.fn<(...args: Array<any>) => any>(() => {
4951
result2 = {
5052
a: 1,
5153
};
@@ -68,7 +70,7 @@ describe('de.first', () => {
6870

6971
it('second block throws', async() => {
7072
let error1;
71-
const spy1 = jest.fn(() => {
73+
const spy1 = vi.fn(() => {
7274
error1 = de.error({
7375
id: 'ERROR',
7476
});

0 commit comments

Comments
 (0)