@voidzero-dev/vite-plus-test 0.1.9 → 0.1.10
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/LICENSE.md +181 -1
- package/dist/@vitest/browser/client/.vite/manifest.json +6 -6
- package/dist/@vitest/browser/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-Di71CKDo.js +63 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.svg +49 -4
- package/dist/@vitest/browser/client/__vitest__/index.html +2 -2
- package/dist/@vitest/browser/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
- package/dist/@vitest/browser/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +167 -58
- package/dist/@vitest/browser/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
- package/dist/@vitest/browser/client/favicon.svg +49 -4
- package/dist/@vitest/browser/client/orchestrator.html +2 -2
- package/dist/@vitest/browser/client/tester/tester.html +2 -2
- package/dist/@vitest/browser/client.js +20 -13
- package/dist/@vitest/browser/context.d.ts +160 -10
- package/dist/@vitest/browser/context.js +108 -22
- package/dist/@vitest/browser/expect-element.js +23 -28
- package/dist/@vitest/browser/index-5Pe7X7sp.js +7 -0
- package/dist/@vitest/browser/index.d.ts +20 -2
- package/dist/@vitest/browser/index.js +5706 -159
- package/dist/@vitest/browser/locators.d.ts +14 -3
- package/dist/@vitest/browser/locators.js +1 -1
- package/dist/@vitest/browser-playwright/index.d.ts +22 -5
- package/dist/@vitest/browser-playwright/index.js +169 -61
- package/dist/@vitest/browser-preview/index.d.ts +14 -1
- package/dist/@vitest/browser-preview/locators.js +31 -18
- package/dist/@vitest/browser-webdriverio/index.d.ts +17 -3
- package/dist/@vitest/browser-webdriverio/index.js +22 -2
- package/dist/@vitest/browser-webdriverio/locators.js +84 -7
- package/dist/@vitest/expect/index.d.ts +172 -54
- package/dist/@vitest/expect/index.js +124 -67
- package/dist/@vitest/mocker/auto-register.js +1 -0
- package/dist/@vitest/mocker/automock.d.ts +1 -0
- package/dist/@vitest/mocker/automock.js +5 -0
- package/dist/@vitest/mocker/browser.d.ts +4 -4
- package/dist/@vitest/mocker/browser.js +1 -0
- package/dist/@vitest/mocker/chunk-automock.js +182 -14
- package/dist/@vitest/mocker/chunk-helpers.js +44 -0
- package/dist/@vitest/mocker/chunk-hoistMocks.js +659 -0
- package/dist/@vitest/mocker/chunk-mocker.js +41 -30
- package/dist/@vitest/mocker/chunk-registry.js +21 -7
- package/dist/@vitest/mocker/chunk-utils.js +18 -7
- package/dist/@vitest/mocker/hoistMocks.d-w2ILr1dG.d.ts +739 -0
- package/dist/@vitest/mocker/{index.d-C-sLYZi-.d.ts → index.d-B41z0AuW.d.ts} +1 -1
- package/dist/@vitest/mocker/index.d.ts +2 -2
- package/dist/@vitest/mocker/index.js +18 -3
- package/dist/@vitest/mocker/{mocker.d-TnKRhz7N.d.ts → mocker.d-QEntlm6J.d.ts} +10 -5
- package/dist/@vitest/mocker/node.d.ts +5 -734
- package/dist/@vitest/mocker/node.js +29 -587
- package/dist/@vitest/mocker/redirect.js +4 -4
- package/dist/@vitest/mocker/register.d.ts +3 -3
- package/dist/@vitest/mocker/register.js +1 -0
- package/dist/@vitest/mocker/transforms.d.ts +6 -0
- package/dist/@vitest/mocker/transforms.js +8 -0
- package/dist/@vitest/mocker/{types.d-B8CCKmHt.d.ts → types.d-BjI5eAwu.d.ts} +23 -7
- package/dist/@vitest/pretty-format/index.d.ts +11 -1
- package/dist/@vitest/pretty-format/index.js +33 -4
- package/dist/@vitest/runner/chunk-tasks.js +305 -37
- package/dist/@vitest/runner/index.d.ts +5 -6
- package/dist/@vitest/runner/index.js +1146 -455
- package/dist/@vitest/runner/{tasks.d-C7UxawJ9.d.ts → tasks.d-D2GKpdwQ.d.ts} +726 -55
- package/dist/@vitest/runner/types.d.ts +2 -182
- package/dist/@vitest/runner/utils.d.ts +16 -8
- package/dist/@vitest/runner/utils.js +1 -1
- package/dist/@vitest/snapshot/{environment.d-DHdQ1Csl.d.ts → environment.d-DOJxxZV9.d.ts} +2 -7
- package/dist/@vitest/snapshot/environment.d.ts +2 -1
- package/dist/@vitest/snapshot/environment.js +1 -1
- package/dist/@vitest/snapshot/index.d.ts +4 -3
- package/dist/@vitest/snapshot/index.js +21 -550
- package/dist/@vitest/snapshot/manager.d.ts +3 -2
- package/dist/@vitest/snapshot/manager.js +1 -1
- package/dist/@vitest/snapshot/{rawSnapshot.d-lFsMJFUd.d.ts → rawSnapshot.d-U2kJUxDr.d.ts} +1 -1
- package/dist/@vitest/spy/index.d.ts +34 -4
- package/dist/@vitest/spy/index.js +69 -19
- package/dist/@vitest/utils/diff.js +11 -9
- package/dist/@vitest/utils/display.d.ts +2 -1
- package/dist/@vitest/utils/display.js +38 -5
- package/dist/@vitest/utils/error.d.ts +2 -1
- package/dist/@vitest/utils/error.js +1 -2
- package/dist/@vitest/utils/helpers.d.ts +4 -1
- package/dist/@vitest/utils/helpers.js +43 -1
- package/dist/@vitest/utils/resolver.js +1 -2
- package/dist/@vitest/utils/serialize.js +6 -6
- package/dist/@vitest/utils/source-map/node.d.ts +6 -0
- package/dist/@vitest/utils/source-map/node.js +23 -0
- package/dist/@vitest/utils/source-map.js +15 -5
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +2 -2
- package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
- package/dist/chunks/{base.CJ0Y4ePK.js → base.DM0-RqVb.js} +54 -16
- package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.D0SlKNbZ.js} +1 -1
- package/dist/chunks/{browser.d.ChKACdzH.d.ts → browser.d.X3SXoOCV.d.ts} +4 -1
- package/dist/chunks/{cac.DVeoLl0M.js → cac.CWGDZnXT.js} +979 -20
- package/dist/chunks/{cli-api.B7PN_QUv.js → cli-api.DuT9iuvY.js} +8764 -7898
- package/dist/chunks/{config.d.Cy95HiCx.d.ts → config.d.EJLVE3es.d.ts} +30 -15
- package/dist/chunks/{console.Cf-YriPC.js → console.3WNpx0tS.js} +3 -2
- package/dist/chunks/{constants.D_Q9UYh-.js → constants.CPYnjOGj.js} +4 -2
- package/dist/chunks/coverage.Bri33R1t.js +1050 -0
- package/dist/chunks/{creator.DAmOKTvJ.js → creator.DgVhQm5q.js} +35 -4
- package/dist/chunks/{defaults.BOqNVLsY.js → defaults.CdU2lD-q.js} +4 -3
- package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.x-ILCfAE.d.ts} +1 -2
- package/dist/chunks/{globals.DOayXfHP.js → globals.BXNGLnTL.js} +11 -10
- package/dist/chunks/{coverage.AVPTjMgw.js → index.BCY_7LL2.js} +5 -959
- package/dist/chunks/{index.C5r1PdPD.js → index.CEzQDJGb.js} +1 -1
- package/dist/chunks/{index.D3XRDfWc.js → index.CMESou6r.js} +26 -1
- package/dist/chunks/{index.6Qv1eEA6.js → index.DGNSnENe.js} +95 -9
- package/dist/chunks/{index.M8mOzt4Y.js → index.DXMFO5MJ.js} +3279 -2914
- package/dist/chunks/{index.Z5E_ObnR.js → index.DlDSLQD3.js} +7 -3
- package/dist/chunks/{index.CyBMJtT7.js → index.EY6TCHpo.js} +10 -8
- package/dist/chunks/{index.D4KonVSU.js → index.og1WyBLx.js} +18 -3
- package/dist/chunks/{init-forks._y3TW739.js → init-forks.DeArv0jT.js} +1 -1
- package/dist/chunks/{init-threads.DBO2kn-p.js → init-threads.-2OUl4Nn.js} +1 -1
- package/dist/chunks/{init.B6MLFIaN.js → init.DICorXCo.js} +52 -13
- package/dist/chunks/native.DPzPHdi5.js +148 -0
- package/dist/chunks/nativeModuleMocker.DndvSdL6.js +206 -0
- package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
- package/dist/chunks/{node.Ce0vMQM7.js → node.COQbm6gK.js} +1 -1
- package/dist/chunks/{plugin.d.CtqpEehP.d.ts → plugin.d.BuW-flqo.d.ts} +1 -1
- package/dist/chunks/{reporters.d.CWXNI2jG.d.ts → reporters.d.DVUYHHhe.d.ts} +328 -79
- package/dist/chunks/rpc.MzXet3jl.js +144 -0
- package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.BFMWpdph.d.ts} +10 -2
- package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.B41N_kPE.js} +3 -3
- package/dist/chunks/{startModuleRunner.DEj0jb3e.js → startVitestModuleRunner.C3ZR-4J3.js} +265 -405
- package/dist/chunks/{suite.d.BJWk38HB.d.ts → suite.d.udJtyAgw.d.ts} +1 -1
- package/dist/chunks/{vi.2VT5v0um.js → test.CTcmp4Su.js} +538 -181
- package/dist/chunks/{utils.DvEY5TfP.js → utils.BX5Fg8C4.js} +8 -1
- package/dist/chunks/{vm.D3epNOPZ.js → vm.Dh2rTtmP.js} +48 -8
- package/dist/chunks/{worker.d.Dyxm8DEL.d.ts → worker.d.B84sVRy0.d.ts} +2 -2
- package/dist/cli.js +6 -5
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
- package/dist/client/__vitest__/assets/index-Di71CKDo.js +63 -0
- package/dist/client/__vitest__/favicon.ico +0 -0
- package/dist/client/__vitest__/favicon.svg +49 -4
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
- package/dist/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +167 -58
- package/dist/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
- package/dist/client/favicon.svg +49 -4
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +20 -13
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +13 -12
- package/dist/config.js +2 -2
- package/dist/context.js +108 -22
- package/dist/coverage.d.ts +12 -8
- package/dist/coverage.js +8 -5
- package/dist/environments.js +3 -1
- package/dist/expect-element.js +23 -23
- package/dist/index-5Pe7X7sp.js +7 -0
- package/dist/index.d.ts +66 -27
- package/dist/index.js +10 -9
- package/dist/locators.d.ts +14 -3
- package/dist/locators.js +1 -1
- package/dist/module-evaluator.d.ts +11 -1
- package/dist/module-evaluator.js +43 -26
- package/dist/node.d.ts +28 -14
- package/dist/node.js +42 -40
- package/dist/nodejs-worker-loader.js +41 -0
- package/dist/plugins/mocker-transforms.mjs +2 -0
- package/dist/plugins/utils-source-map-node.mjs +2 -0
- package/dist/reporters.d.ts +8 -8
- package/dist/reporters.js +7 -5
- package/dist/runners.d.ts +24 -5
- package/dist/runners.js +6 -6
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +35 -0
- package/dist/snapshot.js +4 -2
- package/dist/suite.d.ts +1 -1
- package/dist/suite.js +4 -2
- package/dist/vendor/blazediff_core.d.mts +1 -0
- package/dist/vendor/blazediff_core.mjs +117 -0
- package/dist/vendor/chai.mjs +4 -249
- package/dist/vendor/convert-source-map.d.mts +1 -0
- package/dist/vendor/convert-source-map.mjs +150 -0
- package/dist/vendor/expect-type.d.mts +14 -7
- package/dist/vendor/expect-type.mjs +5 -5
- package/dist/vendor/std-env.d.mts +131 -40
- package/dist/vendor/std-env.mjs +114 -117
- package/dist/worker.d.ts +6 -6
- package/dist/worker.js +27 -21
- package/dist/workers/forks.js +23 -17
- package/dist/workers/runVmTests.js +18 -16
- package/dist/workers/threads.js +23 -17
- package/dist/workers/vmForks.js +15 -12
- package/dist/workers/vmThreads.js +15 -12
- package/globals.d.ts +2 -0
- package/package.json +35 -26
- package/suppress-warnings.cjs +1 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +0 -57
- package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
- package/dist/@vitest/browser/index-D6m36C6U.js +0 -11
- package/dist/@vitest/utils/chunk-_commonjsHelpers.js +0 -5
- package/dist/@vitest/utils/highlight.d.ts +0 -9
- package/dist/@vitest/utils/highlight.js +0 -538
- package/dist/chunks/date.Bq6ZW5rf.js +0 -73
- package/dist/chunks/rpc.BoxB0q7B.js +0 -76
- package/dist/chunks/test.B8ej_ZHS.js +0 -254
- package/dist/client/__vitest__/assets/index-BUCFJtth.js +0 -57
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
- package/dist/index-D6m36C6U.js +0 -6
- package/dist/mocker.d.ts +0 -1
- package/dist/mocker.js +0 -1
- package/dist/module-runner.js +0 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CustomComparatorsRegistry } from '../browser/index.js';
|
|
2
2
|
export { defineBrowserCommand } from '../browser/index.js';
|
|
3
|
-
import { ScreenshotMatcherOptions, ScreenshotComparatorRegistry } from '../browser/index.js';
|
|
3
|
+
import { SelectorOptions, ScreenshotMatcherOptions, ScreenshotComparatorRegistry } from '../browser/index.js';
|
|
4
4
|
import { BrowserProvider, TestProject, CDPSession, BrowserProviderOption } from '../../node.js';
|
|
5
5
|
import { ClickOptions, MoveToOptions, DragAndDropOptions, remote } from 'webdriverio';
|
|
6
6
|
|
|
@@ -39,14 +39,27 @@ declare class WebdriverBrowserProvider implements BrowserProvider {
|
|
|
39
39
|
getCDPSession(_sessionId: string): Promise<CDPSession>;
|
|
40
40
|
}
|
|
41
41
|
declare module "vitest/browser" {
|
|
42
|
-
interface UserEventClickOptions extends Partial<ClickOptions
|
|
43
|
-
interface UserEventHoverOptions extends MoveToOptions {}
|
|
42
|
+
interface UserEventClickOptions extends Partial<ClickOptions>, SelectorOptions {}
|
|
43
|
+
interface UserEventHoverOptions extends MoveToOptions, SelectorOptions {}
|
|
44
44
|
interface UserEventDragAndDropOptions extends DragAndDropOptions {
|
|
45
45
|
sourceX?: number;
|
|
46
46
|
sourceY?: number;
|
|
47
47
|
targetX?: number;
|
|
48
48
|
targetY?: number;
|
|
49
49
|
}
|
|
50
|
+
interface UserEventFillOptions extends SelectorOptions {}
|
|
51
|
+
interface UserEventSelectOptions extends SelectorOptions {}
|
|
52
|
+
interface UserEventClearOptions extends SelectorOptions {}
|
|
53
|
+
interface UserEventDoubleClickOptions extends SelectorOptions {}
|
|
54
|
+
interface UserEventTripleClickOptions extends SelectorOptions {}
|
|
55
|
+
interface UserEventWheelBaseOptions extends SelectorOptions {}
|
|
56
|
+
interface LocatorScreenshotOptions extends SelectorOptions {}
|
|
57
|
+
}
|
|
58
|
+
interface WebdriverCDPSession {
|
|
59
|
+
send: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
60
|
+
on: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
61
|
+
once: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
62
|
+
off: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
50
63
|
}
|
|
51
64
|
declare module "vitest/node" {
|
|
52
65
|
interface BrowserCommandContext {
|
|
@@ -57,6 +70,7 @@ declare module "vitest/node" {
|
|
|
57
70
|
}
|
|
58
71
|
interface ToMatchScreenshotOptions extends Omit<ScreenshotMatcherOptions, "comparatorName" | "comparatorOptions">, CustomComparatorsRegistry {}
|
|
59
72
|
interface ToMatchScreenshotComparators extends ScreenshotComparatorRegistry {}
|
|
73
|
+
interface CDPSession extends WebdriverCDPSession {}
|
|
60
74
|
}
|
|
61
75
|
|
|
62
76
|
export { WebdriverBrowserProvider, webdriverio };
|
|
@@ -367,11 +367,29 @@ const viewport = async (context, options) => {
|
|
|
367
367
|
await context.provider.setViewport(options);
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
+
const wheel = async (context, selector, options) => {
|
|
371
|
+
const browser = context.browser;
|
|
372
|
+
const times = options.times ?? 1;
|
|
373
|
+
const deltaX = options.delta.x ?? 0;
|
|
374
|
+
const deltaY = options.delta.y ?? 0;
|
|
375
|
+
let action = browser.action("wheel");
|
|
376
|
+
const wheelOptions = {
|
|
377
|
+
deltaX,
|
|
378
|
+
deltaY,
|
|
379
|
+
origin: browser.$(selector)
|
|
380
|
+
};
|
|
381
|
+
for (let count = 0; count < times; count += 1) {
|
|
382
|
+
action = action.scroll(wheelOptions);
|
|
383
|
+
}
|
|
384
|
+
await action.perform();
|
|
385
|
+
};
|
|
386
|
+
|
|
370
387
|
var commands = {
|
|
371
388
|
__vitest_upload: upload,
|
|
372
389
|
__vitest_click: click,
|
|
373
390
|
__vitest_dblClick: dblClick,
|
|
374
391
|
__vitest_tripleClick: tripleClick,
|
|
392
|
+
__vitest_wheel: wheel,
|
|
375
393
|
__vitest_takeScreenshot: takeScreenshot,
|
|
376
394
|
__vitest_type: type,
|
|
377
395
|
__vitest_clear: clear,
|
|
@@ -538,8 +556,10 @@ class WebdriverBrowserProvider {
|
|
|
538
556
|
const port = inspector.port || 9229;
|
|
539
557
|
const host = inspector.host || "127.0.0.1";
|
|
540
558
|
args.push(`--remote-debugging-port=${port}`);
|
|
541
|
-
|
|
542
|
-
|
|
559
|
+
if (host !== "localhost" && host !== "127.0.0.1" && host !== "::1") {
|
|
560
|
+
this.project.vitest.logger.warn(`Custom inspector host "${host}" will be ignored. Chrome only allows remote debugging on localhost.`);
|
|
561
|
+
}
|
|
562
|
+
this.project.vitest.logger.log(`Debugger listening on ws://127.0.0.1:${port}`);
|
|
543
563
|
capabilities[key] ??= {};
|
|
544
564
|
capabilities[key].args = args;
|
|
545
565
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { selectorEngine, getByTitleSelector, getByTextSelector, getByPlaceholderSelector, getByAltTextSelector, getByTestIdSelector, getByRoleSelector, getByLabelSelector, Locator, convertElementToCssSelector, getIframeScale } from '../browser/locators.js';
|
|
1
|
+
import { selectorEngine, getByTitleSelector, getByTextSelector, getByPlaceholderSelector, getByAltTextSelector, getByTestIdSelector, getByRoleSelector, getByLabelSelector, Locator, convertElementToCssSelector, ensureAwaited, triggerCommandWithTrace, getIframeScale } from '../browser/locators.js';
|
|
2
2
|
import { page } from '../browser/context.js';
|
|
3
3
|
import { utils } from '../browser/index.js';
|
|
4
4
|
import { __INTERNAL } from '../../browser.js';
|
|
@@ -9,6 +9,12 @@ class WebdriverIOLocator extends Locator {
|
|
|
9
9
|
this._pwSelector = _pwSelector;
|
|
10
10
|
this._container = _container;
|
|
11
11
|
}
|
|
12
|
+
// This exists to avoid calling `this.elements` in `this.selector`'s getter in interactive actions
|
|
13
|
+
withElement(element, error) {
|
|
14
|
+
const pwSelector = selectorEngine.generateSelectorSimple(element);
|
|
15
|
+
const cssSelector = convertElementToCssSelector(element);
|
|
16
|
+
return new ElementWebdriverIOLocator(cssSelector, error, pwSelector, element);
|
|
17
|
+
}
|
|
12
18
|
get selector() {
|
|
13
19
|
const selectors = this.elements().map((element) => convertElementToCssSelector(element));
|
|
14
20
|
if (!selectors.length) {
|
|
@@ -25,24 +31,75 @@ class WebdriverIOLocator extends Locator {
|
|
|
25
31
|
return (hasShadowRoot ? ">>>" : "") + newSelectors.join(", ");
|
|
26
32
|
}
|
|
27
33
|
click(options) {
|
|
28
|
-
return
|
|
34
|
+
return ensureAwaited(async (error) => {
|
|
35
|
+
const element = await this.findElement(options);
|
|
36
|
+
return this.withElement(element, error).click(processClickOptions(options));
|
|
37
|
+
});
|
|
29
38
|
}
|
|
30
39
|
dblClick(options) {
|
|
31
|
-
return
|
|
40
|
+
return ensureAwaited(async (error) => {
|
|
41
|
+
const element = await this.findElement(options);
|
|
42
|
+
return this.withElement(element, error).dblClick(processClickOptions(options));
|
|
43
|
+
});
|
|
32
44
|
}
|
|
33
45
|
tripleClick(options) {
|
|
34
|
-
return
|
|
46
|
+
return ensureAwaited(async (error) => {
|
|
47
|
+
const element = await this.findElement(options);
|
|
48
|
+
return this.withElement(element, error).tripleClick(processClickOptions(options));
|
|
49
|
+
});
|
|
35
50
|
}
|
|
36
51
|
selectOptions(value, options) {
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
return ensureAwaited(async (error) => {
|
|
53
|
+
const element = await this.findElement(options);
|
|
54
|
+
const values = getWebdriverioSelectOptions(element, value);
|
|
55
|
+
return triggerCommandWithTrace({
|
|
56
|
+
name: "__vitest_selectOptions",
|
|
57
|
+
arguments: [
|
|
58
|
+
convertElementToCssSelector(element),
|
|
59
|
+
values,
|
|
60
|
+
options
|
|
61
|
+
],
|
|
62
|
+
errorSource: error
|
|
63
|
+
});
|
|
64
|
+
});
|
|
39
65
|
}
|
|
40
66
|
hover(options) {
|
|
41
|
-
return
|
|
67
|
+
return ensureAwaited(async (error) => {
|
|
68
|
+
const element = await this.findElement(options);
|
|
69
|
+
return this.withElement(element, error).hover(processHoverOptions(options));
|
|
70
|
+
});
|
|
42
71
|
}
|
|
43
72
|
dropTo(target, options) {
|
|
73
|
+
// playwright doesn't enforce a single element, it selects the first one,
|
|
74
|
+
// so we just follow the behavior
|
|
44
75
|
return super.dropTo(target, processDragAndDropOptions(options));
|
|
45
76
|
}
|
|
77
|
+
wheel(options) {
|
|
78
|
+
return ensureAwaited(async (error) => {
|
|
79
|
+
const element = await this.findElement(options);
|
|
80
|
+
return this.withElement(element, error).wheel(options);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
clear(options) {
|
|
84
|
+
return ensureAwaited(async (error) => {
|
|
85
|
+
const element = await this.findElement(options);
|
|
86
|
+
return this.withElement(element, error).clear(options);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
fill(text, options) {
|
|
90
|
+
return ensureAwaited(async (error) => {
|
|
91
|
+
const element = await this.findElement(options);
|
|
92
|
+
return this.withElement(element, error).fill(text, options);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
screenshot(options) {
|
|
96
|
+
return ensureAwaited(async (error) => {
|
|
97
|
+
const element = await this.findElement(options);
|
|
98
|
+
return this.withElement(element, error).screenshot(options);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// playwright doesn't enforce a single element in upload
|
|
102
|
+
// public override async upload(): Promise<void>
|
|
46
103
|
locator(selector) {
|
|
47
104
|
return new WebdriverIOLocator(`${this._pwSelector} >> ${selector}`, this._container);
|
|
48
105
|
}
|
|
@@ -50,6 +107,26 @@ class WebdriverIOLocator extends Locator {
|
|
|
50
107
|
return new WebdriverIOLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
51
108
|
}
|
|
52
109
|
}
|
|
110
|
+
const kElementLocator = Symbol.for("$$vitest:locator-resolved");
|
|
111
|
+
class ElementWebdriverIOLocator extends Locator {
|
|
112
|
+
[kElementLocator] = true;
|
|
113
|
+
constructor(_cssSelector, _errorSource, _pwSelector, _container) {
|
|
114
|
+
super();
|
|
115
|
+
this._cssSelector = _cssSelector;
|
|
116
|
+
this._errorSource = _errorSource;
|
|
117
|
+
this._pwSelector = _pwSelector;
|
|
118
|
+
this._container = _container;
|
|
119
|
+
}
|
|
120
|
+
get selector() {
|
|
121
|
+
return this._cssSelector;
|
|
122
|
+
}
|
|
123
|
+
locator(_selector) {
|
|
124
|
+
throw new Error(`should not be called`);
|
|
125
|
+
}
|
|
126
|
+
elementLocator(_element) {
|
|
127
|
+
throw new Error(`should not be called`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
53
130
|
page.extend({
|
|
54
131
|
getByLabelText(text, options) {
|
|
55
132
|
return new WebdriverIOLocator(getByLabelSelector(text, options));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="chai" />
|
|
2
2
|
import { Test } from '../runner/index.js';
|
|
3
3
|
import { MockInstance } from '../spy/index.js';
|
|
4
|
-
import { Constructable } from '../utils/index.js';
|
|
5
4
|
import { Formatter } from '../../vendor/tinyrainbow.mjs';
|
|
6
5
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
6
|
import { diff, printDiffOrStringify } from '../utils/diff.js';
|
|
@@ -10,11 +9,6 @@ import { stringify } from '../utils/display.js';
|
|
|
10
9
|
import * as chai from '../../vendor/chai.mjs';
|
|
11
10
|
export { chai };
|
|
12
11
|
|
|
13
|
-
declare const MATCHERS_OBJECT: unique symbol;
|
|
14
|
-
declare const JEST_MATCHERS_OBJECT: unique symbol;
|
|
15
|
-
declare const GLOBAL_EXPECT: unique symbol;
|
|
16
|
-
declare const ASYMMETRIC_MATCHERS_OBJECT: unique symbol;
|
|
17
|
-
|
|
18
12
|
interface AsymmetricMatcherInterface {
|
|
19
13
|
asymmetricMatch: (other: unknown, customTesters?: Array<Tester>) => boolean;
|
|
20
14
|
toString: () => string;
|
|
@@ -132,9 +126,18 @@ interface MatcherState {
|
|
|
132
126
|
customTesters: Array<Tester>;
|
|
133
127
|
assertionCalls: number;
|
|
134
128
|
currentTestName?: string;
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated exists only in types
|
|
131
|
+
*/
|
|
135
132
|
dontThrow?: () => void;
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated exists only in types
|
|
135
|
+
*/
|
|
136
136
|
error?: Error;
|
|
137
137
|
equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated exists only in types
|
|
140
|
+
*/
|
|
138
141
|
expand?: boolean;
|
|
139
142
|
expectedAssertionsNumber?: number | null;
|
|
140
143
|
expectedAssertionsNumberErrorGen?: (() => Error) | null;
|
|
@@ -142,6 +145,9 @@ interface MatcherState {
|
|
|
142
145
|
isExpectingAssertionsError?: Error | null;
|
|
143
146
|
isNot: boolean;
|
|
144
147
|
promise: string;
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated exists only in types
|
|
150
|
+
*/
|
|
145
151
|
suppressedErrors: Array<Error>;
|
|
146
152
|
testPath?: string;
|
|
147
153
|
utils: ReturnType<typeof getMatcherUtils> & {
|
|
@@ -235,8 +241,6 @@ interface AsymmetricMatchersContaining extends CustomMatcher {
|
|
|
235
241
|
/**
|
|
236
242
|
* Matches if the received number is within a certain precision of the expected number.
|
|
237
243
|
*
|
|
238
|
-
* @param precision - Optional decimal precision for comparison. Default is 2.
|
|
239
|
-
*
|
|
240
244
|
* @example
|
|
241
245
|
* expect(10.45).toEqual(expect.closeTo(10.5, 1));
|
|
242
246
|
* expect(5.11).toEqual(expect.closeTo(5.12)); // with default precision
|
|
@@ -453,6 +457,7 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
453
457
|
*
|
|
454
458
|
* @example
|
|
455
459
|
* expect(mockFunc).toBeCalledTimes(2);
|
|
460
|
+
* @deprecated Use `toHaveBeenCalledTimes` instead
|
|
456
461
|
*/
|
|
457
462
|
toBeCalledTimes: (times: number) => void;
|
|
458
463
|
/**
|
|
@@ -471,6 +476,7 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
471
476
|
*
|
|
472
477
|
* @example
|
|
473
478
|
* expect(mockFunc).toBeCalled();
|
|
479
|
+
* @deprecated Use `toHaveBeenCalled` instead
|
|
474
480
|
*/
|
|
475
481
|
toBeCalled: () => void;
|
|
476
482
|
/**
|
|
@@ -489,6 +495,7 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
489
495
|
*
|
|
490
496
|
* @example
|
|
491
497
|
* expect(mockFunc).toBeCalledWith('arg1', 42);
|
|
498
|
+
* @deprecated Use `toHaveBeenCalledWith` instead
|
|
492
499
|
*/
|
|
493
500
|
toBeCalledWith: <E extends any[]>(...args: E) => void;
|
|
494
501
|
/**
|
|
@@ -501,15 +508,6 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
501
508
|
*/
|
|
502
509
|
toHaveBeenNthCalledWith: <E extends any[]>(n: number, ...args: E) => void;
|
|
503
510
|
/**
|
|
504
|
-
* Ensure that a mock function is called with specific arguments on an Nth call.
|
|
505
|
-
*
|
|
506
|
-
* Alias for `expect.toHaveBeenNthCalledWith`.
|
|
507
|
-
*
|
|
508
|
-
* @example
|
|
509
|
-
* expect(mockFunc).nthCalledWith(2, 'secondArg');
|
|
510
|
-
*/
|
|
511
|
-
nthCalledWith: <E extends any[]>(nthCall: number, ...args: E) => void;
|
|
512
|
-
/**
|
|
513
511
|
* If you have a mock function, you can use `.toHaveBeenLastCalledWith`
|
|
514
512
|
* to test what arguments it was last called with.
|
|
515
513
|
*
|
|
@@ -520,16 +518,6 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
520
518
|
*/
|
|
521
519
|
toHaveBeenLastCalledWith: <E extends any[]>(...args: E) => void;
|
|
522
520
|
/**
|
|
523
|
-
* If you have a mock function, you can use `.lastCalledWith`
|
|
524
|
-
* to test what arguments it was last called with.
|
|
525
|
-
*
|
|
526
|
-
* Alias for `expect.toHaveBeenLastCalledWith`.
|
|
527
|
-
*
|
|
528
|
-
* @example
|
|
529
|
-
* expect(mockFunc).lastCalledWith('lastArg');
|
|
530
|
-
*/
|
|
531
|
-
lastCalledWith: <E extends any[]>(...args: E) => void;
|
|
532
|
-
/**
|
|
533
521
|
* Used to test that a function throws when it is called.
|
|
534
522
|
*
|
|
535
523
|
* Also under the alias `expect.toThrowError`.
|
|
@@ -537,8 +525,9 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
537
525
|
* @example
|
|
538
526
|
* expect(() => functionWithError()).toThrow('Error message');
|
|
539
527
|
* expect(() => parseJSON('invalid')).toThrow(SyntaxError);
|
|
528
|
+
* expect(() => { throw 42 }).toThrow(42);
|
|
540
529
|
*/
|
|
541
|
-
toThrow: (expected?:
|
|
530
|
+
toThrow: (expected?: any) => void;
|
|
542
531
|
/**
|
|
543
532
|
* Used to test that a function throws when it is called.
|
|
544
533
|
*
|
|
@@ -547,8 +536,10 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
547
536
|
* @example
|
|
548
537
|
* expect(() => functionWithError()).toThrowError('Error message');
|
|
549
538
|
* expect(() => parseJSON('invalid')).toThrowError(SyntaxError);
|
|
539
|
+
* expect(() => { throw 42 }).toThrowError(42);
|
|
540
|
+
* @deprecated Use `toThrow` instead
|
|
550
541
|
*/
|
|
551
|
-
toThrowError: (expected?:
|
|
542
|
+
toThrowError: (expected?: any) => void;
|
|
552
543
|
/**
|
|
553
544
|
* Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
|
|
554
545
|
*
|
|
@@ -556,6 +547,7 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
556
547
|
*
|
|
557
548
|
* @example
|
|
558
549
|
* expect(mockFunc).toReturn();
|
|
550
|
+
* @deprecated Use `toHaveReturned` instead
|
|
559
551
|
*/
|
|
560
552
|
toReturn: () => void;
|
|
561
553
|
/**
|
|
@@ -575,6 +567,7 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
575
567
|
*
|
|
576
568
|
* @example
|
|
577
569
|
* expect(mockFunc).toReturnTimes(3);
|
|
570
|
+
* @deprecated Use `toHaveReturnedTimes` instead
|
|
578
571
|
*/
|
|
579
572
|
toReturnTimes: (times: number) => void;
|
|
580
573
|
/**
|
|
@@ -594,6 +587,7 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
594
587
|
*
|
|
595
588
|
* @example
|
|
596
589
|
* expect(mockFunc).toReturnWith('returnValue');
|
|
590
|
+
* @deprecated Use `toHaveReturnedWith` instead
|
|
597
591
|
*/
|
|
598
592
|
toReturnWith: <E>(value: E) => void;
|
|
599
593
|
/**
|
|
@@ -617,17 +611,6 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
617
611
|
*/
|
|
618
612
|
toHaveLastReturnedWith: <E>(value: E) => void;
|
|
619
613
|
/**
|
|
620
|
-
* Use to test the specific value that a mock function last returned.
|
|
621
|
-
* If the last call to the mock function threw an error, then this matcher will fail
|
|
622
|
-
* no matter what value you provided as the expected return value.
|
|
623
|
-
*
|
|
624
|
-
* Alias for `expect.toHaveLastReturnedWith`.
|
|
625
|
-
*
|
|
626
|
-
* @example
|
|
627
|
-
* expect(mockFunc).lastReturnedWith('lastValue');
|
|
628
|
-
*/
|
|
629
|
-
lastReturnedWith: <E>(value: E) => void;
|
|
630
|
-
/**
|
|
631
614
|
* Use to test the specific value that a mock function returned for the nth call.
|
|
632
615
|
* If the nth call to the mock function threw an error, then this matcher will fail
|
|
633
616
|
* no matter what value you provided as the expected return value.
|
|
@@ -638,17 +621,6 @@ interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
|
|
|
638
621
|
* expect(mockFunc).toHaveNthReturnedWith(2, 'nthValue');
|
|
639
622
|
*/
|
|
640
623
|
toHaveNthReturnedWith: <E>(nthCall: number, value: E) => void;
|
|
641
|
-
/**
|
|
642
|
-
* Use to test the specific value that a mock function returned for the nth call.
|
|
643
|
-
* If the nth call to the mock function threw an error, then this matcher will fail
|
|
644
|
-
* no matter what value you provided as the expected return value.
|
|
645
|
-
*
|
|
646
|
-
* Alias for `expect.toHaveNthReturnedWith`.
|
|
647
|
-
*
|
|
648
|
-
* @example
|
|
649
|
-
* expect(mockFunc).nthReturnedWith(2, 'nthValue');
|
|
650
|
-
*/
|
|
651
|
-
nthReturnedWith: <E>(nthCall: number, value: E) => void;
|
|
652
624
|
}
|
|
653
625
|
type VitestAssertion<
|
|
654
626
|
A,
|
|
@@ -656,7 +628,7 @@ type VitestAssertion<
|
|
|
656
628
|
> = { [K in keyof A] : A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T> } & ((type: string, message?: string) => Assertion);
|
|
657
629
|
type Promisify<O> = { [K in keyof O] : O[K] extends (...args: infer A) => infer R ? Promisify<O[K]> & ((...args: A) => Promise<R>) : O[K] };
|
|
658
630
|
type PromisifyAssertion<T> = Promisify<Assertion<T>>;
|
|
659
|
-
interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T>, Matchers<T> {
|
|
631
|
+
interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T>, ChaiMockAssertion, Matchers<T> {
|
|
660
632
|
/**
|
|
661
633
|
* Ensures a value is of a specific type.
|
|
662
634
|
*
|
|
@@ -760,6 +732,140 @@ interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAss
|
|
|
760
732
|
*/
|
|
761
733
|
rejects: PromisifyAssertion<T>;
|
|
762
734
|
}
|
|
735
|
+
/**
|
|
736
|
+
* Chai-style assertions for spy/mock testing.
|
|
737
|
+
* These provide sinon-chai compatible assertion names that delegate to Jest-style implementations.
|
|
738
|
+
*/
|
|
739
|
+
interface ChaiMockAssertion {
|
|
740
|
+
/**
|
|
741
|
+
* Checks that a spy was called at least once.
|
|
742
|
+
* Chai-style equivalent of `toHaveBeenCalled`.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* expect(spy).to.have.been.called
|
|
746
|
+
*/
|
|
747
|
+
readonly called: Assertion;
|
|
748
|
+
/**
|
|
749
|
+
* Checks that a spy was called a specific number of times.
|
|
750
|
+
* Chai-style equivalent of `toHaveBeenCalledTimes`.
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* expect(spy).to.have.callCount(3)
|
|
754
|
+
*/
|
|
755
|
+
callCount: (count: number) => void;
|
|
756
|
+
/**
|
|
757
|
+
* Checks that a spy was called with specific arguments at least once.
|
|
758
|
+
* Chai-style equivalent of `toHaveBeenCalledWith`.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* expect(spy).to.have.been.calledWith('arg1', 'arg2')
|
|
762
|
+
*/
|
|
763
|
+
calledWith: <E extends any[]>(...args: E) => void;
|
|
764
|
+
/**
|
|
765
|
+
* Checks that a spy was called exactly once.
|
|
766
|
+
* Chai-style equivalent of `toHaveBeenCalledOnce`.
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* expect(spy).to.have.been.calledOnce
|
|
770
|
+
*/
|
|
771
|
+
readonly calledOnce: Assertion;
|
|
772
|
+
/**
|
|
773
|
+
* Checks that a spy was called exactly once with specific arguments.
|
|
774
|
+
* Chai-style equivalent of `toHaveBeenCalledExactlyOnceWith`.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* expect(spy).to.have.been.calledOnceWith('arg1', 'arg2')
|
|
778
|
+
*/
|
|
779
|
+
calledOnceWith: <E extends any[]>(...args: E) => void;
|
|
780
|
+
/**
|
|
781
|
+
* Checks that the last call to a spy was made with specific arguments.
|
|
782
|
+
* Chai-style equivalent of `toHaveBeenLastCalledWith`.
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* expect(spy).to.have.been.lastCalledWith('arg1', 'arg2')
|
|
786
|
+
*/
|
|
787
|
+
lastCalledWith: <E extends any[]>(...args: E) => void;
|
|
788
|
+
/**
|
|
789
|
+
* Checks that the nth call to a spy was made with specific arguments.
|
|
790
|
+
* Chai-style equivalent of `toHaveBeenNthCalledWith`.
|
|
791
|
+
*
|
|
792
|
+
* @example
|
|
793
|
+
* expect(spy).to.have.been.nthCalledWith(2, 'arg1', 'arg2')
|
|
794
|
+
*/
|
|
795
|
+
nthCalledWith: <E extends any[]>(n: number, ...args: E) => void;
|
|
796
|
+
/**
|
|
797
|
+
* Checks that a spy returned successfully at least once.
|
|
798
|
+
* Chai-style equivalent of `toHaveReturned`.
|
|
799
|
+
*
|
|
800
|
+
* @example
|
|
801
|
+
* expect(spy).to.have.returned
|
|
802
|
+
*/
|
|
803
|
+
readonly returned: Assertion;
|
|
804
|
+
/**
|
|
805
|
+
* Checks that a spy returned a specific value at least once.
|
|
806
|
+
* Chai-style equivalent of `toHaveReturnedWith`.
|
|
807
|
+
*
|
|
808
|
+
* @example
|
|
809
|
+
* expect(spy).to.have.returnedWith('value')
|
|
810
|
+
*/
|
|
811
|
+
returnedWith: <E>(value: E) => void;
|
|
812
|
+
/**
|
|
813
|
+
* Checks that a spy returned successfully a specific number of times.
|
|
814
|
+
* Chai-style equivalent of `toHaveReturnedTimes`.
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* expect(spy).to.have.returnedTimes(3)
|
|
818
|
+
*/
|
|
819
|
+
returnedTimes: (count: number) => void;
|
|
820
|
+
/**
|
|
821
|
+
* Checks that the last return value of a spy matches the expected value.
|
|
822
|
+
* Chai-style equivalent of `toHaveLastReturnedWith`.
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* expect(spy).to.have.lastReturnedWith('value')
|
|
826
|
+
*/
|
|
827
|
+
lastReturnedWith: <E>(value: E) => void;
|
|
828
|
+
/**
|
|
829
|
+
* Checks that the nth return value of a spy matches the expected value.
|
|
830
|
+
* Chai-style equivalent of `toHaveNthReturnedWith`.
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* expect(spy).to.have.nthReturnedWith(2, 'value')
|
|
834
|
+
*/
|
|
835
|
+
nthReturnedWith: <E>(n: number, value: E) => void;
|
|
836
|
+
/**
|
|
837
|
+
* Checks that a spy was called before another spy.
|
|
838
|
+
* Chai-style equivalent of `toHaveBeenCalledBefore`.
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* expect(spy1).to.have.been.calledBefore(spy2)
|
|
842
|
+
*/
|
|
843
|
+
calledBefore: (mock: MockInstance, failIfNoFirstInvocation?: boolean) => void;
|
|
844
|
+
/**
|
|
845
|
+
* Checks that a spy was called after another spy.
|
|
846
|
+
* Chai-style equivalent of `toHaveBeenCalledAfter`.
|
|
847
|
+
*
|
|
848
|
+
* @example
|
|
849
|
+
* expect(spy1).to.have.been.calledAfter(spy2)
|
|
850
|
+
*/
|
|
851
|
+
calledAfter: (mock: MockInstance, failIfNoFirstInvocation?: boolean) => void;
|
|
852
|
+
/**
|
|
853
|
+
* Checks that a spy was called exactly twice.
|
|
854
|
+
* Chai-style equivalent of `toHaveBeenCalledTimes(2)`.
|
|
855
|
+
*
|
|
856
|
+
* @example
|
|
857
|
+
* expect(spy).to.have.been.calledTwice
|
|
858
|
+
*/
|
|
859
|
+
readonly calledTwice: Assertion;
|
|
860
|
+
/**
|
|
861
|
+
* Checks that a spy was called exactly three times.
|
|
862
|
+
* Chai-style equivalent of `toHaveBeenCalledTimes(3)`.
|
|
863
|
+
*
|
|
864
|
+
* @example
|
|
865
|
+
* expect(spy).to.have.been.calledThrice
|
|
866
|
+
*/
|
|
867
|
+
readonly calledThrice: Assertion;
|
|
868
|
+
}
|
|
763
869
|
declare global {
|
|
764
870
|
namespace jest {
|
|
765
871
|
interface Matchers<
|
|
@@ -769,6 +875,13 @@ declare global {
|
|
|
769
875
|
}
|
|
770
876
|
}
|
|
771
877
|
|
|
878
|
+
declare const ChaiStyleAssertions: ChaiPlugin;
|
|
879
|
+
|
|
880
|
+
declare const MATCHERS_OBJECT: unique symbol;
|
|
881
|
+
declare const JEST_MATCHERS_OBJECT: unique symbol;
|
|
882
|
+
declare const GLOBAL_EXPECT: unique symbol;
|
|
883
|
+
declare const ASYMMETRIC_MATCHERS_OBJECT: unique symbol;
|
|
884
|
+
|
|
772
885
|
declare const customMatchers: MatchersObject;
|
|
773
886
|
|
|
774
887
|
declare const JestChaiExpect: ChaiPlugin;
|
|
@@ -778,6 +891,7 @@ declare const JestExtend: ChaiPlugin;
|
|
|
778
891
|
declare function equals(a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean): boolean;
|
|
779
892
|
declare function isAsymmetric(obj: any): obj is AsymmetricMatcher<any>;
|
|
780
893
|
declare function hasAsymmetric(obj: any, seen?: Set<any>): boolean;
|
|
894
|
+
declare function isError(value: unknown): value is Error;
|
|
781
895
|
declare function isA(typeName: string, value: unknown): boolean;
|
|
782
896
|
declare function fnNameFor(func: Function): string;
|
|
783
897
|
declare function hasProperty(obj: object | null, property: string): boolean;
|
|
@@ -803,5 +917,9 @@ declare function isStandardSchema(obj: any): obj is StandardSchemaV1;
|
|
|
803
917
|
declare function getState<State extends MatcherState = MatcherState>(expect: ExpectStatic): State;
|
|
804
918
|
declare function setState<State extends MatcherState = MatcherState>(state: Partial<State>, expect: ExpectStatic): void;
|
|
805
919
|
|
|
806
|
-
|
|
807
|
-
|
|
920
|
+
declare function createAssertionMessage(util: Chai.ChaiUtils, assertion: Assertion, hasArgs: boolean): string;
|
|
921
|
+
declare function recordAsyncExpect(_test: any, promise: Promise<any>, assertion: string, error: Error, isSoft?: boolean): Promise<any>;
|
|
922
|
+
declare function wrapAssertion(utils: Chai.ChaiUtils, name: string, fn: (this: Chai.AssertionStatic & Assertion, ...args: any[]) => void | PromiseLike<void>): (this: Chai.AssertionStatic & Assertion, ...args: any[]) => void | PromiseLike<void>;
|
|
923
|
+
|
|
924
|
+
export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, AsymmetricMatcher, ChaiStyleAssertions, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, ObjectContaining, SchemaMatching, StringContaining, StringMatching, addCustomEqualityTesters, arrayBufferEquality, createAssertionMessage, customMatchers, equals, fnNameFor, generateToBeMessage, getObjectKeys, getObjectSubset, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isError, isImmutableUnorderedKeyed, isImmutableUnorderedSet, isStandardSchema, iterableEquality, pluralize, recordAsyncExpect, setState, sparseArrayEquality, subsetEquality, typeEquality, wrapAssertion };
|
|
925
|
+
export type { Assertion, AsymmetricMatcherInterface, AsymmetricMatchersContaining, AsyncExpectationResult, ChaiMockAssertion, ChaiPlugin, DeeplyAllowMatchers, ExpectStatic, ExpectationResult, JestAssertion, MatcherHintOptions, MatcherState, Matchers, MatchersObject, PromisifyAssertion, RawMatcherFn, SyncExpectationResult, Tester, TesterContext };
|