vitest 0.0.125 → 0.0.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/entry.js +5 -6
- package/dist/{global-3b7dd162.js → global-eb23b22e.js} +4 -4
- package/dist/{index-7f52a6d6.js → index-4b6e78b4.js} +3 -2
- package/dist/{index-37193236.js → index-e04b9e4c.js} +1 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -3
- package/dist/{jest-mock-038a01b3.js → jest-mock-30625866.js} +4 -1
- package/dist/node.js +1 -1
- package/dist/{vi-56df0b20.js → vi-5ff3926d.js} +37 -34
- package/dist/worker.js +2 -2
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709
|
|
|
8
8
|
import require$$0, { constants } from 'os';
|
|
9
9
|
import { s as signalExit } from './index-648e7ab2.js';
|
|
10
10
|
import { e as ensurePackageInstalled } from './index-9fdde2e8.js';
|
|
11
|
-
import { c as createVitest } from './index-
|
|
11
|
+
import { c as createVitest } from './index-e04b9e4c.js';
|
|
12
12
|
import './_commonjsHelpers-c9e3b764.js';
|
|
13
13
|
import 'fs';
|
|
14
14
|
import 'stream';
|
|
@@ -1700,7 +1700,7 @@ function execa(file, args, options) {
|
|
|
1700
1700
|
return mergePromise(spawned, handlePromiseOnce);
|
|
1701
1701
|
}
|
|
1702
1702
|
|
|
1703
|
-
var version = "0.0.
|
|
1703
|
+
var version = "0.0.126";
|
|
1704
1704
|
|
|
1705
1705
|
const CLOSE_TIMEOUT = 1e3;
|
|
1706
1706
|
const cli = cac("vitest");
|
package/dist/entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
-
import { f as format_1, h as getSerializers, p as plugins_1,
|
|
2
|
+
import { f as format_1, h as getSerializers, p as plugins_1, j as equals, b as getState, k as iterableEquality, l as subsetEquality, m as isA, J as JestChaiExpect, n as clearContext, o as defaultSuite, q as setHooks, r as getHooks, u as context, s as setState, x as getFn, e as vi } from './vi-5ff3926d.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
@@ -11,7 +11,7 @@ import { l as getOriginalPos, m as posToNumber, n as parseStacktrace, u as unifi
|
|
|
11
11
|
import { performance as performance$1 } from 'perf_hooks';
|
|
12
12
|
import { createHash } from 'crypto';
|
|
13
13
|
import { format } from 'util';
|
|
14
|
-
import './jest-mock-
|
|
14
|
+
import './jest-mock-30625866.js';
|
|
15
15
|
import 'tinyspy';
|
|
16
16
|
import 'url';
|
|
17
17
|
import 'tty';
|
|
@@ -985,12 +985,11 @@ const getMatcherState = (assertion) => {
|
|
|
985
985
|
iterableEquality,
|
|
986
986
|
subsetEquality
|
|
987
987
|
});
|
|
988
|
-
const matcherState = __spreadProps(__spreadValues({
|
|
988
|
+
const matcherState = __spreadProps(__spreadValues({}, getState()), {
|
|
989
989
|
isNot,
|
|
990
990
|
utils: jestUtils,
|
|
991
991
|
promise,
|
|
992
|
-
equals
|
|
993
|
-
}, getState()), {
|
|
992
|
+
equals,
|
|
994
993
|
suppressedErrors: []
|
|
995
994
|
});
|
|
996
995
|
return {
|
|
@@ -1226,7 +1225,7 @@ async function setupGlobalEnv(config) {
|
|
|
1226
1225
|
setupConsoleLogSpy();
|
|
1227
1226
|
await setupChai();
|
|
1228
1227
|
if (config.global)
|
|
1229
|
-
(await import('./global-
|
|
1228
|
+
(await import('./global-eb23b22e.js')).registerApiGlobally();
|
|
1230
1229
|
}
|
|
1231
1230
|
function setupConsoleLogSpy() {
|
|
1232
1231
|
const stdout = new Writable({
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { g as globalApis } from './constants-8b3a9b31.js';
|
|
2
|
-
import { i as index } from './index-
|
|
2
|
+
import { i as index } from './index-4b6e78b4.js';
|
|
3
3
|
import 'url';
|
|
4
4
|
import './index-9fdde2e8.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
9
|
-
import './
|
|
10
|
-
import './jest-mock-038a01b3.js';
|
|
8
|
+
import './vi-5ff3926d.js';
|
|
9
|
+
import './jest-mock-30625866.js';
|
|
11
10
|
import 'chai';
|
|
12
11
|
import 'tinyspy';
|
|
12
|
+
import './_commonjsHelpers-c9e3b764.js';
|
|
13
13
|
|
|
14
14
|
function registerApiGlobally() {
|
|
15
15
|
globalApis.forEach((api) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-5ff3926d.js';
|
|
2
2
|
import chai, { assert, should } from 'chai';
|
|
3
|
-
import { s as spies, a as spyOn, f as fn } from './jest-mock-
|
|
3
|
+
import { s as spies, i as isMockFunction, a as spyOn, f as fn } from './jest-mock-30625866.js';
|
|
4
4
|
|
|
5
5
|
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
6
6
|
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
@@ -29,6 +29,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
29
29
|
chai: chai,
|
|
30
30
|
expect: expect,
|
|
31
31
|
spies: spies,
|
|
32
|
+
isMockFunction: isMockFunction,
|
|
32
33
|
spyOn: spyOn,
|
|
33
34
|
fn: fn,
|
|
34
35
|
vitest: vitest,
|
|
@@ -7597,7 +7597,6 @@ createLogUpdate(process$1.stdout);
|
|
|
7597
7597
|
createLogUpdate(process$1.stderr);
|
|
7598
7598
|
|
|
7599
7599
|
const DURATION_LONG = 300;
|
|
7600
|
-
const MAX_HEIGHT = 20;
|
|
7601
7600
|
const outputMap = new WeakMap();
|
|
7602
7601
|
function formatFilepath(path) {
|
|
7603
7602
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -7643,7 +7642,7 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7643
7642
|
output = output.concat(renderTree(task.tasks, options, level + 1));
|
|
7644
7643
|
}
|
|
7645
7644
|
}
|
|
7646
|
-
return output.
|
|
7645
|
+
return output.join("\n");
|
|
7647
7646
|
}
|
|
7648
7647
|
const createListRenderer = (_tasks, options) => {
|
|
7649
7648
|
let tasks = _tasks;
|
package/dist/index.d.ts
CHANGED
|
@@ -822,6 +822,7 @@ interface MockWithArgs<T extends MockableFunction> extends JestMockCompatFn<Argu
|
|
|
822
822
|
(...args: ArgumentsOf<T>): ReturnType<T>;
|
|
823
823
|
}
|
|
824
824
|
declare const spies: Set<JestMockCompat<any[], any>>;
|
|
825
|
+
declare function isMockFunction(fn: any): fn is EnhancedSpy;
|
|
825
826
|
declare function spyOn<T, K extends keyof T>(obj: T, method: K, accessType?: 'get' | 'set'): T[K] extends (...args: infer TArgs) => infer TReturnValue ? JestMockCompat<TArgs, TReturnValue> : JestMockCompat;
|
|
826
827
|
declare type Awaited<T> = T extends Promise<infer R> ? R : never;
|
|
827
828
|
declare function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TArgs, R>;
|
|
@@ -899,7 +900,7 @@ declare class VitestUtils {
|
|
|
899
900
|
*/
|
|
900
901
|
mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
901
902
|
mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
902
|
-
isMockFunction(fn: any):
|
|
903
|
+
isMockFunction(fn: any): fn is EnhancedSpy;
|
|
903
904
|
clearAllMocks(): this;
|
|
904
905
|
resetAllMocks(): this;
|
|
905
906
|
restoreAllMocks(): this;
|
|
@@ -1011,4 +1012,4 @@ declare global {
|
|
|
1011
1012
|
}
|
|
1012
1013
|
}
|
|
1013
1014
|
|
|
1014
|
-
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ConstructorArgumentsOf, DoneCallback, EnhancedSpy, Environment, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, it, spies, spyOn, suite, test, vi, vitest };
|
|
1015
|
+
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ConstructorArgumentsOf, DoneCallback, EnhancedSpy, Environment, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, isMockFunction, it, spies, spyOn, suite, test, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-
|
|
3
|
-
export { f as fn, s as spies, a as spyOn } from './jest-mock-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-5ff3926d.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-4b6e78b4.js';
|
|
3
|
+
export { f as fn, i as isMockFunction, s as spies, a as spyOn } from './jest-mock-30625866.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
5
|
import './index-9fdde2e8.js';
|
|
6
6
|
import 'url';
|
|
@@ -2,6 +2,9 @@ import { util } from 'chai';
|
|
|
2
2
|
import * as tinyspy from 'tinyspy';
|
|
3
3
|
|
|
4
4
|
const spies = new Set();
|
|
5
|
+
function isMockFunction(fn2) {
|
|
6
|
+
return typeof fn2 === "function" && "__isSpy" in fn2 && fn2.__isSpy;
|
|
7
|
+
}
|
|
5
8
|
function spyOn(obj, method, accessType) {
|
|
6
9
|
const dictionary = {
|
|
7
10
|
get: "getter",
|
|
@@ -87,4 +90,4 @@ function fn(implementation) {
|
|
|
87
90
|
}) }, "fn"));
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
export { spyOn as a, fn as f, spies as s };
|
|
93
|
+
export { spyOn as a, fn as f, isMockFunction as i, spies as s };
|
package/dist/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as noop, i as isObject } from './index-9fdde2e8.js';
|
|
2
|
+
import { i as isMockFunction, a as spyOn, f as fn, s as spies } from './jest-mock-30625866.js';
|
|
2
3
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
|
|
3
|
-
import { a as spyOn, f as fn, s as spies } from './jest-mock-038a01b3.js';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __defProps = Object.defineProperties;
|
|
@@ -2861,12 +2861,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2861
2861
|
def("toContainEqual", function(expected) {
|
|
2862
2862
|
const obj = utils.flag(this, "object");
|
|
2863
2863
|
const index = Array.from(obj).findIndex((item) => {
|
|
2864
|
-
|
|
2865
|
-
chai.assert.deepEqual(item, expected);
|
|
2866
|
-
} catch {
|
|
2867
|
-
return false;
|
|
2868
|
-
}
|
|
2869
|
-
return true;
|
|
2864
|
+
return equals(item, expected);
|
|
2870
2865
|
});
|
|
2871
2866
|
this.assert(index !== -1, "expected #{this} to deep equally contain #{exp}", "expected #{this} to not deep equally contain #{exp}", expected);
|
|
2872
2867
|
});
|
|
@@ -2915,15 +2910,24 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2915
2910
|
def("toHaveProperty", function(...args) {
|
|
2916
2911
|
return this.have.deep.nested.property(...args);
|
|
2917
2912
|
});
|
|
2918
|
-
def("toBeCloseTo", function(
|
|
2919
|
-
|
|
2920
|
-
|
|
2913
|
+
def("toBeCloseTo", function(received, precision = 2) {
|
|
2914
|
+
const expected = this._obj;
|
|
2915
|
+
let pass = false;
|
|
2916
|
+
let expectedDiff = 0;
|
|
2917
|
+
let receivedDiff = 0;
|
|
2918
|
+
if (received === Infinity && expected === Infinity) {
|
|
2919
|
+
pass = true;
|
|
2920
|
+
} else if (received === -Infinity && expected === -Infinity) {
|
|
2921
|
+
pass = true;
|
|
2922
|
+
} else {
|
|
2923
|
+
expectedDiff = Math.pow(10, -precision) / 2;
|
|
2924
|
+
receivedDiff = Math.abs(expected - received);
|
|
2925
|
+
pass = receivedDiff < expectedDiff;
|
|
2926
|
+
}
|
|
2927
|
+
return this.assert(pass, `expected #{this} to be close to #{exp}, recieved difference is ${receivedDiff}, but expected ${expectedDiff}`, `expected #{this} to not be close to #{exp}, recieved difference is ${receivedDiff}, but expected ${expectedDiff}`, received, expected);
|
|
2921
2928
|
});
|
|
2922
|
-
function isSpy(putativeSpy) {
|
|
2923
|
-
return typeof putativeSpy === "function" && "__isSpy" in putativeSpy && putativeSpy.__isSpy;
|
|
2924
|
-
}
|
|
2925
2929
|
const assertIsMock = (assertion) => {
|
|
2926
|
-
if (!
|
|
2930
|
+
if (!isMockFunction(assertion._obj))
|
|
2927
2931
|
throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`);
|
|
2928
2932
|
};
|
|
2929
2933
|
const getSpy = (assertion) => {
|
|
@@ -2933,23 +2937,26 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2933
2937
|
def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {
|
|
2934
2938
|
const spy = getSpy(this);
|
|
2935
2939
|
const spyName = spy.getMockName();
|
|
2936
|
-
|
|
2940
|
+
const callCount = spy.mock.calls.length;
|
|
2941
|
+
return this.assert(callCount === number, `expected "${spyName}" to be called #{exp} times`, `expected "${spyName}" to not be called #{exp} times`, number, callCount);
|
|
2937
2942
|
});
|
|
2938
2943
|
def("toHaveBeenCalledOnce", function() {
|
|
2939
2944
|
const spy = getSpy(this);
|
|
2940
2945
|
const spyName = spy.getMockName();
|
|
2941
|
-
|
|
2946
|
+
const callCount = spy.mock.calls.length;
|
|
2947
|
+
return this.assert(callCount === 1, `expected "${spyName}" to be called once`, `expected "${spyName}" to not be called once`, 1, callCount);
|
|
2942
2948
|
});
|
|
2943
2949
|
def(["toHaveBeenCalled", "toBeCalled"], function() {
|
|
2944
2950
|
const spy = getSpy(this);
|
|
2945
2951
|
const spyName = spy.getMockName();
|
|
2946
|
-
|
|
2952
|
+
const called = spy.mock.calls.length > 0;
|
|
2953
|
+
return this.assert(called, `expected "${spyName}" to be called at least once`, `expected "${spyName}" to not be called at all`, true, called);
|
|
2947
2954
|
});
|
|
2948
2955
|
def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
|
|
2949
2956
|
const spy = getSpy(this);
|
|
2950
2957
|
const spyName = spy.getMockName();
|
|
2951
|
-
const pass = spy.calls.some((callArg) => equals(callArg, args, [iterableEquality]));
|
|
2952
|
-
return this.assert(pass, `expected "${spyName}" to be called with arguments: #{exp}`, `expected "${spyName}" to not be called with arguments: #{exp}`, args, spy.calls);
|
|
2958
|
+
const pass = spy.mock.calls.some((callArg) => equals(callArg, args, [iterableEquality]));
|
|
2959
|
+
return this.assert(pass, `expected "${spyName}" to be called with arguments: #{exp}`, `expected "${spyName}" to not be called with arguments: #{exp}`, args, spy.mock.calls);
|
|
2953
2960
|
});
|
|
2954
2961
|
const ordinalOf = (i) => {
|
|
2955
2962
|
const j = i % 10;
|
|
@@ -2965,44 +2972,40 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2965
2972
|
def(["toHaveBeenNthCalledWith", "nthCalledWith"], function(times, ...args) {
|
|
2966
2973
|
const spy = getSpy(this);
|
|
2967
2974
|
const spyName = spy.getMockName();
|
|
2968
|
-
const nthCall = spy.calls[times - 1];
|
|
2975
|
+
const nthCall = spy.mock.calls[times - 1];
|
|
2969
2976
|
this.assert(equals(nthCall, args, [iterableEquality]), `expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`, `expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`, args, nthCall);
|
|
2970
2977
|
});
|
|
2971
2978
|
def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
|
|
2972
2979
|
const spy = getSpy(this);
|
|
2973
2980
|
const spyName = spy.getMockName();
|
|
2974
|
-
const lastCall = spy.calls[spy.calls.length - 1];
|
|
2981
|
+
const lastCall = spy.mock.calls[spy.calls.length - 1];
|
|
2975
2982
|
this.assert(equals(lastCall, args, [iterableEquality]), `expected last "${spyName}" call to have been called with #{exp}`, `expected last "${spyName}" call to not have been called with #{exp}`, args, lastCall);
|
|
2976
2983
|
});
|
|
2977
2984
|
def(["toThrow", "toThrowError"], function(expected) {
|
|
2978
|
-
|
|
2979
|
-
if (negate)
|
|
2980
|
-
this.not.to.throw(expected);
|
|
2981
|
-
else
|
|
2982
|
-
this.to.throw(expected);
|
|
2985
|
+
return this.to.throw(expected);
|
|
2983
2986
|
});
|
|
2984
2987
|
def(["toHaveReturned", "toReturn"], function() {
|
|
2985
2988
|
const spy = getSpy(this);
|
|
2986
2989
|
const spyName = spy.getMockName();
|
|
2987
|
-
const calledAndNotThrew = spy.
|
|
2990
|
+
const calledAndNotThrew = spy.mock.calls.length > 0 && !spy.mock.results.some(({ type }) => type === "throw");
|
|
2988
2991
|
this.assert(calledAndNotThrew, `expected "${spyName}" to be successfully called at least once`, `expected "${spyName}" to not be successfully called`, calledAndNotThrew, !calledAndNotThrew);
|
|
2989
2992
|
});
|
|
2990
2993
|
def(["toHaveReturnedTimes", "toReturnTimes"], function(times) {
|
|
2991
2994
|
const spy = getSpy(this);
|
|
2992
2995
|
const spyName = spy.getMockName();
|
|
2993
|
-
const successfullReturns = spy.results.reduce((success,
|
|
2996
|
+
const successfullReturns = spy.mock.results.reduce((success, { type }) => type === "throw" ? success : ++success, 0);
|
|
2994
2997
|
this.assert(successfullReturns === times, `expected "${spyName}" to be successfully called ${times} times`, `expected "${spyName}" to not be successfully called ${times} times`, `expected number of returns: ${times}`, `received number of returns: ${successfullReturns}`);
|
|
2995
2998
|
});
|
|
2996
2999
|
def(["toHaveReturnedWith", "toReturnWith"], function(value) {
|
|
2997
3000
|
const spy = getSpy(this);
|
|
2998
3001
|
const spyName = spy.getMockName();
|
|
2999
|
-
const pass = spy.results.some((
|
|
3002
|
+
const pass = spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result));
|
|
3000
3003
|
this.assert(pass, `expected "${spyName}" to be successfully called with #{exp}`, `expected "${spyName}" to not be successfully called with #{exp}`, value);
|
|
3001
3004
|
});
|
|
3002
3005
|
def(["toHaveLastReturnedWith", "lastReturnedWith"], function(value) {
|
|
3003
3006
|
const spy = getSpy(this);
|
|
3004
3007
|
const spyName = spy.getMockName();
|
|
3005
|
-
const lastResult = spy.
|
|
3008
|
+
const { value: lastResult } = spy.mock.results[spy.returns.length - 1];
|
|
3006
3009
|
const pass = equals(lastResult, value);
|
|
3007
3010
|
this.assert(pass, `expected last "${spyName}" call to return #{exp}`, `expected last "${spyName}" call to not return #{exp}`, value, lastResult);
|
|
3008
3011
|
});
|
|
@@ -3010,9 +3013,9 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
3010
3013
|
const spy = getSpy(this);
|
|
3011
3014
|
const spyName = spy.getMockName();
|
|
3012
3015
|
const isNot = utils.flag(this, "negate");
|
|
3013
|
-
const
|
|
3016
|
+
const { type: callType, value: callResult } = spy.mock.results[nthCall - 1];
|
|
3014
3017
|
const ordinalCall = `${ordinalOf(nthCall)} call`;
|
|
3015
|
-
if (!isNot && callType === "
|
|
3018
|
+
if (!isNot && callType === "throw")
|
|
3016
3019
|
chai.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);
|
|
3017
3020
|
const nthCallReturn = equals(callResult, value);
|
|
3018
3021
|
this.assert(nthCallReturn, `expected ${ordinalCall} "${spyName}" call to return #{exp}`, `expected ${ordinalCall} "${spyName}" call to not return #{exp}`, value, callResult);
|
|
@@ -3362,7 +3365,7 @@ class FakeTimers {
|
|
|
3362
3365
|
this._setInterval,
|
|
3363
3366
|
this._clearTimeout,
|
|
3364
3367
|
this._clearInterval
|
|
3365
|
-
], 'timers are not mocked. try calling "
|
|
3368
|
+
], 'timers are not mocked. try calling "vi.useFakeTimers()" first');
|
|
3366
3369
|
}
|
|
3367
3370
|
}
|
|
3368
3371
|
|
|
@@ -3419,7 +3422,7 @@ class VitestUtils {
|
|
|
3419
3422
|
return item;
|
|
3420
3423
|
}
|
|
3421
3424
|
isMockFunction(fn2) {
|
|
3422
|
-
return
|
|
3425
|
+
return isMockFunction(fn2);
|
|
3423
3426
|
}
|
|
3424
3427
|
clearAllMocks() {
|
|
3425
3428
|
__vitest__clearMocks__({ clearMocks: true });
|
package/dist/worker.js
CHANGED
|
@@ -6,7 +6,7 @@ import { pathToFileURL, fileURLToPath } from 'url';
|
|
|
6
6
|
import vm from 'vm';
|
|
7
7
|
import { s as shouldExternalize } from './externalize-2f63779d.js';
|
|
8
8
|
import { existsSync, readdirSync } from 'fs';
|
|
9
|
-
import { a as spyOn, s as spies } from './jest-mock-
|
|
9
|
+
import { a as spyOn, s as spies } from './jest-mock-30625866.js';
|
|
10
10
|
import { r as rpc } from './rpc-8c7cc374.js';
|
|
11
11
|
import 'tty';
|
|
12
12
|
import 'local-pkg';
|
|
@@ -383,7 +383,7 @@ async function startViteNode(ctx) {
|
|
|
383
383
|
return _viteNode;
|
|
384
384
|
}
|
|
385
385
|
function init(ctx) {
|
|
386
|
-
if (process.__vitest_worker__ && ctx.config.threads)
|
|
386
|
+
if (process.__vitest_worker__ && ctx.config.threads && ctx.config.isolate)
|
|
387
387
|
throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${process.__vitest_worker__.ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
|
|
388
388
|
process.stdout.write("\0");
|
|
389
389
|
const { config, port } = ctx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.126",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"strip-ansi": "^7.0.1",
|
|
92
92
|
"typescript": "^4.5.4",
|
|
93
93
|
"ws": "^8.4.0",
|
|
94
|
-
"@vitest/ui": "0.0.
|
|
94
|
+
"@vitest/ui": "0.0.126"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"c8": "*",
|