@pedropaulovc/playwright 1.59.0-next
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/ThirdPartyNotices.txt +5042 -0
- package/cli.js +19 -0
- package/index.d.ts +17 -0
- package/index.js +17 -0
- package/index.mjs +18 -0
- package/jsx-runtime.js +42 -0
- package/jsx-runtime.mjs +21 -0
- package/lib/agents/agentParser.js +89 -0
- package/lib/agents/copilot-setup-steps.yml +34 -0
- package/lib/agents/generateAgents.js +348 -0
- package/lib/agents/playwright-test-coverage.prompt.md +31 -0
- package/lib/agents/playwright-test-generate.prompt.md +8 -0
- package/lib/agents/playwright-test-generator.agent.md +88 -0
- package/lib/agents/playwright-test-heal.prompt.md +6 -0
- package/lib/agents/playwright-test-healer.agent.md +55 -0
- package/lib/agents/playwright-test-plan.prompt.md +9 -0
- package/lib/agents/playwright-test-planner.agent.md +73 -0
- package/lib/common/config.js +282 -0
- package/lib/common/configLoader.js +344 -0
- package/lib/common/esmLoaderHost.js +104 -0
- package/lib/common/expectBundle.js +28 -0
- package/lib/common/expectBundleImpl.js +407 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/process.js +132 -0
- package/lib/common/suiteUtils.js +140 -0
- package/lib/common/test.js +321 -0
- package/lib/common/testLoader.js +101 -0
- package/lib/common/testType.js +298 -0
- package/lib/common/validators.js +68 -0
- package/lib/fsWatcher.js +67 -0
- package/lib/index.js +726 -0
- package/lib/internalsForTest.js +42 -0
- package/lib/isomorphic/events.js +77 -0
- package/lib/isomorphic/folders.js +30 -0
- package/lib/isomorphic/stringInternPool.js +69 -0
- package/lib/isomorphic/teleReceiver.js +521 -0
- package/lib/isomorphic/teleSuiteUpdater.js +157 -0
- package/lib/isomorphic/testServerConnection.js +225 -0
- package/lib/isomorphic/testServerInterface.js +16 -0
- package/lib/isomorphic/testTree.js +329 -0
- package/lib/isomorphic/types.d.js +16 -0
- package/lib/loader/loaderMain.js +59 -0
- package/lib/matchers/expect.js +311 -0
- package/lib/matchers/matcherHint.js +44 -0
- package/lib/matchers/matchers.js +383 -0
- package/lib/matchers/toBeTruthy.js +75 -0
- package/lib/matchers/toEqual.js +100 -0
- package/lib/matchers/toHaveURL.js +101 -0
- package/lib/matchers/toMatchAriaSnapshot.js +159 -0
- package/lib/matchers/toMatchSnapshot.js +342 -0
- package/lib/matchers/toMatchText.js +99 -0
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/browserContextFactory.js +329 -0
- package/lib/mcp/browser/browserServerBackend.js +84 -0
- package/lib/mcp/browser/config.js +421 -0
- package/lib/mcp/browser/context.js +244 -0
- package/lib/mcp/browser/response.js +278 -0
- package/lib/mcp/browser/sessionLog.js +75 -0
- package/lib/mcp/browser/tab.js +351 -0
- package/lib/mcp/browser/tools/common.js +65 -0
- package/lib/mcp/browser/tools/console.js +61 -0
- package/lib/mcp/browser/tools/dialogs.js +60 -0
- package/lib/mcp/browser/tools/evaluate.js +61 -0
- package/lib/mcp/browser/tools/files.js +58 -0
- package/lib/mcp/browser/tools/form.js +63 -0
- package/lib/mcp/browser/tools/install.js +72 -0
- package/lib/mcp/browser/tools/keyboard.js +144 -0
- package/lib/mcp/browser/tools/mouse.js +159 -0
- package/lib/mcp/browser/tools/navigate.js +136 -0
- package/lib/mcp/browser/tools/navigateAndWait.js +66 -0
- package/lib/mcp/browser/tools/network.js +78 -0
- package/lib/mcp/browser/tools/pdf.js +49 -0
- package/lib/mcp/browser/tools/runCode.js +78 -0
- package/lib/mcp/browser/tools/screenshot.js +93 -0
- package/lib/mcp/browser/tools/snapshot.js +205 -0
- package/lib/mcp/browser/tools/snapshotViewport.js +63 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +47 -0
- package/lib/mcp/browser/tools/tracing.js +74 -0
- package/lib/mcp/browser/tools/utils.js +94 -0
- package/lib/mcp/browser/tools/verify.js +143 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools.js +82 -0
- package/lib/mcp/browser/watchdog.js +44 -0
- package/lib/mcp/config.d.js +16 -0
- package/lib/mcp/extension/cdpRelay.js +351 -0
- package/lib/mcp/extension/extensionContextFactory.js +76 -0
- package/lib/mcp/extension/protocol.js +28 -0
- package/lib/mcp/index.js +61 -0
- package/lib/mcp/log.js +35 -0
- package/lib/mcp/program.js +110 -0
- package/lib/mcp/sdk/exports.js +28 -0
- package/lib/mcp/sdk/http.js +152 -0
- package/lib/mcp/sdk/inProcessTransport.js +71 -0
- package/lib/mcp/sdk/server.js +223 -0
- package/lib/mcp/sdk/tool.js +47 -0
- package/lib/mcp/terminal/cli.js +296 -0
- package/lib/mcp/terminal/command.js +56 -0
- package/lib/mcp/terminal/commands.js +519 -0
- package/lib/mcp/terminal/daemon.js +135 -0
- package/lib/mcp/terminal/help.json +47 -0
- package/lib/mcp/terminal/helpGenerator.js +115 -0
- package/lib/mcp/terminal/socketConnection.js +80 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/plannerTools.js +145 -0
- package/lib/mcp/test/seed.js +82 -0
- package/lib/mcp/test/streams.js +44 -0
- package/lib/mcp/test/testBackend.js +99 -0
- package/lib/mcp/test/testContext.js +285 -0
- package/lib/mcp/test/testTool.js +30 -0
- package/lib/mcp/test/testTools.js +108 -0
- package/lib/plugins/gitCommitInfoPlugin.js +198 -0
- package/lib/plugins/index.js +28 -0
- package/lib/plugins/webServerPlugin.js +237 -0
- package/lib/program.js +417 -0
- package/lib/reporters/base.js +634 -0
- package/lib/reporters/blob.js +138 -0
- package/lib/reporters/dot.js +99 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/github.js +128 -0
- package/lib/reporters/html.js +633 -0
- package/lib/reporters/internalReporter.js +138 -0
- package/lib/reporters/json.js +254 -0
- package/lib/reporters/junit.js +232 -0
- package/lib/reporters/line.js +131 -0
- package/lib/reporters/list.js +253 -0
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/markdown.js +144 -0
- package/lib/reporters/merge.js +558 -0
- package/lib/reporters/multiplexer.js +112 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/teleEmitter.js +317 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/runner/dispatcher.js +530 -0
- package/lib/runner/failureTracker.js +72 -0
- package/lib/runner/lastRun.js +77 -0
- package/lib/runner/loadUtils.js +334 -0
- package/lib/runner/loaderHost.js +89 -0
- package/lib/runner/processHost.js +180 -0
- package/lib/runner/projectUtils.js +241 -0
- package/lib/runner/rebase.js +189 -0
- package/lib/runner/reporters.js +138 -0
- package/lib/runner/sigIntWatcher.js +96 -0
- package/lib/runner/storage.js +91 -0
- package/lib/runner/taskRunner.js +127 -0
- package/lib/runner/tasks.js +410 -0
- package/lib/runner/testGroups.js +125 -0
- package/lib/runner/testRunner.js +398 -0
- package/lib/runner/testServer.js +269 -0
- package/lib/runner/uiModeReporter.js +30 -0
- package/lib/runner/vcs.js +72 -0
- package/lib/runner/watchMode.js +396 -0
- package/lib/runner/workerHost.js +104 -0
- package/lib/third_party/pirates.js +62 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/transform/babelBundle.js +46 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/compilationCache.js +274 -0
- package/lib/transform/esmLoader.js +103 -0
- package/lib/transform/md.js +221 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/transform.js +303 -0
- package/lib/util.js +400 -0
- package/lib/utilsBundle.js +50 -0
- package/lib/utilsBundleImpl.js +103 -0
- package/lib/worker/fixtureRunner.js +262 -0
- package/lib/worker/testInfo.js +536 -0
- package/lib/worker/testTracing.js +345 -0
- package/lib/worker/timeoutManager.js +174 -0
- package/lib/worker/util.js +31 -0
- package/lib/worker/workerMain.js +530 -0
- package/package.json +72 -0
- package/test.d.ts +18 -0
- package/test.js +24 -0
- package/test.mjs +34 -0
- package/types/test.d.ts +10251 -0
- package/types/testReporter.d.ts +822 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var matchers_exports = {};
|
|
20
|
+
__export(matchers_exports, {
|
|
21
|
+
computeMatcherTitleSuffix: () => computeMatcherTitleSuffix,
|
|
22
|
+
toBeAttached: () => toBeAttached,
|
|
23
|
+
toBeChecked: () => toBeChecked,
|
|
24
|
+
toBeDisabled: () => toBeDisabled,
|
|
25
|
+
toBeEditable: () => toBeEditable,
|
|
26
|
+
toBeEmpty: () => toBeEmpty,
|
|
27
|
+
toBeEnabled: () => toBeEnabled,
|
|
28
|
+
toBeFocused: () => toBeFocused,
|
|
29
|
+
toBeHidden: () => toBeHidden,
|
|
30
|
+
toBeInViewport: () => toBeInViewport,
|
|
31
|
+
toBeOK: () => toBeOK,
|
|
32
|
+
toBeVisible: () => toBeVisible,
|
|
33
|
+
toContainClass: () => toContainClass,
|
|
34
|
+
toContainText: () => toContainText,
|
|
35
|
+
toHaveAccessibleDescription: () => toHaveAccessibleDescription,
|
|
36
|
+
toHaveAccessibleErrorMessage: () => toHaveAccessibleErrorMessage,
|
|
37
|
+
toHaveAccessibleName: () => toHaveAccessibleName,
|
|
38
|
+
toHaveAttribute: () => toHaveAttribute,
|
|
39
|
+
toHaveCSS: () => toHaveCSS,
|
|
40
|
+
toHaveClass: () => toHaveClass,
|
|
41
|
+
toHaveCount: () => toHaveCount,
|
|
42
|
+
toHaveId: () => toHaveId,
|
|
43
|
+
toHaveJSProperty: () => toHaveJSProperty,
|
|
44
|
+
toHaveRole: () => toHaveRole,
|
|
45
|
+
toHaveText: () => toHaveText,
|
|
46
|
+
toHaveTitle: () => toHaveTitle,
|
|
47
|
+
toHaveURL: () => toHaveURL,
|
|
48
|
+
toHaveValue: () => toHaveValue,
|
|
49
|
+
toHaveValues: () => toHaveValues,
|
|
50
|
+
toPass: () => toPass
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(matchers_exports);
|
|
53
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
54
|
+
var import_utils2 = require("playwright-core/lib/utils");
|
|
55
|
+
var import_util = require("../util");
|
|
56
|
+
var import_toBeTruthy = require("./toBeTruthy");
|
|
57
|
+
var import_toEqual = require("./toEqual");
|
|
58
|
+
var import_toHaveURL = require("./toHaveURL");
|
|
59
|
+
var import_toMatchText = require("./toMatchText");
|
|
60
|
+
var import_toMatchSnapshot = require("./toMatchSnapshot");
|
|
61
|
+
var import_config = require("../common/config");
|
|
62
|
+
var import_globals = require("../common/globals");
|
|
63
|
+
var import_testInfo = require("../worker/testInfo");
|
|
64
|
+
function toBeAttached(locator, options) {
|
|
65
|
+
const attached = !options || options.attached === void 0 || options.attached;
|
|
66
|
+
const expected = attached ? "attached" : "detached";
|
|
67
|
+
const arg = attached ? "" : "{ attached: false }";
|
|
68
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeAttached", locator, "Locator", expected, arg, async (isNot, timeout) => {
|
|
69
|
+
return await locator._expect(attached ? "to.be.attached" : "to.be.detached", { isNot, timeout });
|
|
70
|
+
}, options);
|
|
71
|
+
}
|
|
72
|
+
function toBeChecked(locator, options) {
|
|
73
|
+
const checked = options?.checked;
|
|
74
|
+
const indeterminate = options?.indeterminate;
|
|
75
|
+
const expectedValue = {
|
|
76
|
+
checked,
|
|
77
|
+
indeterminate
|
|
78
|
+
};
|
|
79
|
+
let expected;
|
|
80
|
+
let arg;
|
|
81
|
+
if (options?.indeterminate) {
|
|
82
|
+
expected = "indeterminate";
|
|
83
|
+
arg = `{ indeterminate: true }`;
|
|
84
|
+
} else {
|
|
85
|
+
expected = options?.checked === false ? "unchecked" : "checked";
|
|
86
|
+
arg = options?.checked === false ? `{ checked: false }` : "";
|
|
87
|
+
}
|
|
88
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeChecked", locator, "Locator", expected, arg, async (isNot, timeout) => {
|
|
89
|
+
return await locator._expect("to.be.checked", { isNot, timeout, expectedValue });
|
|
90
|
+
}, options);
|
|
91
|
+
}
|
|
92
|
+
function toBeDisabled(locator, options) {
|
|
93
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeDisabled", locator, "Locator", "disabled", "", async (isNot, timeout) => {
|
|
94
|
+
return await locator._expect("to.be.disabled", { isNot, timeout });
|
|
95
|
+
}, options);
|
|
96
|
+
}
|
|
97
|
+
function toBeEditable(locator, options) {
|
|
98
|
+
const editable = !options || options.editable === void 0 || options.editable;
|
|
99
|
+
const expected = editable ? "editable" : "readOnly";
|
|
100
|
+
const arg = editable ? "" : "{ editable: false }";
|
|
101
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeEditable", locator, "Locator", expected, arg, async (isNot, timeout) => {
|
|
102
|
+
return await locator._expect(editable ? "to.be.editable" : "to.be.readonly", { isNot, timeout });
|
|
103
|
+
}, options);
|
|
104
|
+
}
|
|
105
|
+
function toBeEmpty(locator, options) {
|
|
106
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeEmpty", locator, "Locator", "empty", "", async (isNot, timeout) => {
|
|
107
|
+
return await locator._expect("to.be.empty", { isNot, timeout });
|
|
108
|
+
}, options);
|
|
109
|
+
}
|
|
110
|
+
function toBeEnabled(locator, options) {
|
|
111
|
+
const enabled = !options || options.enabled === void 0 || options.enabled;
|
|
112
|
+
const expected = enabled ? "enabled" : "disabled";
|
|
113
|
+
const arg = enabled ? "" : "{ enabled: false }";
|
|
114
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeEnabled", locator, "Locator", expected, arg, async (isNot, timeout) => {
|
|
115
|
+
return await locator._expect(enabled ? "to.be.enabled" : "to.be.disabled", { isNot, timeout });
|
|
116
|
+
}, options);
|
|
117
|
+
}
|
|
118
|
+
function toBeFocused(locator, options) {
|
|
119
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeFocused", locator, "Locator", "focused", "", async (isNot, timeout) => {
|
|
120
|
+
return await locator._expect("to.be.focused", { isNot, timeout });
|
|
121
|
+
}, options);
|
|
122
|
+
}
|
|
123
|
+
function toBeHidden(locator, options) {
|
|
124
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeHidden", locator, "Locator", "hidden", "", async (isNot, timeout) => {
|
|
125
|
+
return await locator._expect("to.be.hidden", { isNot, timeout });
|
|
126
|
+
}, options);
|
|
127
|
+
}
|
|
128
|
+
function toBeVisible(locator, options) {
|
|
129
|
+
const visible = !options || options.visible === void 0 || options.visible;
|
|
130
|
+
const expected = visible ? "visible" : "hidden";
|
|
131
|
+
const arg = visible ? "" : "{ visible: false }";
|
|
132
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeVisible", locator, "Locator", expected, arg, async (isNot, timeout) => {
|
|
133
|
+
return await locator._expect(visible ? "to.be.visible" : "to.be.hidden", { isNot, timeout });
|
|
134
|
+
}, options);
|
|
135
|
+
}
|
|
136
|
+
function toBeInViewport(locator, options) {
|
|
137
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toBeInViewport", locator, "Locator", "in viewport", "", async (isNot, timeout) => {
|
|
138
|
+
return await locator._expect("to.be.in.viewport", { isNot, expectedNumber: options?.ratio, timeout });
|
|
139
|
+
}, options);
|
|
140
|
+
}
|
|
141
|
+
function toContainText(locator, expected, options = {}) {
|
|
142
|
+
if (Array.isArray(expected)) {
|
|
143
|
+
return import_toEqual.toEqual.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
|
|
144
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
|
145
|
+
return await locator._expect("to.contain.text.array", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
|
|
146
|
+
}, expected, { ...options, contains: true });
|
|
147
|
+
} else {
|
|
148
|
+
return import_toMatchText.toMatchText.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
|
|
149
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
|
150
|
+
return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
|
|
151
|
+
}, expected, { ...options, matchSubstring: true });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function toHaveAccessibleDescription(locator, expected, options) {
|
|
155
|
+
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleDescription", locator, "Locator", async (isNot, timeout) => {
|
|
156
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
|
|
157
|
+
return await locator._expect("to.have.accessible.description", { expectedText, isNot, timeout });
|
|
158
|
+
}, expected, options);
|
|
159
|
+
}
|
|
160
|
+
function toHaveAccessibleName(locator, expected, options) {
|
|
161
|
+
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleName", locator, "Locator", async (isNot, timeout) => {
|
|
162
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
|
|
163
|
+
return await locator._expect("to.have.accessible.name", { expectedText, isNot, timeout });
|
|
164
|
+
}, expected, options);
|
|
165
|
+
}
|
|
166
|
+
function toHaveAccessibleErrorMessage(locator, expected, options) {
|
|
167
|
+
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleErrorMessage", locator, "Locator", async (isNot, timeout) => {
|
|
168
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
|
|
169
|
+
return await locator._expect("to.have.accessible.error.message", { expectedText, isNot, timeout });
|
|
170
|
+
}, expected, options);
|
|
171
|
+
}
|
|
172
|
+
function toHaveAttribute(locator, name, expected, options) {
|
|
173
|
+
if (!options) {
|
|
174
|
+
if (typeof expected === "object" && !(0, import_utils.isRegExp)(expected)) {
|
|
175
|
+
options = expected;
|
|
176
|
+
expected = void 0;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (expected === void 0) {
|
|
180
|
+
return import_toBeTruthy.toBeTruthy.call(this, "toHaveAttribute", locator, "Locator", "have attribute", "", async (isNot, timeout) => {
|
|
181
|
+
return await locator._expect("to.have.attribute", { expressionArg: name, isNot, timeout });
|
|
182
|
+
}, options);
|
|
183
|
+
}
|
|
184
|
+
return import_toMatchText.toMatchText.call(this, "toHaveAttribute", locator, "Locator", async (isNot, timeout) => {
|
|
185
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
|
|
186
|
+
return await locator._expect("to.have.attribute.value", { expressionArg: name, expectedText, isNot, timeout });
|
|
187
|
+
}, expected, options);
|
|
188
|
+
}
|
|
189
|
+
function toHaveClass(locator, expected, options) {
|
|
190
|
+
if (Array.isArray(expected)) {
|
|
191
|
+
return import_toEqual.toEqual.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
|
|
192
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
|
|
193
|
+
return await locator._expect("to.have.class.array", { expectedText, isNot, timeout });
|
|
194
|
+
}, expected, options);
|
|
195
|
+
} else {
|
|
196
|
+
return import_toMatchText.toMatchText.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
|
|
197
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
|
|
198
|
+
return await locator._expect("to.have.class", { expectedText, isNot, timeout });
|
|
199
|
+
}, expected, options);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function toContainClass(locator, expected, options) {
|
|
203
|
+
if (Array.isArray(expected)) {
|
|
204
|
+
if (expected.some((e) => (0, import_utils.isRegExp)(e)))
|
|
205
|
+
throw new Error(`"expected" argument in toContainClass cannot contain RegExp values`);
|
|
206
|
+
return import_toEqual.toEqual.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
|
|
207
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
|
|
208
|
+
return await locator._expect("to.contain.class.array", { expectedText, isNot, timeout });
|
|
209
|
+
}, expected, options);
|
|
210
|
+
} else {
|
|
211
|
+
if ((0, import_utils.isRegExp)(expected))
|
|
212
|
+
throw new Error(`"expected" argument in toContainClass cannot be a RegExp value`);
|
|
213
|
+
return import_toMatchText.toMatchText.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
|
|
214
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
|
|
215
|
+
return await locator._expect("to.contain.class", { expectedText, isNot, timeout });
|
|
216
|
+
}, expected, options);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function toHaveCount(locator, expected, options) {
|
|
220
|
+
return import_toEqual.toEqual.call(this, "toHaveCount", locator, "Locator", async (isNot, timeout) => {
|
|
221
|
+
return await locator._expect("to.have.count", { expectedNumber: expected, isNot, timeout });
|
|
222
|
+
}, expected, options);
|
|
223
|
+
}
|
|
224
|
+
function toHaveCSS(locator, name, expected, options) {
|
|
225
|
+
return import_toMatchText.toMatchText.call(this, "toHaveCSS", locator, "Locator", async (isNot, timeout) => {
|
|
226
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
|
|
227
|
+
return await locator._expect("to.have.css", { expressionArg: name, expectedText, isNot, timeout });
|
|
228
|
+
}, expected, options);
|
|
229
|
+
}
|
|
230
|
+
function toHaveId(locator, expected, options) {
|
|
231
|
+
return import_toMatchText.toMatchText.call(this, "toHaveId", locator, "Locator", async (isNot, timeout) => {
|
|
232
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
|
|
233
|
+
return await locator._expect("to.have.id", { expectedText, isNot, timeout });
|
|
234
|
+
}, expected, options);
|
|
235
|
+
}
|
|
236
|
+
function toHaveJSProperty(locator, name, expected, options) {
|
|
237
|
+
return import_toEqual.toEqual.call(this, "toHaveJSProperty", locator, "Locator", async (isNot, timeout) => {
|
|
238
|
+
return await locator._expect("to.have.property", { expressionArg: name, expectedValue: expected, isNot, timeout });
|
|
239
|
+
}, expected, options);
|
|
240
|
+
}
|
|
241
|
+
function toHaveRole(locator, expected, options) {
|
|
242
|
+
if (!(0, import_utils.isString)(expected))
|
|
243
|
+
throw new Error(`"role" argument in toHaveRole must be a string`);
|
|
244
|
+
return import_toMatchText.toMatchText.call(this, "toHaveRole", locator, "Locator", async (isNot, timeout) => {
|
|
245
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
|
|
246
|
+
return await locator._expect("to.have.role", { expectedText, isNot, timeout });
|
|
247
|
+
}, expected, options);
|
|
248
|
+
}
|
|
249
|
+
function toHaveText(locator, expected, options = {}) {
|
|
250
|
+
if (Array.isArray(expected)) {
|
|
251
|
+
return import_toEqual.toEqual.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
|
|
252
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
|
253
|
+
return await locator._expect("to.have.text.array", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
|
|
254
|
+
}, expected, options);
|
|
255
|
+
} else {
|
|
256
|
+
return import_toMatchText.toMatchText.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
|
|
257
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
|
258
|
+
return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
|
|
259
|
+
}, expected, options);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function toHaveValue(locator, expected, options) {
|
|
263
|
+
return import_toMatchText.toMatchText.call(this, "toHaveValue", locator, "Locator", async (isNot, timeout) => {
|
|
264
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
|
|
265
|
+
return await locator._expect("to.have.value", { expectedText, isNot, timeout });
|
|
266
|
+
}, expected, options);
|
|
267
|
+
}
|
|
268
|
+
function toHaveValues(locator, expected, options) {
|
|
269
|
+
return import_toEqual.toEqual.call(this, "toHaveValues", locator, "Locator", async (isNot, timeout) => {
|
|
270
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
|
|
271
|
+
return await locator._expect("to.have.values", { expectedText, isNot, timeout });
|
|
272
|
+
}, expected, options);
|
|
273
|
+
}
|
|
274
|
+
function toHaveTitle(page, expected, options = {}) {
|
|
275
|
+
return import_toMatchText.toMatchText.call(this, "toHaveTitle", page, "Page", async (isNot, timeout) => {
|
|
276
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true });
|
|
277
|
+
return await page.mainFrame()._expect("to.have.title", { expectedText, isNot, timeout });
|
|
278
|
+
}, expected, options);
|
|
279
|
+
}
|
|
280
|
+
function toHaveURL(page, expected, options) {
|
|
281
|
+
if (typeof expected === "function")
|
|
282
|
+
return import_toHaveURL.toHaveURLWithPredicate.call(this, page, expected, options);
|
|
283
|
+
const baseURL = page.context()._options.baseURL;
|
|
284
|
+
expected = typeof expected === "string" ? (0, import_utils.constructURLBasedOnBaseURL)(baseURL, expected) : expected;
|
|
285
|
+
return import_toMatchText.toMatchText.call(this, "toHaveURL", page, "Page", async (isNot, timeout) => {
|
|
286
|
+
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
|
|
287
|
+
return await page.mainFrame()._expect("to.have.url", { expectedText, isNot, timeout });
|
|
288
|
+
}, expected, options);
|
|
289
|
+
}
|
|
290
|
+
async function toBeOK(response) {
|
|
291
|
+
const matcherName = "toBeOK";
|
|
292
|
+
(0, import_util.expectTypes)(response, ["APIResponse"], matcherName);
|
|
293
|
+
const contentType = response.headers()["content-type"];
|
|
294
|
+
const isTextEncoding = contentType && (0, import_utils.isTextualMimeType)(contentType);
|
|
295
|
+
const [log, text] = this.isNot === response.ok() ? await Promise.all([
|
|
296
|
+
response._fetchLog(),
|
|
297
|
+
isTextEncoding ? response.text() : null
|
|
298
|
+
]) : [];
|
|
299
|
+
const message = () => (0, import_utils.formatMatcherMessage)(this.utils, {
|
|
300
|
+
isNot: this.isNot,
|
|
301
|
+
promise: this.promise,
|
|
302
|
+
matcherName,
|
|
303
|
+
receiver: "response",
|
|
304
|
+
expectation: "",
|
|
305
|
+
log
|
|
306
|
+
}) + (text === null ? "" : `
|
|
307
|
+
Response text:
|
|
308
|
+
${import_utils2.colors.dim(text?.substring(0, 1e3) || "")}`);
|
|
309
|
+
const pass = response.ok();
|
|
310
|
+
return { message, pass };
|
|
311
|
+
}
|
|
312
|
+
async function toPass(callback, options = {}) {
|
|
313
|
+
const testInfo = (0, import_globals.currentTestInfo)();
|
|
314
|
+
const timeout = (0, import_config.takeFirst)(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);
|
|
315
|
+
const intervals = (0, import_config.takeFirst)(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1e3]);
|
|
316
|
+
const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
|
|
317
|
+
const result = await (0, import_utils.pollAgainstDeadline)(async () => {
|
|
318
|
+
if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
|
|
319
|
+
return { continuePolling: false, result: void 0 };
|
|
320
|
+
try {
|
|
321
|
+
await callback();
|
|
322
|
+
return { continuePolling: !!this.isNot, result: void 0 };
|
|
323
|
+
} catch (e) {
|
|
324
|
+
return { continuePolling: !this.isNot, result: e };
|
|
325
|
+
}
|
|
326
|
+
}, deadline, intervals);
|
|
327
|
+
if (result.timedOut) {
|
|
328
|
+
const message = result.result ? [
|
|
329
|
+
result.result.message,
|
|
330
|
+
"",
|
|
331
|
+
`Call Log:`,
|
|
332
|
+
`- ${timeoutMessage}`
|
|
333
|
+
].join("\n") : timeoutMessage;
|
|
334
|
+
return { message: () => message, pass: !!this.isNot };
|
|
335
|
+
}
|
|
336
|
+
return { pass: !this.isNot, message: () => "" };
|
|
337
|
+
}
|
|
338
|
+
function computeMatcherTitleSuffix(matcherName, receiver, args) {
|
|
339
|
+
if (matcherName === "toHaveScreenshot") {
|
|
340
|
+
const title = (0, import_toMatchSnapshot.toHaveScreenshotStepTitle)(...args);
|
|
341
|
+
return { short: title ? `(${title})` : "" };
|
|
342
|
+
}
|
|
343
|
+
if (receiver && typeof receiver === "object" && receiver.constructor?.name === "Locator") {
|
|
344
|
+
try {
|
|
345
|
+
return { long: " " + (0, import_utils.asLocatorDescription)("javascript", receiver._selector) };
|
|
346
|
+
} catch {
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return {};
|
|
350
|
+
}
|
|
351
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
352
|
+
0 && (module.exports = {
|
|
353
|
+
computeMatcherTitleSuffix,
|
|
354
|
+
toBeAttached,
|
|
355
|
+
toBeChecked,
|
|
356
|
+
toBeDisabled,
|
|
357
|
+
toBeEditable,
|
|
358
|
+
toBeEmpty,
|
|
359
|
+
toBeEnabled,
|
|
360
|
+
toBeFocused,
|
|
361
|
+
toBeHidden,
|
|
362
|
+
toBeInViewport,
|
|
363
|
+
toBeOK,
|
|
364
|
+
toBeVisible,
|
|
365
|
+
toContainClass,
|
|
366
|
+
toContainText,
|
|
367
|
+
toHaveAccessibleDescription,
|
|
368
|
+
toHaveAccessibleErrorMessage,
|
|
369
|
+
toHaveAccessibleName,
|
|
370
|
+
toHaveAttribute,
|
|
371
|
+
toHaveCSS,
|
|
372
|
+
toHaveClass,
|
|
373
|
+
toHaveCount,
|
|
374
|
+
toHaveId,
|
|
375
|
+
toHaveJSProperty,
|
|
376
|
+
toHaveRole,
|
|
377
|
+
toHaveText,
|
|
378
|
+
toHaveTitle,
|
|
379
|
+
toHaveURL,
|
|
380
|
+
toHaveValue,
|
|
381
|
+
toHaveValues,
|
|
382
|
+
toPass
|
|
383
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var toBeTruthy_exports = {};
|
|
20
|
+
__export(toBeTruthy_exports, {
|
|
21
|
+
toBeTruthy: () => toBeTruthy
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(toBeTruthy_exports);
|
|
24
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
25
|
+
var import_util = require("../util");
|
|
26
|
+
async function toBeTruthy(matcherName, locator, receiverType, expected, arg, query, options = {}) {
|
|
27
|
+
(0, import_util.expectTypes)(locator, [receiverType], matcherName);
|
|
28
|
+
const timeout = options.timeout ?? this.timeout;
|
|
29
|
+
const { matches: pass, log, timedOut, received, errorMessage } = await query(!!this.isNot, timeout);
|
|
30
|
+
if (pass === !this.isNot) {
|
|
31
|
+
return {
|
|
32
|
+
name: matcherName,
|
|
33
|
+
message: () => "",
|
|
34
|
+
pass,
|
|
35
|
+
expected
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
let printedReceived;
|
|
39
|
+
let printedExpected;
|
|
40
|
+
if (pass) {
|
|
41
|
+
printedExpected = `Expected: not ${expected}`;
|
|
42
|
+
printedReceived = errorMessage ? "" : `Received: ${expected}`;
|
|
43
|
+
} else {
|
|
44
|
+
printedExpected = `Expected: ${expected}`;
|
|
45
|
+
printedReceived = errorMessage ? "" : `Received: ${received}`;
|
|
46
|
+
}
|
|
47
|
+
const message = () => {
|
|
48
|
+
return (0, import_utils.formatMatcherMessage)(this.utils, {
|
|
49
|
+
isNot: this.isNot,
|
|
50
|
+
promise: this.promise,
|
|
51
|
+
matcherName,
|
|
52
|
+
expectation: arg,
|
|
53
|
+
locator: locator.toString(),
|
|
54
|
+
timeout,
|
|
55
|
+
timedOut,
|
|
56
|
+
printedExpected,
|
|
57
|
+
printedReceived,
|
|
58
|
+
errorMessage,
|
|
59
|
+
log
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
message,
|
|
64
|
+
pass,
|
|
65
|
+
actual: received,
|
|
66
|
+
name: matcherName,
|
|
67
|
+
expected,
|
|
68
|
+
log,
|
|
69
|
+
timeout: timedOut ? timeout : void 0
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
toBeTruthy
|
|
75
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var toEqual_exports = {};
|
|
20
|
+
__export(toEqual_exports, {
|
|
21
|
+
toEqual: () => toEqual
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(toEqual_exports);
|
|
24
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
25
|
+
var import_util = require("../util");
|
|
26
|
+
const EXPECTED_LABEL = "Expected";
|
|
27
|
+
const RECEIVED_LABEL = "Received";
|
|
28
|
+
async function toEqual(matcherName, locator, receiverType, query, expected, options = {}) {
|
|
29
|
+
(0, import_util.expectTypes)(locator, [receiverType], matcherName);
|
|
30
|
+
const timeout = options.timeout ?? this.timeout;
|
|
31
|
+
const { matches: pass, received, log, timedOut, errorMessage } = await query(!!this.isNot, timeout);
|
|
32
|
+
if (pass === !this.isNot) {
|
|
33
|
+
return {
|
|
34
|
+
name: matcherName,
|
|
35
|
+
message: () => "",
|
|
36
|
+
pass,
|
|
37
|
+
expected
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
let printedReceived;
|
|
41
|
+
let printedExpected;
|
|
42
|
+
let printedDiff;
|
|
43
|
+
if (pass) {
|
|
44
|
+
printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;
|
|
45
|
+
printedReceived = errorMessage ? "" : `Received: ${this.utils.printReceived(received)}`;
|
|
46
|
+
} else if (errorMessage) {
|
|
47
|
+
printedExpected = `Expected: ${this.utils.printExpected(expected)}`;
|
|
48
|
+
} else if (Array.isArray(expected) && Array.isArray(received)) {
|
|
49
|
+
const normalizedExpected = expected.map((exp, index) => {
|
|
50
|
+
const rec = received[index];
|
|
51
|
+
if ((0, import_utils.isRegExp)(exp))
|
|
52
|
+
return exp.test(rec) ? rec : exp;
|
|
53
|
+
return exp;
|
|
54
|
+
});
|
|
55
|
+
printedDiff = this.utils.printDiffOrStringify(
|
|
56
|
+
normalizedExpected,
|
|
57
|
+
received,
|
|
58
|
+
EXPECTED_LABEL,
|
|
59
|
+
RECEIVED_LABEL,
|
|
60
|
+
false
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
printedDiff = this.utils.printDiffOrStringify(
|
|
64
|
+
expected,
|
|
65
|
+
received,
|
|
66
|
+
EXPECTED_LABEL,
|
|
67
|
+
RECEIVED_LABEL,
|
|
68
|
+
false
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const message = () => {
|
|
72
|
+
return (0, import_utils.formatMatcherMessage)(this.utils, {
|
|
73
|
+
isNot: this.isNot,
|
|
74
|
+
promise: this.promise,
|
|
75
|
+
matcherName,
|
|
76
|
+
expectation: "expected",
|
|
77
|
+
locator: locator.toString(),
|
|
78
|
+
timeout,
|
|
79
|
+
timedOut,
|
|
80
|
+
printedExpected,
|
|
81
|
+
printedReceived,
|
|
82
|
+
printedDiff,
|
|
83
|
+
errorMessage,
|
|
84
|
+
log
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
actual: received,
|
|
89
|
+
expected,
|
|
90
|
+
message,
|
|
91
|
+
name: matcherName,
|
|
92
|
+
pass,
|
|
93
|
+
log,
|
|
94
|
+
timeout: timedOut ? timeout : void 0
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
toEqual
|
|
100
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var toHaveURL_exports = {};
|
|
20
|
+
__export(toHaveURL_exports, {
|
|
21
|
+
toHaveURLWithPredicate: () => toHaveURLWithPredicate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(toHaveURL_exports);
|
|
24
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
25
|
+
async function toHaveURLWithPredicate(page, expected, options) {
|
|
26
|
+
const matcherName = "toHaveURL";
|
|
27
|
+
const timeout = options?.timeout ?? this.timeout;
|
|
28
|
+
const baseURL = page.context()._options.baseURL;
|
|
29
|
+
let conditionSucceeded = false;
|
|
30
|
+
let lastCheckedURLString = void 0;
|
|
31
|
+
try {
|
|
32
|
+
await page.mainFrame().waitForURL(
|
|
33
|
+
(url) => {
|
|
34
|
+
lastCheckedURLString = url.toString();
|
|
35
|
+
if (options?.ignoreCase) {
|
|
36
|
+
return !this.isNot === (0, import_utils.urlMatches)(
|
|
37
|
+
baseURL?.toLocaleLowerCase(),
|
|
38
|
+
lastCheckedURLString.toLocaleLowerCase(),
|
|
39
|
+
expected
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return !this.isNot === (0, import_utils.urlMatches)(baseURL, lastCheckedURLString, expected);
|
|
43
|
+
},
|
|
44
|
+
{ timeout }
|
|
45
|
+
);
|
|
46
|
+
conditionSucceeded = true;
|
|
47
|
+
} catch (e) {
|
|
48
|
+
conditionSucceeded = false;
|
|
49
|
+
}
|
|
50
|
+
if (conditionSucceeded)
|
|
51
|
+
return { name: matcherName, pass: !this.isNot, message: () => "" };
|
|
52
|
+
return {
|
|
53
|
+
name: matcherName,
|
|
54
|
+
pass: this.isNot,
|
|
55
|
+
message: () => toHaveURLMessage(
|
|
56
|
+
this,
|
|
57
|
+
matcherName,
|
|
58
|
+
expected,
|
|
59
|
+
lastCheckedURLString,
|
|
60
|
+
this.isNot,
|
|
61
|
+
true,
|
|
62
|
+
timeout
|
|
63
|
+
),
|
|
64
|
+
actual: lastCheckedURLString,
|
|
65
|
+
timeout
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function toHaveURLMessage(state, matcherName, expected, received, pass, timedOut, timeout) {
|
|
69
|
+
const receivedString = received || "";
|
|
70
|
+
let printedReceived;
|
|
71
|
+
let printedExpected;
|
|
72
|
+
let printedDiff;
|
|
73
|
+
if (typeof expected === "function") {
|
|
74
|
+
printedExpected = `Expected: predicate to ${!state.isNot ? "succeed" : "fail"}`;
|
|
75
|
+
printedReceived = `Received: ${state.utils.printReceived(receivedString)}`;
|
|
76
|
+
} else {
|
|
77
|
+
if (pass) {
|
|
78
|
+
printedExpected = `Expected pattern: not ${state.utils.printExpected(expected)}`;
|
|
79
|
+
const formattedReceived = (0, import_utils.printReceivedStringContainExpectedResult)(state.utils, receivedString, null);
|
|
80
|
+
printedReceived = `Received string: ${formattedReceived}`;
|
|
81
|
+
} else {
|
|
82
|
+
const labelExpected = `Expected ${typeof expected === "string" ? "string" : "pattern"}`;
|
|
83
|
+
printedDiff = state.utils.printDiffOrStringify(expected, receivedString, labelExpected, "Received string", false);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return (0, import_utils.formatMatcherMessage)(state.utils, {
|
|
87
|
+
isNot: state.isNot,
|
|
88
|
+
promise: state.promise,
|
|
89
|
+
matcherName,
|
|
90
|
+
expectation: "expected",
|
|
91
|
+
timeout,
|
|
92
|
+
timedOut,
|
|
93
|
+
printedExpected,
|
|
94
|
+
printedReceived,
|
|
95
|
+
printedDiff
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
toHaveURLWithPredicate
|
|
101
|
+
});
|