Skip to content

Commit

Permalink
feat: Replace jest with vitest (#1538)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbudovski authored Jan 11, 2025
1 parent dc458ff commit 6e76c06
Show file tree
Hide file tree
Showing 11 changed files with 2,208 additions and 4,093 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ cases/typia/build
cases/deepkit/build
cases/ts-auto-guard/build
cases/ts-auto-guard/src/index.guard.ts
jest.config.js
3 changes: 0 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/no-import-type-side-effects": "error"
},
"env": {
"jest": true
},
"overrides": [
{
"files": ["docs/**/*.tsx"],
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/assertLoose.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Benchmark } from './helpers/types';
import { validateData } from './parseSafe';
import type { ExpectStatic, SuiteAPI, TestAPI } from 'vitest';

type Fn = (data: unknown) => boolean;

Expand All @@ -18,7 +19,7 @@ export class AssertLoose extends Benchmark<Fn> {
this.fn(validateData);
}

test(describe: jest.Describe, expect: jest.Expect, test: jest.It) {
test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI) {
describe(this.moduleName, () => {
test('should validate the data', () => {
expect(this.fn(validateData)).toBe(true);
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/assertStrict.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Benchmark } from './helpers/types';
import { validateData } from './parseSafe';
import type { ExpectStatic, SuiteAPI, TestAPI } from 'vitest';

type Fn = (data: unknown) => boolean;

Expand All @@ -13,7 +14,7 @@ export class AssertStrict extends Benchmark<Fn> {
this.fn(validateData);
}

test(describe: jest.Describe, expect: jest.Expect, test: jest.It) {
test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI) {
describe(this.moduleName, () => {
test('should validate the data', () => {
expect(this.fn(validateData)).toBe(true);
Expand Down
14 changes: 6 additions & 8 deletions benchmarks/helpers/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { SuiteAPI, ExpectStatic, TestAPI } from 'vitest';

export interface BenchmarkCase {
readonly moduleName: string;

// execute the actual benchmark function
run(): void;

// run the benchmarks jest test
test(describe: jest.Describe, expect: jest.Expect, test: jest.It): void;
// run the benchmarks vitest test
test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI): void;
}

export abstract class Benchmark<Fn> implements BenchmarkCase {
Expand All @@ -23,12 +25,8 @@ export abstract class Benchmark<Fn> implements BenchmarkCase {
// execute the actual benchmark function
abstract run(): void;

// run the benchmarks jest test
abstract test(
describe: jest.Describe,
expect: jest.Expect,
test: jest.It,
): void;
// run the benchmarks vitest test
abstract test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI): void;
}

// Aliased any.
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/parseSafe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Benchmark } from './helpers/types';
import type { ExpectStatic, SuiteAPI, TestAPI } from 'vitest';

export const validateData = Object.freeze({
number: 1,
Expand Down Expand Up @@ -29,7 +30,7 @@ export class ParseSafe extends Benchmark<Fn> {
this.fn(validateData);
}

test(describe: jest.Describe, expect: jest.Expect, test: jest.It) {
test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI) {
describe(this.moduleName, () => {
test('should validate the data', () => {
expect(this.fn(validateData)).toEqual(validateData);
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/parseStrict.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Benchmark } from './helpers/types';
import { validateData } from './parseSafe';
import type { ExpectStatic, SuiteAPI, TestAPI } from 'vitest';

type Fn = (data: unknown) => typeof validateData;

Expand All @@ -11,7 +12,7 @@ export class ParseStrict extends Benchmark<Fn> {
this.fn(validateData);
}

test(describe: jest.Describe, expect: jest.Expect, test: jest.It) {
test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI) {
describe(this.moduleName, () => {
test('should validate the data', () => {
expect(this.fn(validateData)).toEqual(validateData);
Expand Down
4 changes: 0 additions & 4 deletions jest.config.js

This file was deleted.

Loading

0 comments on commit 6e76c06

Please sign in to comment.