vitest 0.0.79 → 0.0.80
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 +3 -3
- package/dist/{constants-2435fa16.js → constants-9da0006f.js} +2 -3
- package/dist/entry.js +33 -48
- package/dist/{global-38c2f902.js → global-6446cca1.js} +3 -3
- package/dist/{index-6feda5ef.js → index-16a06164.js} +8 -7
- package/dist/index.d.ts +7 -6
- package/dist/index.js +2 -2
- package/dist/{middleware-37267df8.js → middleware-fe2b1f7f.js} +1 -1
- package/dist/worker.js +1 -1
- package/global.d.ts +2 -3
- package/package.json +3 -6
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import path, { isAbsolute, relative, dirname, basename, resolve } from 'path';
|
|
|
4
4
|
import process$2 from 'process';
|
|
5
5
|
import { promises } from 'fs';
|
|
6
6
|
import { createServer } from 'vite';
|
|
7
|
-
import { d as defaultIncludes, a as defaultExcludes, b as defaultPort, c as configFiles, e as distDir } from './constants-
|
|
7
|
+
import { d as defaultIncludes, a as defaultExcludes, b as defaultPort, c as configFiles, e as distDir } from './constants-9da0006f.js';
|
|
8
8
|
import { performance } from 'perf_hooks';
|
|
9
9
|
import { g as getNames, s as slash, a as getTests, b as getSuites, t as toArray, h as hasFailed } from './utils-9dcc4050.js';
|
|
10
10
|
import require$$0 from 'assert';
|
|
@@ -632,7 +632,7 @@ const cac = (name = "") => new CAC(name);
|
|
|
632
632
|
|
|
633
633
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
634
634
|
|
|
635
|
-
var version = "0.0.
|
|
635
|
+
var version = "0.0.80";
|
|
636
636
|
|
|
637
637
|
/*
|
|
638
638
|
How it works:
|
|
@@ -2182,7 +2182,7 @@ async function initVitest(options = {}) {
|
|
|
2182
2182
|
},
|
|
2183
2183
|
async configureServer(server2) {
|
|
2184
2184
|
if (resolved.api)
|
|
2185
|
-
server2.middlewares.use((await import('./middleware-
|
|
2185
|
+
server2.middlewares.use((await import('./middleware-fe2b1f7f.js')).default());
|
|
2186
2186
|
}
|
|
2187
2187
|
}
|
|
2188
2188
|
],
|
package/dist/entry.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Console } from 'console';
|
|
|
2
2
|
import { Writable } from 'stream';
|
|
3
3
|
import { importModule } from 'local-pkg';
|
|
4
4
|
import chai, { expect, util } from 'chai';
|
|
5
|
-
import SinonChai from 'sinon-chai';
|
|
6
5
|
import Subset from 'chai-subset';
|
|
7
6
|
import path, { basename } from 'path';
|
|
8
7
|
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
@@ -3500,31 +3499,22 @@ function JestChaiExpect() {
|
|
|
3500
3499
|
utils.expectTypes(this, ["number"]);
|
|
3501
3500
|
return this.closeTo(number, numDigits);
|
|
3502
3501
|
});
|
|
3503
|
-
|
|
3504
|
-
return
|
|
3505
|
-
}
|
|
3506
|
-
function isCall(putativeCall) {
|
|
3507
|
-
return putativeCall && isSpy(putativeCall.proxy);
|
|
3508
|
-
}
|
|
3509
|
-
const assertIsMock = (assertion) => {
|
|
3510
|
-
if (!isSpy(assertion._obj) && !isCall(assertion._obj))
|
|
3511
|
-
throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`);
|
|
3502
|
+
const getSpy = (assertion) => {
|
|
3503
|
+
return assertion._obj;
|
|
3512
3504
|
};
|
|
3513
3505
|
def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {
|
|
3514
|
-
|
|
3515
|
-
return this.callCount(number);
|
|
3506
|
+
return this.assert(getSpy(this).callCount === number, "expected spy to be called #{exp} times", "expected spy to not be called #{exp} times", number);
|
|
3516
3507
|
});
|
|
3517
3508
|
def("toHaveBeenCalledOnce", function() {
|
|
3518
|
-
|
|
3519
|
-
return this.callCount(1);
|
|
3509
|
+
return this.assert(getSpy(this).callCount === 1, "expected spy to be called once", "expected spy to not be called once", 1);
|
|
3520
3510
|
});
|
|
3521
3511
|
def(["toHaveBeenCalled", "toBeCalled"], function() {
|
|
3522
|
-
|
|
3523
|
-
return this.called;
|
|
3512
|
+
return this.assert(getSpy(this).called, "expected spy to be called at least once", "expected spy to not be called at all", true);
|
|
3524
3513
|
});
|
|
3525
3514
|
def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
|
|
3526
|
-
|
|
3527
|
-
|
|
3515
|
+
const spy = getSpy(this);
|
|
3516
|
+
const pass = spy.calls.some((callArg) => equals(callArg, args));
|
|
3517
|
+
return this.assert(pass, "expected spy to be called with arguments: #{exp}", "expected spy to not be called with arguments: #{exp}", args);
|
|
3528
3518
|
});
|
|
3529
3519
|
const ordinalOf = (i) => {
|
|
3530
3520
|
const j = i % 10;
|
|
@@ -3538,16 +3528,14 @@ function JestChaiExpect() {
|
|
|
3538
3528
|
return `${i}th`;
|
|
3539
3529
|
};
|
|
3540
3530
|
def(["toHaveBeenNthCalledWith", "nthCalledWith"], function(times, ...args) {
|
|
3541
|
-
|
|
3542
|
-
const
|
|
3543
|
-
|
|
3544
|
-
this.assert(nthCall.calledWith(...args), `expected ${ordinalOf(times)} spy call to have been called with #{exp}`, `expected ${ordinalOf(times)} spy call not to have been called with #{exp}`, args, nthCall.args);
|
|
3531
|
+
const spy = getSpy(this);
|
|
3532
|
+
const nthCall = spy.calls[times - 1];
|
|
3533
|
+
this.assert(equals(nthCall, args), `expected ${ordinalOf(times)} spy call to have been called with #{exp}`, `expected ${ordinalOf(times)} spy call to not have been called with #{exp}`, args, nthCall);
|
|
3545
3534
|
});
|
|
3546
3535
|
def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
|
|
3547
|
-
|
|
3548
|
-
const
|
|
3549
|
-
|
|
3550
|
-
this.assert(lastCall.calledWith(...args), "expected last spy call to have been called with #{exp}", "expected last spy call not to have been called with #{exp}", args, lastCall.args);
|
|
3536
|
+
const spy = getSpy(this);
|
|
3537
|
+
const lastCall = spy.calls.at(-1);
|
|
3538
|
+
this.assert(equals(lastCall, args), "expected last spy call to have been called with #{exp}", "expected last spy call to not have been called with #{exp}", args, lastCall);
|
|
3551
3539
|
});
|
|
3552
3540
|
def(["toThrow", "toThrowError"], function(expected) {
|
|
3553
3541
|
const negate = utils.flag(this, "negate");
|
|
@@ -3557,37 +3545,35 @@ function JestChaiExpect() {
|
|
|
3557
3545
|
this.to.throw(expected);
|
|
3558
3546
|
});
|
|
3559
3547
|
def(["toHaveReturned", "toReturn"], function() {
|
|
3560
|
-
|
|
3561
|
-
const
|
|
3562
|
-
|
|
3563
|
-
this.assert(calledAndNotThrew, "expected spy to be successfully called at least once", "expected spy not to be successfully called", calledAndNotThrew, !calledAndNotThrew);
|
|
3548
|
+
const spy = getSpy(this);
|
|
3549
|
+
const calledAndNotThrew = spy.called && !spy.results.some(([type]) => type === "error");
|
|
3550
|
+
this.assert(calledAndNotThrew, "expected spy to be successfully called at least once", "expected spy to not be successfully called", calledAndNotThrew, !calledAndNotThrew);
|
|
3564
3551
|
});
|
|
3565
3552
|
def(["toHaveReturnedTimes", "toReturnTimes"], function(times) {
|
|
3566
|
-
|
|
3567
|
-
const
|
|
3568
|
-
|
|
3569
|
-
this.assert(successfullReturns === times, `expected spy to be successfully called ${times} times`, `expected spy not to be successfully called ${times} times`, `expected number of returns: ${times}`, `recieved number of returns: ${successfullReturns}`);
|
|
3553
|
+
const spy = getSpy(this);
|
|
3554
|
+
const successfullReturns = spy.results.reduce((success, [type]) => type === "error" ? success : ++success, 0);
|
|
3555
|
+
this.assert(successfullReturns === times, `expected spy to be successfully called ${times} times`, `expected spy to not be successfully called ${times} times`, `expected number of returns: ${times}`, `recieved number of returns: ${successfullReturns}`);
|
|
3570
3556
|
});
|
|
3571
3557
|
def(["toHaveReturnedWith", "toReturnWith"], function(value) {
|
|
3572
|
-
|
|
3573
|
-
|
|
3558
|
+
const spy = getSpy(this);
|
|
3559
|
+
const pass = spy.results.some(([type, result]) => type === "ok" && equals(value, result));
|
|
3560
|
+
this.assert(pass, "expected spy to be successfully called with #{exp}", "expected spy to not be successfully called with #{exp}", value);
|
|
3574
3561
|
});
|
|
3575
3562
|
def(["toHaveLastReturnedWith", "lastReturnedWith"], function(value) {
|
|
3576
|
-
|
|
3577
|
-
const
|
|
3578
|
-
const
|
|
3579
|
-
this.assert(
|
|
3563
|
+
const spy = getSpy(this);
|
|
3564
|
+
const lastResult = spy.returns.at(-1);
|
|
3565
|
+
const pass = equals(lastResult, value);
|
|
3566
|
+
this.assert(pass, "expected last spy call to return #{exp}", "expected last spy call to not return #{exp}", value, lastResult);
|
|
3580
3567
|
});
|
|
3581
3568
|
def(["toHaveNthReturnedWith", "nthReturnedWith"], function(nthCall, value) {
|
|
3582
|
-
|
|
3583
|
-
const spy = utils.flag(this, "object");
|
|
3569
|
+
const spy = getSpy(this);
|
|
3584
3570
|
const isNot = utils.flag(this, "negate");
|
|
3585
|
-
const
|
|
3571
|
+
const [callType, callResult] = spy.results[nthCall - 1];
|
|
3586
3572
|
const ordinalCall = `${ordinalOf(nthCall)} call`;
|
|
3587
|
-
if (!isNot &&
|
|
3573
|
+
if (!isNot && callType === "error")
|
|
3588
3574
|
chai.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);
|
|
3589
|
-
const nthCallReturn =
|
|
3590
|
-
this.assert(nthCallReturn, `expected ${ordinalCall} spy call to return #{exp}`, `expected ${ordinalCall} spy call not
|
|
3575
|
+
const nthCallReturn = equals(callResult, value);
|
|
3576
|
+
this.assert(nthCallReturn, `expected ${ordinalCall} spy call to return #{exp}`, `expected ${ordinalCall} spy call to not return #{exp}`, value, callResult);
|
|
3591
3577
|
});
|
|
3592
3578
|
};
|
|
3593
3579
|
}
|
|
@@ -3596,7 +3582,6 @@ let installed = false;
|
|
|
3596
3582
|
async function setupChai() {
|
|
3597
3583
|
if (installed)
|
|
3598
3584
|
return;
|
|
3599
|
-
chai.use(SinonChai);
|
|
3600
3585
|
chai.use(JestExtend());
|
|
3601
3586
|
chai.use(JestChaiExpect());
|
|
3602
3587
|
chai.use(Subset);
|
|
@@ -3612,7 +3597,7 @@ async function setupGlobalEnv(config) {
|
|
|
3612
3597
|
setupConsoleLogSpy();
|
|
3613
3598
|
await setupChai();
|
|
3614
3599
|
if (config.global)
|
|
3615
|
-
(await import('./global-
|
|
3600
|
+
(await import('./global-6446cca1.js')).registerApiGlobally();
|
|
3616
3601
|
}
|
|
3617
3602
|
function setupConsoleLogSpy() {
|
|
3618
3603
|
const stdout = new Writable({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-9da0006f.js';
|
|
2
|
+
import { i as index } from './index-16a06164.js';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'url';
|
|
5
5
|
import './suite-95be5909.js';
|
|
6
6
|
import './index-9e71c815.js';
|
|
7
7
|
import 'chai';
|
|
8
|
-
import '
|
|
8
|
+
import 'tinyspy';
|
|
9
9
|
|
|
10
10
|
function registerApiGlobally() {
|
|
11
11
|
globalApis.forEach((api) => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-95be5909.js';
|
|
2
2
|
import chai, { assert, should, expect } from 'chai';
|
|
3
|
-
import
|
|
3
|
+
import { spyOn, spy } from 'tinyspy';
|
|
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()));
|
|
7
7
|
const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
8
8
|
const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const vitest = {
|
|
11
|
+
spyOn,
|
|
12
|
+
fn: spy
|
|
13
|
+
};
|
|
12
14
|
|
|
13
15
|
var index = /*#__PURE__*/Object.freeze({
|
|
14
16
|
__proto__: null,
|
|
@@ -24,10 +26,9 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
24
26
|
should: should,
|
|
25
27
|
expect: expect,
|
|
26
28
|
chai: chai,
|
|
27
|
-
sinon: sinon,
|
|
28
|
-
mock: mock,
|
|
29
29
|
spy: spy,
|
|
30
|
-
|
|
30
|
+
spyOn: spyOn,
|
|
31
|
+
vitest: vitest
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d,
|
|
34
|
+
export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, index as i, vitest as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { TransformResult, ViteDevServer } from 'vite';
|
|
|
3
3
|
import { OptionsReceived } from 'pretty-format';
|
|
4
4
|
import { MessagePort } from 'worker_threads';
|
|
5
5
|
export { assert, default as chai, expect, should } from 'chai';
|
|
6
|
-
import
|
|
7
|
-
export {
|
|
6
|
+
import { spyOn, spy } from 'tinyspy';
|
|
7
|
+
export { spy, spyOn } from 'tinyspy';
|
|
8
8
|
|
|
9
9
|
declare const EXPECTED_COLOR: Formatter;
|
|
10
10
|
declare const RECEIVED_COLOR: Formatter;
|
|
@@ -567,9 +567,10 @@ declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undef
|
|
|
567
567
|
declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
|
|
568
568
|
declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
|
|
569
569
|
|
|
570
|
-
declare const
|
|
571
|
-
|
|
572
|
-
|
|
570
|
+
declare const vitest: {
|
|
571
|
+
spyOn: typeof spyOn;
|
|
572
|
+
fn: typeof spy;
|
|
573
|
+
};
|
|
573
574
|
|
|
574
575
|
declare module 'vite' {
|
|
575
576
|
interface UserConfig {
|
|
@@ -636,4 +637,4 @@ declare global {
|
|
|
636
637
|
}
|
|
637
638
|
}
|
|
638
639
|
|
|
639
|
-
export { Arrayable, Awaitable, CliOptions, ComputeMode, Environment, EnvironmentReturn, File, HookListener, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConsoleLog, UserOptions, VitestContext, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it,
|
|
640
|
+
export { Arrayable, Awaitable, CliOptions, ComputeMode, Environment, EnvironmentReturn, File, HookListener, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConsoleLog, UserOptions, VitestContext, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { d as describe, i as it, s as suite, t as test } from './suite-95be5909.js';
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach,
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, v as vitest } from './index-16a06164.js';
|
|
3
3
|
export { assert, default as chai, expect, should } from 'chai';
|
|
4
|
-
export {
|
|
4
|
+
export { spy, spyOn } from 'tinyspy';
|
|
5
5
|
import './index-9e71c815.js';
|
package/dist/worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve, dirname } from 'path';
|
|
2
2
|
import { n as nanoid } from './index-9e71c815.js';
|
|
3
|
-
import { e as distDir } from './constants-
|
|
3
|
+
import { e as distDir } from './constants-9da0006f.js';
|
|
4
4
|
import { builtinModules, createRequire } from 'module';
|
|
5
5
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
6
6
|
import vm from 'vm';
|
package/global.d.ts
CHANGED
|
@@ -5,10 +5,9 @@ declare global {
|
|
|
5
5
|
const it: typeof import('vitest')['it']
|
|
6
6
|
const expect: typeof import('vitest')['expect']
|
|
7
7
|
const assert: typeof import('vitest')['assert']
|
|
8
|
-
const sinon: typeof import('vitest')['sinon']
|
|
9
8
|
const spy: typeof import('vitest')['spy']
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const spyOn: typeof import('vitest')['spyOn']
|
|
10
|
+
const vitest: typeof import('vitest')['vitest']
|
|
12
11
|
const beforeAll: typeof import('vitest')['beforeAll']
|
|
13
12
|
const afterAll: typeof import('vitest')['afterAll']
|
|
14
13
|
const beforeEach: typeof import('vitest')['beforeEach']
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -41,8 +41,6 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@types/chai": "^4.3.0",
|
|
43
43
|
"@types/chai-subset": "^1.3.3",
|
|
44
|
-
"@types/sinon": "^10.0.6",
|
|
45
|
-
"@types/sinon-chai": "^3.2.6",
|
|
46
44
|
"chai": "^4.3.4",
|
|
47
45
|
"chai-subset": "^1.6.0",
|
|
48
46
|
"fast-glob": "^3.2.7",
|
|
@@ -50,9 +48,8 @@
|
|
|
50
48
|
"local-pkg": "^0.4.0",
|
|
51
49
|
"micromatch": "^4.0.4",
|
|
52
50
|
"piscina": "^3.2.0",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"source-map": "^0.7.3"
|
|
51
|
+
"source-map": "^0.7.3",
|
|
52
|
+
"tinyspy": "^0.0.6"
|
|
56
53
|
},
|
|
57
54
|
"devDependencies": {
|
|
58
55
|
"@types/diff": "^5.0.1",
|