Skip to content

Commit

Permalink
feat: use vitest replace jest
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Oct 7, 2022
1 parent d66704c commit 86d5ff4
Show file tree
Hide file tree
Showing 9 changed files with 980 additions and 4,116 deletions.
13 changes: 0 additions & 13 deletions jest.config.js

This file was deleted.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"dev": "rollup -c -w",
"build": "rollup -c",
"test": "jest --no-cache"
"test": "vitest"
},
"author": "cuixiaorui",
"homepage": "https://github.com/cuixiaorui",
Expand All @@ -17,13 +17,11 @@
"@rollup/plugin-node-resolve": "^8.1.0",
"@rollup/plugin-replace": "^2.3.3",
"@rollup/plugin-typescript": "^8.2.5",
"@types/jest": "^26.0.24",
"jest": "^27.5.1",
"rollup": "^2.17.1",
"rollup-plugin-sourcemaps": "^0.6.2",
"ts-jest": "^27.0.5",
"tslib": "^2.3.1",
"typescript": "^4.4.3"
"typescript": "^4.4.3",
"vitest": "^0.22.1"
},
"dependencies": {
"@vue/reactivity": "^3.0.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1

exports[`element and interpolation 1`] = `
"
Expand Down
3 changes: 2 additions & 1 deletion packages/reactivity/__tests__/computed.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { computed } from "../src/computed";
import { reactive } from "../src/reactive";
import {vi} from 'vitest'

describe("computed", () => {
it("happy path", () => {
Expand All @@ -19,7 +20,7 @@ describe("computed", () => {
const value = reactive({
foo: 1,
});
const getter = jest.fn(() => {
const getter = vi.fn(() => {
return value.foo;
});
const cValue = computed(getter);
Expand Down
7 changes: 4 additions & 3 deletions packages/reactivity/__tests__/effect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { reactive } from "../src/reactive";
import { effect, stop } from "../src/effect";
import { vi } from "vitest";

describe("effect", () => {
it("should run the passed function once (wrapped by a effect)", () => {
const fnSpy = jest.fn(() => {});
const fnSpy = vi.fn(() => {});
effect(fnSpy);
expect(fnSpy).toHaveBeenCalledTimes(1);
});
Expand Down Expand Up @@ -66,7 +67,7 @@ describe("effect", () => {
it("scheduler", () => {
let dummy;
let run: any;
const scheduler = jest.fn(() => {
const scheduler = vi.fn(() => {
run = runner;
});
const obj = reactive({ foo: 1 });
Expand Down Expand Up @@ -108,7 +109,7 @@ describe("effect", () => {
});

it("events: onStop", () => {
const onStop = jest.fn();
const onStop = vi.fn();
const runner = effect(() => {}, {
onStop,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity/src/baseHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactiveEffect, track, trigger } from "./effect";
import { track, trigger } from "./effect";
import {
reactive,
ReactiveFlags,
Expand Down
9 changes: 5 additions & 4 deletions packages/runtime-core/__tests__/componentEmits.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { nodeOps, render, h } from "@mini-vue/runtime-test";
import {vi} from 'vitest'

describe("component: emits", () => {
test("trigger handlers", () => {
Expand All @@ -13,8 +14,8 @@ describe("component: emits", () => {
},
};

const onfoo = jest.fn();
const onBar = jest.fn();
const onfoo = vi.fn();
const onBar = vi.fn();
const Comp = {
render() {
return h(Foo, { onfoo, onBar });
Expand All @@ -37,7 +38,7 @@ describe("component: emits", () => {
},
};

const fooSpy = jest.fn();
const fooSpy = vi.fn();
const Comp = {
render() {
return h(Foo, { onTestEvent: fooSpy });
Expand All @@ -58,7 +59,7 @@ describe("component: emits", () => {
},
};

const fooSpy = jest.fn();
const fooSpy = vi.fn();

const Comp = {
render() {
Expand Down
Loading

0 comments on commit 86d5ff4

Please sign in to comment.