@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { selectorEngine, getByTitleSelector, getByTextSelector, getByPlaceholderSelector, getByAltTextSelector, getByTestIdSelector, getByRoleSelector, getByLabelSelector, Locator, processTimeoutOptions, getIframeScale } from '../browser/locators.js';
|
|
2
|
+
import { page } from '../browser/context.js';
|
|
3
|
+
import { __INTERNAL } from '../../browser.js';
|
|
4
|
+
|
|
5
|
+
class PlaywrightLocator extends Locator {
|
|
6
|
+
constructor(selector, _container) {
|
|
7
|
+
super();
|
|
8
|
+
this.selector = selector;
|
|
9
|
+
this._container = _container;
|
|
10
|
+
}
|
|
11
|
+
click(options) {
|
|
12
|
+
return super.click(processTimeoutOptions(processClickOptions(options)));
|
|
13
|
+
}
|
|
14
|
+
dblClick(options) {
|
|
15
|
+
return super.dblClick(processTimeoutOptions(processClickOptions(options)));
|
|
16
|
+
}
|
|
17
|
+
tripleClick(options) {
|
|
18
|
+
return super.tripleClick(processTimeoutOptions(processClickOptions(options)));
|
|
19
|
+
}
|
|
20
|
+
selectOptions(value, options) {
|
|
21
|
+
return super.selectOptions(value, processTimeoutOptions(options));
|
|
22
|
+
}
|
|
23
|
+
clear(options) {
|
|
24
|
+
return super.clear(processTimeoutOptions(options));
|
|
25
|
+
}
|
|
26
|
+
hover(options) {
|
|
27
|
+
return super.hover(processTimeoutOptions(processHoverOptions(options)));
|
|
28
|
+
}
|
|
29
|
+
upload(files, options) {
|
|
30
|
+
return super.upload(files, processTimeoutOptions(options));
|
|
31
|
+
}
|
|
32
|
+
fill(text, options) {
|
|
33
|
+
return super.fill(text, processTimeoutOptions(options));
|
|
34
|
+
}
|
|
35
|
+
dropTo(target, options) {
|
|
36
|
+
return super.dropTo(target, processTimeoutOptions(processDragAndDropOptions(options)));
|
|
37
|
+
}
|
|
38
|
+
locator(selector) {
|
|
39
|
+
return new PlaywrightLocator(`${this.selector} >> ${selector}`, this._container);
|
|
40
|
+
}
|
|
41
|
+
elementLocator(element) {
|
|
42
|
+
return new PlaywrightLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
page.extend({
|
|
46
|
+
getByLabelText(text, options) {
|
|
47
|
+
return new PlaywrightLocator(getByLabelSelector(text, options));
|
|
48
|
+
},
|
|
49
|
+
getByRole(role, options) {
|
|
50
|
+
return new PlaywrightLocator(getByRoleSelector(role, options));
|
|
51
|
+
},
|
|
52
|
+
getByTestId(testId) {
|
|
53
|
+
return new PlaywrightLocator(getByTestIdSelector(window.__vitest_worker__.config.browser.locators.testIdAttribute, testId));
|
|
54
|
+
},
|
|
55
|
+
getByAltText(text, options) {
|
|
56
|
+
return new PlaywrightLocator(getByAltTextSelector(text, options));
|
|
57
|
+
},
|
|
58
|
+
getByPlaceholder(text, options) {
|
|
59
|
+
return new PlaywrightLocator(getByPlaceholderSelector(text, options));
|
|
60
|
+
},
|
|
61
|
+
getByText(text, options) {
|
|
62
|
+
return new PlaywrightLocator(getByTextSelector(text, options));
|
|
63
|
+
},
|
|
64
|
+
getByTitle(title, options) {
|
|
65
|
+
return new PlaywrightLocator(getByTitleSelector(title, options));
|
|
66
|
+
},
|
|
67
|
+
elementLocator(element) {
|
|
68
|
+
return new PlaywrightLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
69
|
+
},
|
|
70
|
+
frameLocator(locator) {
|
|
71
|
+
return new PlaywrightLocator(`${locator.selector} >> internal:control=enter-frame`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
__INTERNAL._createLocator = (selector) => new PlaywrightLocator(selector);
|
|
75
|
+
function processDragAndDropOptions(options) {
|
|
76
|
+
if (!options) {
|
|
77
|
+
return options;
|
|
78
|
+
}
|
|
79
|
+
if (options.sourcePosition) {
|
|
80
|
+
options.sourcePosition = processPlaywrightPosition(options.sourcePosition);
|
|
81
|
+
}
|
|
82
|
+
if (options.targetPosition) {
|
|
83
|
+
options.targetPosition = processPlaywrightPosition(options.targetPosition);
|
|
84
|
+
}
|
|
85
|
+
return options;
|
|
86
|
+
}
|
|
87
|
+
function processHoverOptions(options) {
|
|
88
|
+
if (!options) {
|
|
89
|
+
return options;
|
|
90
|
+
}
|
|
91
|
+
if (options.position) {
|
|
92
|
+
options.position = processPlaywrightPosition(options.position);
|
|
93
|
+
}
|
|
94
|
+
return options;
|
|
95
|
+
}
|
|
96
|
+
function processClickOptions(options) {
|
|
97
|
+
if (!options) {
|
|
98
|
+
return options;
|
|
99
|
+
}
|
|
100
|
+
if (options.position) {
|
|
101
|
+
options.position = processPlaywrightPosition(options.position);
|
|
102
|
+
}
|
|
103
|
+
return options;
|
|
104
|
+
}
|
|
105
|
+
function processPlaywrightPosition(position) {
|
|
106
|
+
const scale = getIframeScale();
|
|
107
|
+
if (position.x != null) {
|
|
108
|
+
position.x *= scale;
|
|
109
|
+
}
|
|
110
|
+
if (position.y != null) {
|
|
111
|
+
position.y *= scale;
|
|
112
|
+
}
|
|
113
|
+
return position;
|
|
114
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../browser/context.js'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BrowserProviderOption, BrowserProvider, TestProject } from '../../node.js';
|
|
2
|
+
export { defineBrowserCommand } from '../browser/index.js';
|
|
3
|
+
|
|
4
|
+
declare function preview(): BrowserProviderOption;
|
|
5
|
+
declare class PreviewBrowserProvider implements BrowserProvider {
|
|
6
|
+
name: "preview";
|
|
7
|
+
supportsParallelism: boolean;
|
|
8
|
+
private project;
|
|
9
|
+
private open;
|
|
10
|
+
distRoot: string;
|
|
11
|
+
initScripts: string[];
|
|
12
|
+
constructor(project: TestProject);
|
|
13
|
+
isOpen(): boolean;
|
|
14
|
+
getCommandsContext(): {};
|
|
15
|
+
openPage(_sessionId: string, url: string): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { PreviewBrowserProvider, preview };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { nextTick } from 'node:process';
|
|
2
|
+
import { defineBrowserProvider } from '../browser/index.js';
|
|
3
|
+
export { defineBrowserCommand } from '../browser/index.js';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
7
|
+
function normalizeWindowsPath(input = "") {
|
|
8
|
+
if (!input) {
|
|
9
|
+
return input;
|
|
10
|
+
}
|
|
11
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
12
|
+
}
|
|
13
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
14
|
+
function cwd() {
|
|
15
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
16
|
+
return process.cwd().replace(/\\/g, "/");
|
|
17
|
+
}
|
|
18
|
+
return "/";
|
|
19
|
+
}
|
|
20
|
+
const resolve = function(...arguments_) {
|
|
21
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
22
|
+
let resolvedPath = "";
|
|
23
|
+
let resolvedAbsolute = false;
|
|
24
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
25
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
26
|
+
if (!path || path.length === 0) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
30
|
+
resolvedAbsolute = isAbsolute(path);
|
|
31
|
+
}
|
|
32
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
33
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
34
|
+
return `/${resolvedPath}`;
|
|
35
|
+
}
|
|
36
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
37
|
+
};
|
|
38
|
+
function normalizeString(path, allowAboveRoot) {
|
|
39
|
+
let res = "";
|
|
40
|
+
let lastSegmentLength = 0;
|
|
41
|
+
let lastSlash = -1;
|
|
42
|
+
let dots = 0;
|
|
43
|
+
let char = null;
|
|
44
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
45
|
+
if (index < path.length) {
|
|
46
|
+
char = path[index];
|
|
47
|
+
} else if (char === "/") {
|
|
48
|
+
break;
|
|
49
|
+
} else {
|
|
50
|
+
char = "/";
|
|
51
|
+
}
|
|
52
|
+
if (char === "/") {
|
|
53
|
+
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
54
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
55
|
+
if (res.length > 2) {
|
|
56
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
57
|
+
if (lastSlashIndex === -1) {
|
|
58
|
+
res = "";
|
|
59
|
+
lastSegmentLength = 0;
|
|
60
|
+
} else {
|
|
61
|
+
res = res.slice(0, lastSlashIndex);
|
|
62
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
63
|
+
}
|
|
64
|
+
lastSlash = index;
|
|
65
|
+
dots = 0;
|
|
66
|
+
continue;
|
|
67
|
+
} else if (res.length > 0) {
|
|
68
|
+
res = "";
|
|
69
|
+
lastSegmentLength = 0;
|
|
70
|
+
lastSlash = index;
|
|
71
|
+
dots = 0;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (allowAboveRoot) {
|
|
76
|
+
res += res.length > 0 ? "/.." : "..";
|
|
77
|
+
lastSegmentLength = 2;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
if (res.length > 0) {
|
|
81
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
82
|
+
} else {
|
|
83
|
+
res = path.slice(lastSlash + 1, index);
|
|
84
|
+
}
|
|
85
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
86
|
+
}
|
|
87
|
+
lastSlash = index;
|
|
88
|
+
dots = 0;
|
|
89
|
+
} else if (char === "." && dots !== -1) {
|
|
90
|
+
++dots;
|
|
91
|
+
} else {
|
|
92
|
+
dots = -1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return res;
|
|
96
|
+
}
|
|
97
|
+
const isAbsolute = function(p) {
|
|
98
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const distRoot = dirname(fileURLToPath(import.meta.url));
|
|
102
|
+
|
|
103
|
+
function preview() {
|
|
104
|
+
return defineBrowserProvider({
|
|
105
|
+
name: "preview",
|
|
106
|
+
providerFactory(project) {
|
|
107
|
+
return new PreviewBrowserProvider(project);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
class PreviewBrowserProvider {
|
|
112
|
+
name = "preview";
|
|
113
|
+
supportsParallelism = false;
|
|
114
|
+
project;
|
|
115
|
+
open = false;
|
|
116
|
+
distRoot = distRoot;
|
|
117
|
+
initScripts = [resolve(distRoot, "locators.js")];
|
|
118
|
+
constructor(project) {
|
|
119
|
+
this.project = project;
|
|
120
|
+
this.open = false;
|
|
121
|
+
if (project.config.browser.headless) {
|
|
122
|
+
throw new Error("You've enabled headless mode for \"preview\" provider but it doesn't support it. Use \"playwright\" or \"webdriverio\" instead: https://vitest.dev/guide/browser/#configuration");
|
|
123
|
+
}
|
|
124
|
+
nextTick(() => {
|
|
125
|
+
project.vitest.logger.printBrowserBanner(project);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
isOpen() {
|
|
129
|
+
return this.open;
|
|
130
|
+
}
|
|
131
|
+
getCommandsContext() {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
async openPage(_sessionId, url) {
|
|
135
|
+
this.open = true;
|
|
136
|
+
if (!this.project.browser) {
|
|
137
|
+
throw new Error("Browser is not initialized");
|
|
138
|
+
}
|
|
139
|
+
const options = this.project.browser.vite.config.server;
|
|
140
|
+
const _open = options.open;
|
|
141
|
+
options.open = url;
|
|
142
|
+
this.project.browser.vite.openBrowser();
|
|
143
|
+
options.open = _open;
|
|
144
|
+
}
|
|
145
|
+
async close() {}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { PreviewBrowserProvider, preview };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { selectorEngine, getByTitleSelector, getByTextSelector, getByPlaceholderSelector, getByAltTextSelector, getByTestIdSelector, getByRoleSelector, getByLabelSelector, Locator, convertElementToCssSelector } from '../browser/locators.js';
|
|
2
|
+
import { page } from '../browser/context.js';
|
|
3
|
+
import { utils, userEvent } from '../browser/index.js';
|
|
4
|
+
import { __INTERNAL } from '../../browser.js';
|
|
5
|
+
|
|
6
|
+
class PreviewLocator extends Locator {
|
|
7
|
+
constructor(_pwSelector, _container) {
|
|
8
|
+
super();
|
|
9
|
+
this._pwSelector = _pwSelector;
|
|
10
|
+
this._container = _container;
|
|
11
|
+
}
|
|
12
|
+
get selector() {
|
|
13
|
+
const selectors = this.elements().map((element) => convertElementToCssSelector(element));
|
|
14
|
+
if (!selectors.length) {
|
|
15
|
+
throw utils.getElementError(this._pwSelector, this._container || document.body);
|
|
16
|
+
}
|
|
17
|
+
return selectors.join(", ");
|
|
18
|
+
}
|
|
19
|
+
click() {
|
|
20
|
+
return userEvent.click(this.element());
|
|
21
|
+
}
|
|
22
|
+
dblClick() {
|
|
23
|
+
return userEvent.dblClick(this.element());
|
|
24
|
+
}
|
|
25
|
+
tripleClick() {
|
|
26
|
+
return userEvent.tripleClick(this.element());
|
|
27
|
+
}
|
|
28
|
+
hover() {
|
|
29
|
+
return userEvent.hover(this.element());
|
|
30
|
+
}
|
|
31
|
+
unhover() {
|
|
32
|
+
return userEvent.unhover(this.element());
|
|
33
|
+
}
|
|
34
|
+
async fill(text) {
|
|
35
|
+
return userEvent.fill(this.element(), text);
|
|
36
|
+
}
|
|
37
|
+
async upload(file) {
|
|
38
|
+
return userEvent.upload(this.element(), file);
|
|
39
|
+
}
|
|
40
|
+
selectOptions(options) {
|
|
41
|
+
return userEvent.selectOptions(this.element(), options);
|
|
42
|
+
}
|
|
43
|
+
clear() {
|
|
44
|
+
return userEvent.clear(this.element());
|
|
45
|
+
}
|
|
46
|
+
locator(selector) {
|
|
47
|
+
return new PreviewLocator(`${this._pwSelector} >> ${selector}`, this._container);
|
|
48
|
+
}
|
|
49
|
+
elementLocator(element) {
|
|
50
|
+
return new PreviewLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
page.extend({
|
|
54
|
+
getByLabelText(text, options) {
|
|
55
|
+
return new PreviewLocator(getByLabelSelector(text, options));
|
|
56
|
+
},
|
|
57
|
+
getByRole(role, options) {
|
|
58
|
+
return new PreviewLocator(getByRoleSelector(role, options));
|
|
59
|
+
},
|
|
60
|
+
getByTestId(testId) {
|
|
61
|
+
return new PreviewLocator(getByTestIdSelector(window.__vitest_worker__.config.browser.locators.testIdAttribute, testId));
|
|
62
|
+
},
|
|
63
|
+
getByAltText(text, options) {
|
|
64
|
+
return new PreviewLocator(getByAltTextSelector(text, options));
|
|
65
|
+
},
|
|
66
|
+
getByPlaceholder(text, options) {
|
|
67
|
+
return new PreviewLocator(getByPlaceholderSelector(text, options));
|
|
68
|
+
},
|
|
69
|
+
getByText(text, options) {
|
|
70
|
+
return new PreviewLocator(getByTextSelector(text, options));
|
|
71
|
+
},
|
|
72
|
+
getByTitle(title, options) {
|
|
73
|
+
return new PreviewLocator(getByTitleSelector(title, options));
|
|
74
|
+
},
|
|
75
|
+
elementLocator(element) {
|
|
76
|
+
return new PreviewLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
__INTERNAL._createLocator = (selector) => new PreviewLocator(selector);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../browser/context.js'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { CustomComparatorsRegistry } from '../browser/index.js';
|
|
2
|
+
export { defineBrowserCommand } from '../browser/index.js';
|
|
3
|
+
import { ScreenshotMatcherOptions, ScreenshotComparatorRegistry } from '../browser/index.js';
|
|
4
|
+
import { BrowserProvider, TestProject, CDPSession, BrowserProviderOption } from '../../node.js';
|
|
5
|
+
import { ClickOptions, MoveToOptions, DragAndDropOptions, remote } from 'webdriverio';
|
|
6
|
+
|
|
7
|
+
declare const webdriverBrowsers: readonly ["firefox", "chrome", "edge", "safari"];
|
|
8
|
+
type WebdriverBrowser = (typeof webdriverBrowsers)[number];
|
|
9
|
+
interface WebdriverProviderOptions extends Partial<Parameters<typeof remote>[0]> {}
|
|
10
|
+
declare function webdriverio(options?: WebdriverProviderOptions): BrowserProviderOption<WebdriverProviderOptions>;
|
|
11
|
+
declare class WebdriverBrowserProvider implements BrowserProvider {
|
|
12
|
+
name: "webdriverio";
|
|
13
|
+
supportsParallelism: boolean;
|
|
14
|
+
browser: WebdriverIO.Browser | null;
|
|
15
|
+
private browserName;
|
|
16
|
+
private project;
|
|
17
|
+
private options?;
|
|
18
|
+
private closing;
|
|
19
|
+
private iframeSwitched;
|
|
20
|
+
private topLevelContext;
|
|
21
|
+
initScripts: string[];
|
|
22
|
+
getSupportedBrowsers(): readonly string[];
|
|
23
|
+
constructor(project: TestProject, options: WebdriverProviderOptions);
|
|
24
|
+
isIframeSwitched(): boolean;
|
|
25
|
+
switchToTestFrame(): Promise<void>;
|
|
26
|
+
switchToMainFrame(): Promise<void>;
|
|
27
|
+
setViewport(options: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
getCommandsContext(): {
|
|
32
|
+
browser: WebdriverIO.Browser | null;
|
|
33
|
+
};
|
|
34
|
+
openBrowser(): Promise<WebdriverIO.Browser>;
|
|
35
|
+
private buildCapabilities;
|
|
36
|
+
openPage(sessionId: string, url: string): Promise<void>;
|
|
37
|
+
private _throwIfClosing;
|
|
38
|
+
close(): Promise<void>;
|
|
39
|
+
getCDPSession(_sessionId: string): Promise<CDPSession>;
|
|
40
|
+
}
|
|
41
|
+
declare module "vitest/browser" {
|
|
42
|
+
interface UserEventClickOptions extends Partial<ClickOptions> {}
|
|
43
|
+
interface UserEventHoverOptions extends MoveToOptions {}
|
|
44
|
+
interface UserEventDragAndDropOptions extends DragAndDropOptions {
|
|
45
|
+
sourceX?: number;
|
|
46
|
+
sourceY?: number;
|
|
47
|
+
targetX?: number;
|
|
48
|
+
targetY?: number;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
declare module "vitest/node" {
|
|
52
|
+
interface BrowserCommandContext {
|
|
53
|
+
browser: WebdriverIO.Browser;
|
|
54
|
+
}
|
|
55
|
+
interface _BrowserNames {
|
|
56
|
+
webdriverio: WebdriverBrowser;
|
|
57
|
+
}
|
|
58
|
+
interface ToMatchScreenshotOptions extends Omit<ScreenshotMatcherOptions, "comparatorName" | "comparatorOptions">, CustomComparatorsRegistry {}
|
|
59
|
+
interface ToMatchScreenshotComparators extends ScreenshotComparatorRegistry {}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { WebdriverBrowserProvider, webdriverio };
|
|
63
|
+
export type { WebdriverProviderOptions };
|