@voidzero-dev/vite-plus-test 0.0.0-0bfcc90f.20260209-0731
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 +691 -0
- package/browser/context.d.ts +4 -0
- package/browser/context.js +20 -0
- package/config.d.ts +3 -0
- package/coverage.d.ts +1 -0
- package/dist/@vitest/browser/client/.vite/manifest.json +24 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/@vitest/browser/client/__vitest__/bg.png +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.svg +5 -0
- package/dist/@vitest/browser/client/__vitest__/index.html +32 -0
- package/dist/@vitest/browser/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/@vitest/browser/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/@vitest/browser/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/@vitest/browser/client/error-catcher.js +82 -0
- package/dist/@vitest/browser/client/esm-client-injector.js +67 -0
- package/dist/@vitest/browser/client/favicon.svg +5 -0
- package/dist/@vitest/browser/client/orchestrator.html +35 -0
- package/dist/@vitest/browser/client/tester/tester.html +13 -0
- package/dist/@vitest/browser/client.js +456 -0
- package/dist/@vitest/browser/context.d.ts +792 -0
- package/dist/@vitest/browser/context.js +541 -0
- package/dist/@vitest/browser/expect-element.js +32 -0
- package/dist/@vitest/browser/index-D6m36C6U.js +11 -0
- package/dist/@vitest/browser/index.d.ts +73 -0
- package/dist/@vitest/browser/index.js +3513 -0
- package/dist/@vitest/browser/jest-dom.d.ts +724 -0
- package/dist/@vitest/browser/locators.d.ts +354 -0
- package/dist/@vitest/browser/locators.js +1 -0
- package/dist/@vitest/browser/matchers.d.ts +29 -0
- package/dist/@vitest/browser/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/@vitest/browser/state.js +280 -0
- package/dist/@vitest/browser/types.d.ts +69 -0
- package/dist/@vitest/browser-playwright/context.d.ts +1 -0
- package/dist/@vitest/browser-playwright/index.d.ts +106 -0
- package/dist/@vitest/browser-playwright/index.js +1111 -0
- package/dist/@vitest/browser-playwright/locators.js +114 -0
- package/dist/@vitest/browser-preview/context.d.ts +1 -0
- package/dist/@vitest/browser-preview/index.d.ts +19 -0
- package/dist/@vitest/browser-preview/index.js +148 -0
- package/dist/@vitest/browser-preview/locators.js +79 -0
- package/dist/@vitest/browser-webdriverio/context.d.ts +1 -0
- package/dist/@vitest/browser-webdriverio/index.d.ts +63 -0
- package/dist/@vitest/browser-webdriverio/index.js +600 -0
- package/dist/@vitest/browser-webdriverio/locators.js +163 -0
- package/dist/@vitest/expect/index.d.ts +807 -0
- package/dist/@vitest/expect/index.js +1875 -0
- package/dist/@vitest/mocker/auto-register.d.ts +2 -0
- package/dist/@vitest/mocker/auto-register.js +9 -0
- package/dist/@vitest/mocker/automock.d.ts +12 -0
- package/dist/@vitest/mocker/automock.js +1 -0
- package/dist/@vitest/mocker/browser.d.ts +53 -0
- package/dist/@vitest/mocker/browser.js +91 -0
- package/dist/@vitest/mocker/chunk-automock.js +354 -0
- package/dist/@vitest/mocker/chunk-interceptor-native.js +15 -0
- package/dist/@vitest/mocker/chunk-mocker.js +521 -0
- package/dist/@vitest/mocker/chunk-pathe.M-eThtNZ.js +174 -0
- package/dist/@vitest/mocker/chunk-registry.js +185 -0
- package/dist/@vitest/mocker/chunk-utils.js +16 -0
- package/dist/@vitest/mocker/index.d-C-sLYZi-.d.ts +25 -0
- package/dist/@vitest/mocker/index.d.ts +2 -0
- package/dist/@vitest/mocker/index.js +185 -0
- package/dist/@vitest/mocker/mocker.d-TnKRhz7N.d.ts +81 -0
- package/dist/@vitest/mocker/node.d.ts +800 -0
- package/dist/@vitest/mocker/node.js +966 -0
- package/dist/@vitest/mocker/redirect.d.ts +3 -0
- package/dist/@vitest/mocker/redirect.js +79 -0
- package/dist/@vitest/mocker/register.d.ts +9 -0
- package/dist/@vitest/mocker/register.js +41 -0
- package/dist/@vitest/mocker/types.d-B8CCKmHt.d.ts +107 -0
- package/dist/@vitest/pretty-format/index.d.ts +124 -0
- package/dist/@vitest/pretty-format/index.js +1022 -0
- package/dist/@vitest/runner/chunk-tasks.js +340 -0
- package/dist/@vitest/runner/index.d.ts +180 -0
- package/dist/@vitest/runner/index.js +2114 -0
- package/dist/@vitest/runner/tasks.d-C7UxawJ9.d.ts +834 -0
- package/dist/@vitest/runner/types.d.ts +183 -0
- package/dist/@vitest/runner/types.js +1 -0
- package/dist/@vitest/runner/utils.d.ts +45 -0
- package/dist/@vitest/runner/utils.js +5 -0
- package/dist/@vitest/snapshot/environment.d-DHdQ1Csl.d.ts +22 -0
- package/dist/@vitest/snapshot/environment.d.ts +16 -0
- package/dist/@vitest/snapshot/environment.js +40 -0
- package/dist/@vitest/snapshot/index.d.ts +130 -0
- package/dist/@vitest/snapshot/index.js +1437 -0
- package/dist/@vitest/snapshot/manager.d.ts +18 -0
- package/dist/@vitest/snapshot/manager.js +73 -0
- package/dist/@vitest/snapshot/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/dist/@vitest/spy/index.d.ts +384 -0
- package/dist/@vitest/spy/index.js +433 -0
- package/dist/@vitest/utils/chunk-_commonjsHelpers.js +5 -0
- package/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +156 -0
- package/dist/@vitest/utils/constants.d.ts +21 -0
- package/dist/@vitest/utils/constants.js +49 -0
- package/dist/@vitest/utils/diff.d.ts +93 -0
- package/dist/@vitest/utils/diff.js +2199 -0
- package/dist/@vitest/utils/display.d.ts +29 -0
- package/dist/@vitest/utils/display.js +742 -0
- package/dist/@vitest/utils/error.d.ts +7 -0
- package/dist/@vitest/utils/error.js +42 -0
- package/dist/@vitest/utils/helpers.d.ts +73 -0
- package/dist/@vitest/utils/helpers.js +295 -0
- package/dist/@vitest/utils/highlight.d.ts +9 -0
- package/dist/@vitest/utils/highlight.js +538 -0
- package/dist/@vitest/utils/index.d.ts +5 -0
- package/dist/@vitest/utils/index.js +1 -0
- package/dist/@vitest/utils/offset.d.ts +5 -0
- package/dist/@vitest/utils/offset.js +32 -0
- package/dist/@vitest/utils/resolver.d.ts +7 -0
- package/dist/@vitest/utils/resolver.js +71 -0
- package/dist/@vitest/utils/serialize.d.ts +3 -0
- package/dist/@vitest/utils/serialize.js +118 -0
- package/dist/@vitest/utils/source-map.d.ts +55 -0
- package/dist/@vitest/utils/source-map.js +478 -0
- package/dist/@vitest/utils/timers.d.ts +33 -0
- package/dist/@vitest/utils/timers.js +49 -0
- package/dist/@vitest/utils/types.d-BCElaP-c.d.ts +53 -0
- package/dist/@vitest/utils/types.d.ts +34 -0
- package/dist/@vitest/utils/types.js +1 -0
- package/dist/browser-compat.js +3 -0
- package/dist/browser.d.ts +46 -0
- package/dist/browser.js +20 -0
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/chunks/base.CJ0Y4ePK.js +165 -0
- package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
- package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
- package/dist/chunks/cac.DVeoLl0M.js +1409 -0
- package/dist/chunks/cli-api.B7PN_QUv.js +13672 -0
- package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/constants.D_Q9UYh-.js +36 -0
- package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
- package/dist/chunks/coverage.D_JHT54q.js +25 -0
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
- package/dist/chunks/creator.DAmOKTvJ.js +673 -0
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/defaults.BOqNVLsY.js +74 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
- package/dist/chunks/git.Bm2pzPAa.js +71 -0
- package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
- package/dist/chunks/globals.DOayXfHP.js +30 -0
- package/dist/chunks/index.6Qv1eEA6.js +109 -0
- package/dist/chunks/index.C5r1PdPD.js +231 -0
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/index.CyBMJtT7.js +727 -0
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/index.D4KonVSU.js +6343 -0
- package/dist/chunks/index.M8mOzt4Y.js +3839 -0
- package/dist/chunks/index.Z5E_ObnR.js +37 -0
- package/dist/chunks/init-forks._y3TW739.js +41 -0
- package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
- package/dist/chunks/init.B6MLFIaN.js +334 -0
- package/dist/chunks/inspector.CvyFGlXm.js +53 -0
- package/dist/chunks/modules.BJuCwlRJ.js +36 -0
- package/dist/chunks/node.Ce0vMQM7.js +14 -0
- package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
- package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
- package/dist/chunks/rpc.BoxB0q7B.js +76 -0
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
- package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
- package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
- package/dist/chunks/test.B8ej_ZHS.js +254 -0
- package/dist/chunks/traces.CCmnQaNT.js +217 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/utils.DvEY5TfP.js +52 -0
- package/dist/chunks/vi.2VT5v0um.js +3919 -0
- package/dist/chunks/vm.D3epNOPZ.js +744 -0
- package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
- package/dist/cli.js +28 -0
- package/dist/client/.vite/manifest.json +24 -0
- package/dist/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/client/__vitest__/bg.png +0 -0
- package/dist/client/__vitest__/favicon.ico +0 -0
- package/dist/client/__vitest__/favicon.svg +5 -0
- package/dist/client/__vitest__/index.html +32 -0
- package/dist/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/client/error-catcher.js +82 -0
- package/dist/client/esm-client-injector.js +67 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/orchestrator.html +35 -0
- package/dist/client/tester/tester.html +13 -0
- package/dist/client.js +456 -0
- package/dist/config.cjs +94 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +15 -0
- package/dist/context.js +541 -0
- package/dist/coverage.d.ts +118 -0
- package/dist/coverage.js +23 -0
- package/dist/dummy.js +2 -0
- package/dist/environments.d.ts +22 -0
- package/dist/environments.js +3 -0
- package/dist/expect-element.js +27 -0
- package/dist/index-D6m36C6U.js +6 -0
- package/dist/index-node.js +7 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +19 -0
- package/dist/locators.d.ts +354 -0
- package/dist/locators.js +1 -0
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/module-evaluator.d.ts +124 -0
- package/dist/module-evaluator.js +343 -0
- package/dist/module-runner-stub.js +44 -0
- package/dist/module-runner.js +17 -0
- package/dist/node.d.ts +251 -0
- package/dist/node.js +98 -0
- package/dist/path.js +7 -0
- package/dist/plugins/browser-client.mjs +2 -0
- package/dist/plugins/browser-context.mjs +2 -0
- package/dist/plugins/browser-locators.mjs +2 -0
- package/dist/plugins/browser-playwright.mjs +2 -0
- package/dist/plugins/browser-preview.mjs +2 -0
- package/dist/plugins/browser-webdriverio.mjs +2 -0
- package/dist/plugins/browser.mjs +2 -0
- package/dist/plugins/expect.mjs +2 -0
- package/dist/plugins/mocker-automock.mjs +2 -0
- package/dist/plugins/mocker-browser.mjs +2 -0
- package/dist/plugins/mocker-node.mjs +2 -0
- package/dist/plugins/mocker-redirect.mjs +2 -0
- package/dist/plugins/mocker-register.mjs +2 -0
- package/dist/plugins/mocker.mjs +2 -0
- package/dist/plugins/pretty-format.mjs +2 -0
- package/dist/plugins/runner-types.mjs +2 -0
- package/dist/plugins/runner-utils.mjs +2 -0
- package/dist/plugins/runner.mjs +2 -0
- package/dist/plugins/snapshot-environment.mjs +2 -0
- package/dist/plugins/snapshot-manager.mjs +2 -0
- package/dist/plugins/snapshot.mjs +2 -0
- package/dist/plugins/spy.mjs +2 -0
- package/dist/plugins/utils-constants.mjs +2 -0
- package/dist/plugins/utils-diff.mjs +2 -0
- package/dist/plugins/utils-display.mjs +2 -0
- package/dist/plugins/utils-error.mjs +2 -0
- package/dist/plugins/utils-helpers.mjs +2 -0
- package/dist/plugins/utils-highlight.mjs +2 -0
- package/dist/plugins/utils-offset.mjs +2 -0
- package/dist/plugins/utils-resolver.mjs +2 -0
- package/dist/plugins/utils-serialize.mjs +2 -0
- package/dist/plugins/utils-source-map.mjs +2 -0
- package/dist/plugins/utils-timers.mjs +2 -0
- package/dist/plugins/utils.mjs +2 -0
- package/dist/reporters.d.ts +27 -0
- package/dist/reporters.js +24 -0
- package/dist/runners.d.ts +50 -0
- package/dist/runners.js +19 -0
- package/dist/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +4 -0
- package/dist/spy.js +1 -0
- package/dist/state.js +280 -0
- package/dist/suite.d.ts +5 -0
- package/dist/suite.js +6 -0
- package/dist/types.d.ts +69 -0
- package/dist/vendor/chai.d.mts +1 -0
- package/dist/vendor/chai.mjs +3577 -0
- package/dist/vendor/es-module-lexer.d.mts +193 -0
- package/dist/vendor/es-module-lexer.mjs +79 -0
- package/dist/vendor/estree-walker.d.mts +583 -0
- package/dist/vendor/estree-walker.mjs +339 -0
- package/dist/vendor/expect-type.d.mts +1574 -0
- package/dist/vendor/expect-type.mjs +214 -0
- package/dist/vendor/magic-string.d.mts +261 -0
- package/dist/vendor/magic-string.mjs +1700 -0
- package/dist/vendor/obug.d.mts +56 -0
- package/dist/vendor/obug.mjs +276 -0
- package/dist/vendor/pathe.d.mts +46 -0
- package/dist/vendor/pathe.mjs +496 -0
- package/dist/vendor/picomatch.d.mts +1 -0
- package/dist/vendor/picomatch.mjs +1855 -0
- package/dist/vendor/shared-3g9mwCWP.mjs +31 -0
- package/dist/vendor/std-env.d.mts +88 -0
- package/dist/vendor/std-env.mjs +159 -0
- package/dist/vendor/tinybench.d.mts +317 -0
- package/dist/vendor/tinybench.mjs +504 -0
- package/dist/vendor/tinyexec.d.mts +72 -0
- package/dist/vendor/tinyexec.mjs +637 -0
- package/dist/vendor/tinyglobby.d.mts +157 -0
- package/dist/vendor/tinyglobby.mjs +832 -0
- package/dist/vendor/tinyrainbow.d.mts +60 -0
- package/dist/vendor/tinyrainbow.mjs +93 -0
- package/dist/vendor/vitest_browser.mjs +2 -0
- package/dist/vendor/vitest_internal_browser.mjs +2 -0
- package/dist/vendor/vitest_runner.mjs +2 -0
- package/dist/vendor/vitest_runners.mjs +2 -0
- package/dist/worker.d.ts +32 -0
- package/dist/worker.js +48 -0
- package/dist/workers/forks.js +54 -0
- package/dist/workers/runVmTests.js +95 -0
- package/dist/workers/threads.js +55 -0
- package/dist/workers/vmForks.js +36 -0
- package/dist/workers/vmThreads.js +37 -0
- package/environments.d.ts +1 -0
- package/globals.d.ts +20 -0
- package/import-meta.d.ts +5 -0
- package/importMeta.d.ts +4 -0
- package/index.cjs +5 -0
- package/index.d.cts +1 -0
- package/jsdom.d.ts +6 -0
- package/mocker.d.ts +1 -0
- package/node.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +335 -0
- package/reporters.d.ts +1 -0
- package/runners.d.ts +1 -0
- package/snapshot.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/suppress-warnings.cjs +21 -0
- package/vitest.mjs +2 -0
- package/worker.d.ts +1 -0
package/dist/context.js
ADDED
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import { __INTERNAL, stringify } from".//browser.js";
|
|
2
|
+
|
|
3
|
+
function ensureAwaited(promise) {
|
|
4
|
+
const test = getWorkerState().current;
|
|
5
|
+
if (!test || test.type !== "test") {
|
|
6
|
+
return promise();
|
|
7
|
+
}
|
|
8
|
+
let awaited = false;
|
|
9
|
+
const sourceError = new Error("STACK_TRACE_ERROR");
|
|
10
|
+
test.onFinished ??= [];
|
|
11
|
+
test.onFinished.push(() => {
|
|
12
|
+
if (!awaited) {
|
|
13
|
+
const error = new Error(`The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`);
|
|
14
|
+
error.stack = sourceError.stack?.replace(sourceError.message, error.message);
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
// don't even start the promise if it's not awaited to not cause any unhanded promise rejections
|
|
19
|
+
let promiseResult;
|
|
20
|
+
return {
|
|
21
|
+
then(onFulfilled, onRejected) {
|
|
22
|
+
awaited = true;
|
|
23
|
+
return (promiseResult ||= promise(sourceError)).then(onFulfilled, onRejected);
|
|
24
|
+
},
|
|
25
|
+
catch(onRejected) {
|
|
26
|
+
return (promiseResult ||= promise(sourceError)).catch(onRejected);
|
|
27
|
+
},
|
|
28
|
+
finally(onFinally) {
|
|
29
|
+
return (promiseResult ||= promise(sourceError)).finally(onFinally);
|
|
30
|
+
},
|
|
31
|
+
[Symbol.toStringTag]: "Promise"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
35
|
+
function getBrowserState() {
|
|
36
|
+
// @ts-expect-error not typed global
|
|
37
|
+
return window.__vitest_browser_runner__;
|
|
38
|
+
}
|
|
39
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
40
|
+
function getWorkerState() {
|
|
41
|
+
// @ts-expect-error not typed global
|
|
42
|
+
const state = window.__vitest_worker__;
|
|
43
|
+
if (!state) {
|
|
44
|
+
throw new Error("Worker state is not found. This is an issue with Vitest. Please, open an issue.");
|
|
45
|
+
}
|
|
46
|
+
return state;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const provider$1 = getBrowserState().provider;
|
|
50
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
51
|
+
function convertElementToCssSelector(element) {
|
|
52
|
+
if (!element || !(element instanceof Element)) {
|
|
53
|
+
throw new Error(`Expected DOM element to be an instance of Element, received ${typeof element}`);
|
|
54
|
+
}
|
|
55
|
+
return getUniqueCssSelector(element);
|
|
56
|
+
}
|
|
57
|
+
function escapeIdForCSSSelector(id) {
|
|
58
|
+
return id.split("").map((char) => {
|
|
59
|
+
const code = char.charCodeAt(0);
|
|
60
|
+
if (char === " " || char === "#" || char === "." || char === ":" || char === "[" || char === "]" || char === ">" || char === "+" || char === "~" || char === "\\") {
|
|
61
|
+
// Escape common special characters with backslashes
|
|
62
|
+
return `\\${char}`;
|
|
63
|
+
} else if (code >= 65536) {
|
|
64
|
+
// Unicode escape for characters outside the BMP
|
|
65
|
+
return `\\${code.toString(16).toUpperCase().padStart(6, "0")} `;
|
|
66
|
+
} else if (code < 32 || code === 127) {
|
|
67
|
+
// Non-printable ASCII characters (0x00-0x1F and 0x7F) are escaped
|
|
68
|
+
return `\\${code.toString(16).toUpperCase().padStart(2, "0")} `;
|
|
69
|
+
} else if (code >= 128) {
|
|
70
|
+
// Non-ASCII characters (0x80 and above) are escaped
|
|
71
|
+
return `\\${code.toString(16).toUpperCase().padStart(2, "0")} `;
|
|
72
|
+
} else {
|
|
73
|
+
// Allowable characters are used directly
|
|
74
|
+
return char;
|
|
75
|
+
}
|
|
76
|
+
}).join("");
|
|
77
|
+
}
|
|
78
|
+
function getUniqueCssSelector(el) {
|
|
79
|
+
const path = [];
|
|
80
|
+
let parent;
|
|
81
|
+
let hasShadowRoot = false;
|
|
82
|
+
// eslint-disable-next-line no-cond-assign
|
|
83
|
+
while (parent = getParent(el)) {
|
|
84
|
+
if (parent.shadowRoot) {
|
|
85
|
+
hasShadowRoot = true;
|
|
86
|
+
}
|
|
87
|
+
const tag = el.tagName;
|
|
88
|
+
if (el.id) {
|
|
89
|
+
path.push(`#${escapeIdForCSSSelector(el.id)}`);
|
|
90
|
+
} else if (!el.nextElementSibling && !el.previousElementSibling) {
|
|
91
|
+
path.push(tag.toLowerCase());
|
|
92
|
+
} else {
|
|
93
|
+
let index = 0;
|
|
94
|
+
let sameTagSiblings = 0;
|
|
95
|
+
let elementIndex = 0;
|
|
96
|
+
for (const sibling of parent.children) {
|
|
97
|
+
index++;
|
|
98
|
+
if (sibling.tagName === tag) {
|
|
99
|
+
sameTagSiblings++;
|
|
100
|
+
}
|
|
101
|
+
if (sibling === el) {
|
|
102
|
+
elementIndex = index;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (sameTagSiblings > 1) {
|
|
106
|
+
path.push(`${tag.toLowerCase()}:nth-child(${elementIndex})`);
|
|
107
|
+
} else {
|
|
108
|
+
path.push(tag.toLowerCase());
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
el = parent;
|
|
112
|
+
}
|
|
113
|
+
return `${getBrowserState().provider === "webdriverio" && hasShadowRoot ? ">>>" : ""}${path.reverse().join(" > ")}`;
|
|
114
|
+
}
|
|
115
|
+
function getParent(el) {
|
|
116
|
+
const parent = el.parentNode;
|
|
117
|
+
if (parent instanceof ShadowRoot) {
|
|
118
|
+
return parent.host;
|
|
119
|
+
}
|
|
120
|
+
return parent;
|
|
121
|
+
}
|
|
122
|
+
const now = Date.now;
|
|
123
|
+
function processTimeoutOptions(options_) {
|
|
124
|
+
if (options_ && options_.timeout != null || provider$1 !== "playwright") {
|
|
125
|
+
return options_;
|
|
126
|
+
}
|
|
127
|
+
// if there is a default action timeout, use it
|
|
128
|
+
if (getWorkerState().config.browser.providerOptions.actionTimeout != null) {
|
|
129
|
+
return options_;
|
|
130
|
+
}
|
|
131
|
+
const runner = getBrowserState().runner;
|
|
132
|
+
const startTime = runner._currentTaskStartTime;
|
|
133
|
+
// ignore timeout if this is called outside of a test
|
|
134
|
+
if (!startTime) {
|
|
135
|
+
return options_;
|
|
136
|
+
}
|
|
137
|
+
const timeout = runner._currentTaskTimeout;
|
|
138
|
+
if (timeout === 0 || timeout == null || timeout === Number.POSITIVE_INFINITY) {
|
|
139
|
+
return options_;
|
|
140
|
+
}
|
|
141
|
+
options_ = options_ || {};
|
|
142
|
+
const currentTime = now();
|
|
143
|
+
const endTime = startTime + timeout;
|
|
144
|
+
const remainingTime = endTime - currentTime;
|
|
145
|
+
if (remainingTime <= 0) {
|
|
146
|
+
return options_;
|
|
147
|
+
}
|
|
148
|
+
// give us some time to process the timeout
|
|
149
|
+
options_.timeout = remainingTime - 100;
|
|
150
|
+
return options_;
|
|
151
|
+
}
|
|
152
|
+
function convertToSelector(elementOrLocator) {
|
|
153
|
+
if (!elementOrLocator) {
|
|
154
|
+
throw new Error("Expected element or locator to be defined.");
|
|
155
|
+
}
|
|
156
|
+
if (elementOrLocator instanceof Element) {
|
|
157
|
+
return convertElementToCssSelector(elementOrLocator);
|
|
158
|
+
}
|
|
159
|
+
if (isLocator(elementOrLocator)) {
|
|
160
|
+
return elementOrLocator.selector;
|
|
161
|
+
}
|
|
162
|
+
throw new Error("Expected element or locator to be an instance of Element or Locator.");
|
|
163
|
+
}
|
|
164
|
+
const kLocator = Symbol.for("$$vitest:locator");
|
|
165
|
+
function isLocator(element) {
|
|
166
|
+
return !!element && typeof element === "object" && kLocator in element;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// this file should not import anything directly, only types and utils
|
|
170
|
+
// @ts-expect-error not typed global
|
|
171
|
+
const provider = __vitest_browser_runner__.provider;
|
|
172
|
+
const sessionId = getBrowserState().sessionId;
|
|
173
|
+
const channel = new BroadcastChannel(`vitest:${sessionId}`);
|
|
174
|
+
function triggerCommand(command, args, error) {
|
|
175
|
+
return getBrowserState().commands.triggerCommand(command, args, error);
|
|
176
|
+
}
|
|
177
|
+
function createUserEvent(__tl_user_event_base__, options) {
|
|
178
|
+
if (__tl_user_event_base__) {
|
|
179
|
+
return createPreviewUserEvent(__tl_user_event_base__, options ?? {});
|
|
180
|
+
}
|
|
181
|
+
const keyboard = { unreleased: [] };
|
|
182
|
+
// https://playwright.dev/docs/api/class-keyboard
|
|
183
|
+
// https://webdriver.io/docs/api/browser/keys/
|
|
184
|
+
const modifier = provider === "playwright" ? "ControlOrMeta" : provider === "webdriverio" ? "Ctrl" : "Control";
|
|
185
|
+
const userEvent = {
|
|
186
|
+
setup() {
|
|
187
|
+
return createUserEvent();
|
|
188
|
+
},
|
|
189
|
+
async cleanup() {
|
|
190
|
+
// avoid cleanup rpc call if there is nothing to cleanup
|
|
191
|
+
if (!keyboard.unreleased.length) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
return ensureAwaited(async (error) => {
|
|
195
|
+
await triggerCommand("__vitest_cleanup", [keyboard], error);
|
|
196
|
+
keyboard.unreleased = [];
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
click(element, options) {
|
|
200
|
+
return convertToLocator(element).click(options);
|
|
201
|
+
},
|
|
202
|
+
dblClick(element, options) {
|
|
203
|
+
return convertToLocator(element).dblClick(options);
|
|
204
|
+
},
|
|
205
|
+
tripleClick(element, options) {
|
|
206
|
+
return convertToLocator(element).tripleClick(options);
|
|
207
|
+
},
|
|
208
|
+
selectOptions(element, value, options) {
|
|
209
|
+
return convertToLocator(element).selectOptions(value, options);
|
|
210
|
+
},
|
|
211
|
+
clear(element, options) {
|
|
212
|
+
return convertToLocator(element).clear(options);
|
|
213
|
+
},
|
|
214
|
+
hover(element, options) {
|
|
215
|
+
return convertToLocator(element).hover(options);
|
|
216
|
+
},
|
|
217
|
+
unhover(element, options) {
|
|
218
|
+
return convertToLocator(element).unhover(options);
|
|
219
|
+
},
|
|
220
|
+
upload(element, files, options) {
|
|
221
|
+
return convertToLocator(element).upload(files, options);
|
|
222
|
+
},
|
|
223
|
+
fill(element, text, options) {
|
|
224
|
+
return convertToLocator(element).fill(text, options);
|
|
225
|
+
},
|
|
226
|
+
dragAndDrop(source, target, options) {
|
|
227
|
+
const sourceLocator = convertToLocator(source);
|
|
228
|
+
const targetLocator = convertToLocator(target);
|
|
229
|
+
return sourceLocator.dropTo(targetLocator, options);
|
|
230
|
+
},
|
|
231
|
+
async type(element, text, options) {
|
|
232
|
+
return ensureAwaited(async (error) => {
|
|
233
|
+
const selector = convertToSelector(element);
|
|
234
|
+
const { unreleased } = await triggerCommand("__vitest_type", [
|
|
235
|
+
selector,
|
|
236
|
+
text,
|
|
237
|
+
{
|
|
238
|
+
...options,
|
|
239
|
+
unreleased: keyboard.unreleased
|
|
240
|
+
}
|
|
241
|
+
], error);
|
|
242
|
+
keyboard.unreleased = unreleased;
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
tab(options = {}) {
|
|
246
|
+
return ensureAwaited((error) => triggerCommand("__vitest_tab", [options], error));
|
|
247
|
+
},
|
|
248
|
+
async keyboard(text) {
|
|
249
|
+
return ensureAwaited(async (error) => {
|
|
250
|
+
const { unreleased } = await triggerCommand("__vitest_keyboard", [text, keyboard], error);
|
|
251
|
+
keyboard.unreleased = unreleased;
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
async copy() {
|
|
255
|
+
await userEvent.keyboard(`{${modifier}>}{c}{/${modifier}}`);
|
|
256
|
+
},
|
|
257
|
+
async cut() {
|
|
258
|
+
await userEvent.keyboard(`{${modifier}>}{x}{/${modifier}}`);
|
|
259
|
+
},
|
|
260
|
+
async paste() {
|
|
261
|
+
await userEvent.keyboard(`{${modifier}>}{v}{/${modifier}}`);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
return userEvent;
|
|
265
|
+
}
|
|
266
|
+
function createPreviewUserEvent(userEventBase, options) {
|
|
267
|
+
let userEvent = userEventBase.setup(options);
|
|
268
|
+
let clipboardData;
|
|
269
|
+
function toElement(element) {
|
|
270
|
+
return element instanceof Element ? element : element.element();
|
|
271
|
+
}
|
|
272
|
+
const vitestUserEvent = {
|
|
273
|
+
setup(options) {
|
|
274
|
+
return createPreviewUserEvent(userEventBase, options);
|
|
275
|
+
},
|
|
276
|
+
async cleanup() {
|
|
277
|
+
userEvent = userEventBase.setup(options ?? {});
|
|
278
|
+
},
|
|
279
|
+
async click(element) {
|
|
280
|
+
await userEvent.click(toElement(element));
|
|
281
|
+
},
|
|
282
|
+
async dblClick(element) {
|
|
283
|
+
await userEvent.dblClick(toElement(element));
|
|
284
|
+
},
|
|
285
|
+
async tripleClick(element) {
|
|
286
|
+
await userEvent.tripleClick(toElement(element));
|
|
287
|
+
},
|
|
288
|
+
async selectOptions(element, value) {
|
|
289
|
+
const options = (Array.isArray(value) ? value : [value]).map((option) => {
|
|
290
|
+
if (typeof option !== "string") {
|
|
291
|
+
return toElement(option);
|
|
292
|
+
}
|
|
293
|
+
return option;
|
|
294
|
+
});
|
|
295
|
+
await userEvent.selectOptions(toElement(element), options);
|
|
296
|
+
},
|
|
297
|
+
async clear(element) {
|
|
298
|
+
await userEvent.clear(toElement(element));
|
|
299
|
+
},
|
|
300
|
+
async hover(element) {
|
|
301
|
+
await userEvent.hover(toElement(element));
|
|
302
|
+
},
|
|
303
|
+
async unhover(element) {
|
|
304
|
+
await userEvent.unhover(toElement(element));
|
|
305
|
+
},
|
|
306
|
+
async upload(element, files) {
|
|
307
|
+
const uploadPromise = (Array.isArray(files) ? files : [files]).map(async (file) => {
|
|
308
|
+
if (typeof file !== "string") {
|
|
309
|
+
return file;
|
|
310
|
+
}
|
|
311
|
+
const { content: base64, basename, mime } = await triggerCommand("__vitest_fileInfo", [file, "base64"]);
|
|
312
|
+
const fileInstance = fetch(`data:${mime};base64,${base64}`).then((r) => r.blob()).then((blob) => new File([blob], basename, { type: mime }));
|
|
313
|
+
return fileInstance;
|
|
314
|
+
});
|
|
315
|
+
const uploadFiles = await Promise.all(uploadPromise);
|
|
316
|
+
return userEvent.upload(toElement(element), uploadFiles);
|
|
317
|
+
},
|
|
318
|
+
async fill(element, text) {
|
|
319
|
+
await userEvent.clear(toElement(element));
|
|
320
|
+
return userEvent.type(toElement(element), text);
|
|
321
|
+
},
|
|
322
|
+
async dragAndDrop() {
|
|
323
|
+
throw new Error(`The "preview" provider doesn't support 'userEvent.dragAndDrop'`);
|
|
324
|
+
},
|
|
325
|
+
async type(element, text, options) {
|
|
326
|
+
await userEvent.type(toElement(element), text, options);
|
|
327
|
+
},
|
|
328
|
+
async tab(options) {
|
|
329
|
+
await userEvent.tab(options);
|
|
330
|
+
},
|
|
331
|
+
async keyboard(text) {
|
|
332
|
+
await userEvent.keyboard(text);
|
|
333
|
+
},
|
|
334
|
+
async copy() {
|
|
335
|
+
clipboardData = await userEvent.copy();
|
|
336
|
+
},
|
|
337
|
+
async cut() {
|
|
338
|
+
clipboardData = await userEvent.cut();
|
|
339
|
+
},
|
|
340
|
+
async paste() {
|
|
341
|
+
await userEvent.paste(clipboardData);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
for (const [name, fn] of Object.entries(vitestUserEvent)) {
|
|
345
|
+
if (name !== "setup") {
|
|
346
|
+
vitestUserEvent[name] = function(...args) {
|
|
347
|
+
return ensureAwaited(() => fn.apply(this, args));
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return vitestUserEvent;
|
|
352
|
+
}
|
|
353
|
+
function cdp() {
|
|
354
|
+
return getBrowserState().cdp;
|
|
355
|
+
}
|
|
356
|
+
const screenshotIds = {};
|
|
357
|
+
const page = {
|
|
358
|
+
viewport(width, height) {
|
|
359
|
+
const id = getBrowserState().iframeId;
|
|
360
|
+
channel.postMessage({
|
|
361
|
+
event: "viewport",
|
|
362
|
+
width,
|
|
363
|
+
height,
|
|
364
|
+
iframeId: id
|
|
365
|
+
});
|
|
366
|
+
return new Promise((resolve, reject) => {
|
|
367
|
+
channel.addEventListener("message", function handler(e) {
|
|
368
|
+
if (e.data.event === "viewport:done" && e.data.iframeId === id) {
|
|
369
|
+
channel.removeEventListener("message", handler);
|
|
370
|
+
resolve();
|
|
371
|
+
}
|
|
372
|
+
if (e.data.event === "viewport:fail" && e.data.iframeId === id) {
|
|
373
|
+
channel.removeEventListener("message", handler);
|
|
374
|
+
reject(new Error(e.data.error));
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
},
|
|
379
|
+
async screenshot(options = {}) {
|
|
380
|
+
const currentTest = getWorkerState().current;
|
|
381
|
+
if (!currentTest) {
|
|
382
|
+
throw new Error("Cannot take a screenshot outside of a test.");
|
|
383
|
+
}
|
|
384
|
+
if (currentTest.concurrent) {
|
|
385
|
+
throw new Error("Cannot take a screenshot in a concurrent test because " + "concurrent tests run at the same time in the same iframe and affect each other's environment. " + "Use a non-concurrent test to take a screenshot.");
|
|
386
|
+
}
|
|
387
|
+
const repeatCount = currentTest.result?.repeatCount ?? 0;
|
|
388
|
+
const taskName = getTaskFullName(currentTest);
|
|
389
|
+
const number = screenshotIds[repeatCount]?.[taskName] ?? 1;
|
|
390
|
+
screenshotIds[repeatCount] ??= {};
|
|
391
|
+
screenshotIds[repeatCount][taskName] = number + 1;
|
|
392
|
+
const name = options.path || `${taskName.replace(/[^a-z0-9]/gi, "-")}-${number}.png`;
|
|
393
|
+
const normalizedOptions = "mask" in options ? {
|
|
394
|
+
...options,
|
|
395
|
+
mask: options.mask.map(convertToSelector)
|
|
396
|
+
} : options;
|
|
397
|
+
return ensureAwaited((error) => triggerCommand("__vitest_screenshot", [name, processTimeoutOptions(
|
|
398
|
+
{
|
|
399
|
+
...normalizedOptions,
|
|
400
|
+
element: options.element ? convertToSelector(options.element) : undefined
|
|
401
|
+
}
|
|
402
|
+
/** TODO */
|
|
403
|
+
)], error));
|
|
404
|
+
},
|
|
405
|
+
getByRole() {
|
|
406
|
+
throw new Error(`Method "getByRole" is not supported by the "${provider}" provider.`);
|
|
407
|
+
},
|
|
408
|
+
getByLabelText() {
|
|
409
|
+
throw new Error(`Method "getByLabelText" is not supported by the "${provider}" provider.`);
|
|
410
|
+
},
|
|
411
|
+
getByTestId() {
|
|
412
|
+
throw new Error(`Method "getByTestId" is not supported by the "${provider}" provider.`);
|
|
413
|
+
},
|
|
414
|
+
getByAltText() {
|
|
415
|
+
throw new Error(`Method "getByAltText" is not supported by the "${provider}" provider.`);
|
|
416
|
+
},
|
|
417
|
+
getByPlaceholder() {
|
|
418
|
+
throw new Error(`Method "getByPlaceholder" is not supported by the "${provider}" provider.`);
|
|
419
|
+
},
|
|
420
|
+
getByText() {
|
|
421
|
+
throw new Error(`Method "getByText" is not supported by the "${provider}" provider.`);
|
|
422
|
+
},
|
|
423
|
+
getByTitle() {
|
|
424
|
+
throw new Error(`Method "getByTitle" is not supported by the "${provider}" provider.`);
|
|
425
|
+
},
|
|
426
|
+
elementLocator() {
|
|
427
|
+
throw new Error(`Method "elementLocator" is not supported by the "${provider}" provider.`);
|
|
428
|
+
},
|
|
429
|
+
frameLocator() {
|
|
430
|
+
throw new Error(`Method "frameLocator" is not supported by the "${provider}" provider.`);
|
|
431
|
+
},
|
|
432
|
+
extend(methods) {
|
|
433
|
+
for (const key in methods) {
|
|
434
|
+
page[key] = methods[key].bind(page);
|
|
435
|
+
}
|
|
436
|
+
return page;
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
function convertToLocator(element) {
|
|
440
|
+
if (element instanceof Element) {
|
|
441
|
+
return page.elementLocator(element);
|
|
442
|
+
}
|
|
443
|
+
return element;
|
|
444
|
+
}
|
|
445
|
+
function getTaskFullName(task) {
|
|
446
|
+
return task.suite ? `${getTaskFullName(task.suite)} ${task.name}` : task.name;
|
|
447
|
+
}
|
|
448
|
+
const locators = {
|
|
449
|
+
createElementLocators: getElementLocatorSelectors,
|
|
450
|
+
extend(methods) {
|
|
451
|
+
const Locator = __INTERNAL._createLocator("css=body").constructor;
|
|
452
|
+
for (const method in methods) {
|
|
453
|
+
__INTERNAL._extendedMethods.add(method);
|
|
454
|
+
const cb = methods[method];
|
|
455
|
+
// @ts-expect-error types are hard to make work
|
|
456
|
+
Locator.prototype[method] = function(...args) {
|
|
457
|
+
const selectorOrLocator = cb.call(this, ...args);
|
|
458
|
+
if (typeof selectorOrLocator === "string") {
|
|
459
|
+
return this.locator(selectorOrLocator);
|
|
460
|
+
}
|
|
461
|
+
return selectorOrLocator;
|
|
462
|
+
};
|
|
463
|
+
page[method] = function(...args) {
|
|
464
|
+
const selectorOrLocator = cb.call(this, ...args);
|
|
465
|
+
if (typeof selectorOrLocator === "string") {
|
|
466
|
+
return __INTERNAL._createLocator(selectorOrLocator);
|
|
467
|
+
}
|
|
468
|
+
return selectorOrLocator;
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
function getElementLocatorSelectors(element) {
|
|
474
|
+
const locator = page.elementLocator(element);
|
|
475
|
+
return {
|
|
476
|
+
getByAltText: (altText, options) => locator.getByAltText(altText, options),
|
|
477
|
+
getByLabelText: (labelText, options) => locator.getByLabelText(labelText, options),
|
|
478
|
+
getByPlaceholder: (placeholderText, options) => locator.getByPlaceholder(placeholderText, options),
|
|
479
|
+
getByRole: (role, options) => locator.getByRole(role, options),
|
|
480
|
+
getByTestId: (testId) => locator.getByTestId(testId),
|
|
481
|
+
getByText: (text, options) => locator.getByText(text, options),
|
|
482
|
+
getByTitle: (title, options) => locator.getByTitle(title, options),
|
|
483
|
+
...Array.from(__INTERNAL._extendedMethods).reduce((methods, method) => {
|
|
484
|
+
methods[method] = (...args) => locator[method](...args);
|
|
485
|
+
return methods;
|
|
486
|
+
}, {})
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
let defaultOptions;
|
|
490
|
+
function debug(el, maxLength, options) {
|
|
491
|
+
if (Array.isArray(el)) {
|
|
492
|
+
// eslint-disable-next-line no-console
|
|
493
|
+
el.forEach((e) => console.log(prettyDOM(e, maxLength, options)));
|
|
494
|
+
} else {
|
|
495
|
+
// eslint-disable-next-line no-console
|
|
496
|
+
console.log(prettyDOM(el, maxLength, options));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function prettyDOM(dom, maxLength = Number(defaultOptions?.maxLength ?? import.meta.env.DEBUG_PRINT_LIMIT ?? 7e3), prettyFormatOptions = {}) {
|
|
500
|
+
if (maxLength === 0) {
|
|
501
|
+
return "";
|
|
502
|
+
}
|
|
503
|
+
if (!dom) {
|
|
504
|
+
dom = document.body;
|
|
505
|
+
}
|
|
506
|
+
if ("element" in dom && "all" in dom) {
|
|
507
|
+
dom = dom.element();
|
|
508
|
+
}
|
|
509
|
+
const type = typeof dom;
|
|
510
|
+
if (type !== "object" || !dom.outerHTML) {
|
|
511
|
+
const typeName = type === "object" ? dom.constructor.name : type;
|
|
512
|
+
throw new TypeError(`Expecting a valid DOM element, but got ${typeName}.`);
|
|
513
|
+
}
|
|
514
|
+
const pretty = stringify(dom, Number.POSITIVE_INFINITY, {
|
|
515
|
+
maxLength,
|
|
516
|
+
highlight: true,
|
|
517
|
+
...defaultOptions,
|
|
518
|
+
...prettyFormatOptions
|
|
519
|
+
});
|
|
520
|
+
return dom.outerHTML.length > maxLength ? `${pretty.slice(0, maxLength)}...` : pretty;
|
|
521
|
+
}
|
|
522
|
+
function getElementError(selector, container) {
|
|
523
|
+
const error = new Error(`Cannot find element with locator: ${__INTERNAL._asLocator("javascript", selector)}\n\n${prettyDOM(container)}`);
|
|
524
|
+
error.name = "VitestBrowserElementError";
|
|
525
|
+
return error;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* @experimental
|
|
529
|
+
*/
|
|
530
|
+
function configurePrettyDOM(options) {
|
|
531
|
+
defaultOptions = options;
|
|
532
|
+
}
|
|
533
|
+
const utils = {
|
|
534
|
+
getElementError,
|
|
535
|
+
prettyDOM,
|
|
536
|
+
debug,
|
|
537
|
+
getElementLocatorSelectors,
|
|
538
|
+
configurePrettyDOM
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
export { cdp, createUserEvent, locators, page, utils };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.CWXNI2jG.js';
|
|
2
|
+
import { TransformResult } from '@voidzero-dev/vite-plus-core';
|
|
3
|
+
import { A as AfterSuiteRunMeta } from './chunks/rpc.d.RH3apGEf.js';
|
|
4
|
+
import './@vitest/runner/index.js';
|
|
5
|
+
import './@vitest/utils/index.js';
|
|
6
|
+
import 'node:stream';
|
|
7
|
+
import './chunks/browser.d.ChKACdzH.js';
|
|
8
|
+
import './chunks/traces.d.402V_yFI.js';
|
|
9
|
+
import './chunks/worker.d.Dyxm8DEL.js';
|
|
10
|
+
import '@voidzero-dev/vite-plus-core/module-runner';
|
|
11
|
+
import './chunks/config.d.Cy95HiCx.js';
|
|
12
|
+
import './@vitest/pretty-format/index.js';
|
|
13
|
+
import './@vitest/snapshot/index.js';
|
|
14
|
+
import './@vitest/utils/diff.js';
|
|
15
|
+
import './chunks/environment.d.CrsxCzP1.js';
|
|
16
|
+
import './@vitest/mocker/index.js';
|
|
17
|
+
import './@vitest/utils/source-map.js';
|
|
18
|
+
import './@vitest/browser/index.js';
|
|
19
|
+
import './@vitest/expect/index.js';
|
|
20
|
+
import 'vitest/optional-types.js';
|
|
21
|
+
import './chunks/benchmark.d.DAaHLpsq.js';
|
|
22
|
+
import './@vitest/runner/utils.js';
|
|
23
|
+
import './vendor/tinybench.mjs';
|
|
24
|
+
import './chunks/coverage.d.BZtK59WP.js';
|
|
25
|
+
import './@vitest/snapshot/manager.js';
|
|
26
|
+
import 'node:console';
|
|
27
|
+
import 'node:fs';
|
|
28
|
+
|
|
29
|
+
type Threshold = "lines" | "functions" | "statements" | "branches";
|
|
30
|
+
interface ResolvedThreshold {
|
|
31
|
+
coverageMap: CoverageMap;
|
|
32
|
+
name: string;
|
|
33
|
+
thresholds: Partial<Record<Threshold, number | undefined>>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Holds info about raw coverage results that are stored on file system:
|
|
37
|
+
*
|
|
38
|
+
* ```json
|
|
39
|
+
* "project-a": {
|
|
40
|
+
* "web": {
|
|
41
|
+
* "tests/math.test.ts": "coverage-1.json",
|
|
42
|
+
* "tests/utils.test.ts": "coverage-2.json",
|
|
43
|
+
* // ^^^^^^^^^^^^^^^ Raw coverage on file system
|
|
44
|
+
* },
|
|
45
|
+
* "ssr": { ... },
|
|
46
|
+
* "browser": { ... },
|
|
47
|
+
* },
|
|
48
|
+
* "project-b": ...
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["environment"], {
|
|
52
|
+
[TestFilenames: string]: string;
|
|
53
|
+
}>>;
|
|
54
|
+
declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"istanbul" | "v8">> {
|
|
55
|
+
ctx: Vitest;
|
|
56
|
+
readonly name: "v8" | "istanbul";
|
|
57
|
+
version: string;
|
|
58
|
+
options: Options;
|
|
59
|
+
globCache: Map<string, boolean>;
|
|
60
|
+
coverageFiles: CoverageFiles;
|
|
61
|
+
pendingPromises: Promise<void>[];
|
|
62
|
+
coverageFilesDirectory: string;
|
|
63
|
+
roots: string[];
|
|
64
|
+
_initialize(ctx: Vitest): void;
|
|
65
|
+
/**
|
|
66
|
+
* Check if file matches `coverage.include` but not `coverage.exclude`
|
|
67
|
+
*/
|
|
68
|
+
isIncluded(_filename: string, root?: string): boolean;
|
|
69
|
+
private getUntestedFilesByRoot;
|
|
70
|
+
getUntestedFiles(testedFiles: string[]): Promise<string[]>;
|
|
71
|
+
createCoverageMap(): CoverageMap;
|
|
72
|
+
generateReports(_: CoverageMap, __: boolean | undefined): Promise<void>;
|
|
73
|
+
parseConfigModule(_: string): Promise<{
|
|
74
|
+
generate: () => {
|
|
75
|
+
code: string;
|
|
76
|
+
};
|
|
77
|
+
}>;
|
|
78
|
+
resolveOptions(): Options;
|
|
79
|
+
clean(clean?: boolean): Promise<void>;
|
|
80
|
+
onAfterSuiteRun({ coverage, environment, projectName, testFiles }: AfterSuiteRunMeta): void;
|
|
81
|
+
readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
|
|
82
|
+
/** Callback invoked with a single coverage result */
|
|
83
|
+
onFileRead: (data: CoverageType) => void;
|
|
84
|
+
/** Callback invoked once all results of a project for specific transform mode are read */
|
|
85
|
+
onFinished: (project: Vitest["projects"][number], environment: string) => Promise<void>;
|
|
86
|
+
onDebug: ((...logs: any[]) => void) & {
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
};
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
cleanAfterRun(): Promise<void>;
|
|
91
|
+
onTestFailure(): Promise<void>;
|
|
92
|
+
reportCoverage(coverageMap: unknown, { allTestsRun }: ReportContext): Promise<void>;
|
|
93
|
+
reportThresholds(coverageMap: CoverageMap, allTestsRun: boolean | undefined): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Constructs collected coverage and users' threshold options into separate sets
|
|
96
|
+
* where each threshold set holds their own coverage maps. Threshold set is either
|
|
97
|
+
* for specific files defined by glob pattern or global for all other files.
|
|
98
|
+
*/
|
|
99
|
+
private resolveThresholds;
|
|
100
|
+
/**
|
|
101
|
+
* Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
|
|
102
|
+
*/
|
|
103
|
+
private checkThresholds;
|
|
104
|
+
/**
|
|
105
|
+
* Check if current coverage is above configured thresholds and bump the thresholds if needed
|
|
106
|
+
*/
|
|
107
|
+
updateThresholds({ thresholds: allThresholds, onUpdate, configurationFile }: {
|
|
108
|
+
thresholds: ResolvedThreshold[];
|
|
109
|
+
configurationFile: unknown;
|
|
110
|
+
onUpdate: () => void;
|
|
111
|
+
}): Promise<void>;
|
|
112
|
+
mergeReports(coverageMaps: unknown[]): Promise<void>;
|
|
113
|
+
hasTerminalReporter(reporters: ResolvedCoverageOptions["reporter"]): boolean;
|
|
114
|
+
toSlices<T>(array: T[], size: number): T[][];
|
|
115
|
+
createUncoveredFileTransformer(ctx: Vitest): (filename: string) => Promise<TransformResult | null | undefined>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { BaseCoverageProvider };
|
package/dist/coverage.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { B as BaseCoverageProvider } from './chunks/coverage.AVPTjMgw.js';
|
|
2
|
+
import 'node:fs';
|
|
3
|
+
import 'node:path';
|
|
4
|
+
import './@vitest/utils/helpers.js';
|
|
5
|
+
import './vendor/pathe.mjs';
|
|
6
|
+
import './vendor/picomatch.mjs';
|
|
7
|
+
import './vendor/tinyglobby.mjs';
|
|
8
|
+
import './vendor/tinyrainbow.mjs';
|
|
9
|
+
import './chunks/defaults.BOqNVLsY.js';
|
|
10
|
+
import 'node:os';
|
|
11
|
+
import './chunks/env.D4Lgay0q.js';
|
|
12
|
+
import './vendor/std-env.mjs';
|
|
13
|
+
import 'node:crypto';
|
|
14
|
+
import 'node:url';
|
|
15
|
+
import 'node:module';
|
|
16
|
+
import 'node:process';
|
|
17
|
+
import 'node:fs/promises';
|
|
18
|
+
import 'node:assert';
|
|
19
|
+
import 'node:v8';
|
|
20
|
+
import 'node:util';
|
|
21
|
+
import '@voidzero-dev/vite-plus-core';
|
|
22
|
+
import './chunks/constants.D_Q9UYh-.js';
|
|
23
|
+
import './chunks/coverage.D_JHT54q.js';
|
package/dist/dummy.js
ADDED