@stablyai/internal-playwright 0.1.0
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 +202 -0
- package/NOTICE +5 -0
- package/README.md +168 -0
- package/ThirdPartyNotices.txt +6277 -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/generateAgents.js +265 -0
- package/lib/agents/generator.md +102 -0
- package/lib/agents/healer.md +78 -0
- package/lib/agents/planner.md +135 -0
- package/lib/cli.js +274 -0
- package/lib/common/config.js +274 -0
- package/lib/common/config.js.map +7 -0
- package/lib/common/configLoader.js +377 -0
- package/lib/common/configLoader.js.map +7 -0
- package/lib/common/esmLoaderHost.js +102 -0
- package/lib/common/esmLoaderHost.js.map +7 -0
- package/lib/common/expectBundle.js +52 -0
- package/lib/common/expectBundle.js.map +7 -0
- package/lib/common/expectBundleImpl.js +389 -0
- package/lib/common/expectBundleImpl.js.map +7 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/fixtures.js.map +7 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/globals.js.map +7 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/ipc.js.map +7 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/poolBuilder.js.map +7 -0
- package/lib/common/process.js +104 -0
- package/lib/common/process.js.map +7 -0
- package/lib/common/suiteUtils.js +140 -0
- package/lib/common/suiteUtils.js.map +7 -0
- package/lib/common/test.js +321 -0
- package/lib/common/test.js.map +7 -0
- package/lib/common/testLoader.js +100 -0
- package/lib/common/testLoader.js.map +7 -0
- package/lib/common/testType.js +310 -0
- package/lib/common/testType.js.map +7 -0
- package/lib/fsWatcher.js +67 -0
- package/lib/fsWatcher.js.map +7 -0
- package/lib/index.js +696 -0
- package/lib/index.js.map +7 -0
- package/lib/internalsForTest.js +42 -0
- package/lib/internalsForTest.js.map +7 -0
- package/lib/isomorphic/events.js +77 -0
- package/lib/isomorphic/events.js.map +7 -0
- package/lib/isomorphic/folders.js +30 -0
- package/lib/isomorphic/folders.js.map +7 -0
- package/lib/isomorphic/stringInternPool.js +69 -0
- package/lib/isomorphic/stringInternPool.js.map +7 -0
- package/lib/isomorphic/teleReceiver.js +507 -0
- package/lib/isomorphic/teleReceiver.js.map +7 -0
- package/lib/isomorphic/teleSuiteUpdater.js +137 -0
- package/lib/isomorphic/teleSuiteUpdater.js.map +7 -0
- package/lib/isomorphic/testServerConnection.js +211 -0
- package/lib/isomorphic/testServerConnection.js.map +7 -0
- package/lib/isomorphic/testServerInterface.js +16 -0
- package/lib/isomorphic/testServerInterface.js.map +7 -0
- package/lib/isomorphic/testTree.js +334 -0
- package/lib/isomorphic/testTree.js.map +7 -0
- package/lib/isomorphic/types.d.js +16 -0
- package/lib/isomorphic/types.d.js.map +7 -0
- package/lib/loader/loaderMain.js +59 -0
- package/lib/loader/loaderMain.js.map +7 -0
- package/lib/matchers/expect.js +325 -0
- package/lib/matchers/expect.js.map +7 -0
- package/lib/matchers/matcherHint.js +87 -0
- package/lib/matchers/matcherHint.js.map +7 -0
- package/lib/matchers/matchers.js +366 -0
- package/lib/matchers/matchers.js.map +7 -0
- package/lib/matchers/toBeTruthy.js +73 -0
- package/lib/matchers/toBeTruthy.js.map +7 -0
- package/lib/matchers/toEqual.js +99 -0
- package/lib/matchers/toEqual.js.map +7 -0
- package/lib/matchers/toHaveURL.js +102 -0
- package/lib/matchers/toHaveURL.js.map +7 -0
- package/lib/matchers/toMatchAriaSnapshot.js +159 -0
- package/lib/matchers/toMatchAriaSnapshot.js.map +7 -0
- package/lib/matchers/toMatchSnapshot.js +359 -0
- package/lib/matchers/toMatchSnapshot.js.map +7 -0
- package/lib/matchers/toMatchText.js +99 -0
- package/lib/matchers/toMatchText.js.map +7 -0
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/backend.js +93 -0
- package/lib/mcp/browser/backend.js.map +7 -0
- package/lib/mcp/browser/browserContextFactory.js +296 -0
- package/lib/mcp/browser/browserServerBackend.js +76 -0
- package/lib/mcp/browser/codegen.js +66 -0
- package/lib/mcp/browser/config.js +385 -0
- package/lib/mcp/browser/context.js +287 -0
- package/lib/mcp/browser/response.js +228 -0
- package/lib/mcp/browser/sessionLog.js +160 -0
- package/lib/mcp/browser/tab.js +277 -0
- package/lib/mcp/browser/tool.js +30 -0
- package/lib/mcp/browser/tool.js.map +7 -0
- package/lib/mcp/browser/tools/common.js +63 -0
- package/lib/mcp/browser/tools/console.js +44 -0
- package/lib/mcp/browser/tools/dialogs.js +60 -0
- package/lib/mcp/browser/tools/evaluate.js +70 -0
- package/lib/mcp/browser/tools/files.js +58 -0
- package/lib/mcp/browser/tools/form.js +74 -0
- package/lib/mcp/browser/tools/install.js +69 -0
- package/lib/mcp/browser/tools/keyboard.js +85 -0
- package/lib/mcp/browser/tools/mouse.js +107 -0
- package/lib/mcp/browser/tools/navigate.js +62 -0
- package/lib/mcp/browser/tools/network.js +54 -0
- package/lib/mcp/browser/tools/pdf.js +59 -0
- package/lib/mcp/browser/tools/screenshot.js +88 -0
- package/lib/mcp/browser/tools/snapshot.js +182 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +49 -0
- package/lib/mcp/browser/tools/tracing.js +74 -0
- package/lib/mcp/browser/tools/utils.js +100 -0
- package/lib/mcp/browser/tools/verify.js +154 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools.js +80 -0
- package/lib/mcp/browser/tools.js.map +7 -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 +75 -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 +96 -0
- package/lib/mcp/sdk/bundle.js +81 -0
- package/lib/mcp/sdk/bundle.js.map +7 -0
- package/lib/mcp/sdk/call.js +49 -0
- package/lib/mcp/sdk/call.js.map +7 -0
- package/lib/mcp/sdk/exports.js +32 -0
- package/lib/mcp/sdk/exports.js.map +7 -0
- package/lib/mcp/sdk/http.js +187 -0
- package/lib/mcp/sdk/http.js.map +7 -0
- package/lib/mcp/sdk/inProcessTransport.js +71 -0
- package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
- package/lib/mcp/sdk/mdb.js +206 -0
- package/lib/mcp/sdk/mdb.js.map +7 -0
- package/lib/mcp/sdk/proxyBackend.js +128 -0
- package/lib/mcp/sdk/proxyBackend.js.map +7 -0
- package/lib/mcp/sdk/server.js +189 -0
- package/lib/mcp/sdk/server.js.map +7 -0
- package/lib/mcp/sdk/tool.js +51 -0
- package/lib/mcp/sdk/tool.js.map +7 -0
- package/lib/mcp/test/backend.js +67 -0
- package/lib/mcp/test/backend.js.map +7 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/context.js +48 -0
- package/lib/mcp/test/context.js.map +7 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/plannerTools.js +46 -0
- package/lib/mcp/test/seed.js +72 -0
- package/lib/mcp/test/streams.js +39 -0
- package/lib/mcp/test/streams.js.map +7 -0
- package/lib/mcp/test/testBackend.js +97 -0
- package/lib/mcp/test/testContext.js +176 -0
- package/lib/mcp/test/testTool.js +30 -0
- package/lib/mcp/test/testTools.js +115 -0
- package/lib/mcp/test/tool.js +30 -0
- package/lib/mcp/test/tool.js.map +7 -0
- package/lib/mcp/test/tools.js +150 -0
- package/lib/mcp/test/tools.js.map +7 -0
- package/lib/mcp/vscode/host.js +187 -0
- package/lib/mcp/vscode/main.js +77 -0
- package/lib/mcpBundleImpl.js +41 -0
- package/lib/mcpBundleImpl.js.map +7 -0
- package/lib/plugins/gitCommitInfoPlugin.js +198 -0
- package/lib/plugins/gitCommitInfoPlugin.js.map +7 -0
- package/lib/plugins/index.js +28 -0
- package/lib/plugins/index.js.map +7 -0
- package/lib/plugins/webServerPlugin.js +209 -0
- package/lib/plugins/webServerPlugin.js.map +7 -0
- package/lib/program.js +412 -0
- package/lib/program.js.map +7 -0
- package/lib/reporters/base.js +609 -0
- package/lib/reporters/base.js.map +7 -0
- package/lib/reporters/blob.js +135 -0
- package/lib/reporters/blob.js.map +7 -0
- package/lib/reporters/dot.js +82 -0
- package/lib/reporters/dot.js.map +7 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/empty.js.map +7 -0
- package/lib/reporters/github.js +128 -0
- package/lib/reporters/github.js.map +7 -0
- package/lib/reporters/html.js +644 -0
- package/lib/reporters/html.js.map +7 -0
- package/lib/reporters/internalReporter.js +130 -0
- package/lib/reporters/internalReporter.js.map +7 -0
- package/lib/reporters/json.js +254 -0
- package/lib/reporters/json.js.map +7 -0
- package/lib/reporters/junit.js +230 -0
- package/lib/reporters/junit.js.map +7 -0
- package/lib/reporters/line.js +113 -0
- package/lib/reporters/line.js.map +7 -0
- package/lib/reporters/list.js +235 -0
- package/lib/reporters/list.js.map +7 -0
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/listModeReporter.js.map +7 -0
- package/lib/reporters/markdown.js +144 -0
- package/lib/reporters/markdown.js.map +7 -0
- package/lib/reporters/merge.js +535 -0
- package/lib/reporters/merge.js.map +7 -0
- package/lib/reporters/multiplexer.js +104 -0
- package/lib/reporters/multiplexer.js.map +7 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/reporterV2.js.map +7 -0
- package/lib/reporters/teleEmitter.js +297 -0
- package/lib/reporters/teleEmitter.js.map +7 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/reporters/versions/blobV1.js.map +7 -0
- package/lib/runner/dispatcher.js +491 -0
- package/lib/runner/dispatcher.js.map +7 -0
- package/lib/runner/failureTracker.js +72 -0
- package/lib/runner/failureTracker.js.map +7 -0
- package/lib/runner/lastRun.js +77 -0
- package/lib/runner/lastRun.js.map +7 -0
- package/lib/runner/loadUtils.js +333 -0
- package/lib/runner/loadUtils.js.map +7 -0
- package/lib/runner/loaderHost.js +89 -0
- package/lib/runner/loaderHost.js.map +7 -0
- package/lib/runner/processHost.js +161 -0
- package/lib/runner/processHost.js.map +7 -0
- package/lib/runner/projectUtils.js +241 -0
- package/lib/runner/projectUtils.js.map +7 -0
- package/lib/runner/rebase.js +189 -0
- package/lib/runner/rebase.js.map +7 -0
- package/lib/runner/reporters.js +137 -0
- package/lib/runner/reporters.js.map +7 -0
- package/lib/runner/runner.js +173 -0
- package/lib/runner/sigIntWatcher.js +96 -0
- package/lib/runner/sigIntWatcher.js.map +7 -0
- package/lib/runner/taskRunner.js +127 -0
- package/lib/runner/taskRunner.js.map +7 -0
- package/lib/runner/tasks.js +410 -0
- package/lib/runner/tasks.js.map +7 -0
- package/lib/runner/testGroups.js +117 -0
- package/lib/runner/testGroups.js.map +7 -0
- package/lib/runner/testRunner.js +390 -0
- package/lib/runner/testRunner.js.map +7 -0
- package/lib/runner/testServer.js +264 -0
- package/lib/runner/testServer.js.map +7 -0
- package/lib/runner/uiMode.js +271 -0
- package/lib/runner/uiModeReporter.js +30 -0
- package/lib/runner/uiModeReporter.js.map +7 -0
- package/lib/runner/vcs.js +72 -0
- package/lib/runner/vcs.js.map +7 -0
- package/lib/runner/watchMode.js +395 -0
- package/lib/runner/watchMode.js.map +7 -0
- package/lib/runner/workerHost.js +95 -0
- package/lib/runner/workerHost.js.map +7 -0
- package/lib/store.js +98 -0
- package/lib/third_party/pirates.js +62 -0
- package/lib/third_party/pirates.js.map +7 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/third_party/tsconfig-loader.js.map +7 -0
- package/lib/transform/babelBundle.js +43 -0
- package/lib/transform/babelBundle.js.map +7 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/babelBundleImpl.js.map +7 -0
- package/lib/transform/compilationCache.js +272 -0
- package/lib/transform/compilationCache.js.map +7 -0
- package/lib/transform/esmLoader.js +104 -0
- package/lib/transform/esmLoader.js.map +7 -0
- package/lib/transform/esmUtils.js +32 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/portTransport.js.map +7 -0
- package/lib/transform/transform.js +293 -0
- package/lib/transform/transform.js.map +7 -0
- package/lib/util.js +403 -0
- package/lib/util.js.map +7 -0
- package/lib/utilsBundle.js +43 -0
- package/lib/utilsBundle.js.map +7 -0
- package/lib/utilsBundleImpl.js +100 -0
- package/lib/utilsBundleImpl.js.map +7 -0
- package/lib/worker/fixtureRunner.js +258 -0
- package/lib/worker/fixtureRunner.js.map +7 -0
- package/lib/worker/stepContext.js +34 -0
- package/lib/worker/testInfo.js +508 -0
- package/lib/worker/testInfo.js.map +7 -0
- package/lib/worker/testTracing.js +344 -0
- package/lib/worker/testTracing.js.map +7 -0
- package/lib/worker/timeoutManager.js +174 -0
- package/lib/worker/timeoutManager.js.map +7 -0
- package/lib/worker/util.js +31 -0
- package/lib/worker/util.js.map +7 -0
- package/lib/worker/workerMain.js +520 -0
- package/lib/worker/workerMain.js.map +7 -0
- package/package.json +74 -0
- package/test.d.ts +18 -0
- package/test.js +24 -0
- package/test.mjs +33 -0
- package/types/test.d.ts +10217 -0
- package/types/testReporter.d.ts +816 -0
@@ -0,0 +1,325 @@
|
|
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 expect_exports = {};
|
20
|
+
__export(expect_exports, {
|
21
|
+
expect: () => expect,
|
22
|
+
mergeExpects: () => mergeExpects,
|
23
|
+
printReceivedStringContainExpectedResult: () => printReceivedStringContainExpectedResult,
|
24
|
+
printReceivedStringContainExpectedSubstring: () => printReceivedStringContainExpectedSubstring
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(expect_exports);
|
27
|
+
var import_utils = require("playwright-core/lib/utils");
|
28
|
+
var import_matcherHint = require("./matcherHint");
|
29
|
+
var import_matchers = require("./matchers");
|
30
|
+
var import_toMatchAriaSnapshot = require("./toMatchAriaSnapshot");
|
31
|
+
var import_toMatchSnapshot = require("./toMatchSnapshot");
|
32
|
+
var import_expectBundle = require("../common/expectBundle");
|
33
|
+
var import_globals = require("../common/globals");
|
34
|
+
var import_util = require("../util");
|
35
|
+
var import_testInfo = require("../worker/testInfo");
|
36
|
+
const printSubstring = (val) => val.replace(/"|\\/g, "\\$&");
|
37
|
+
const printReceivedStringContainExpectedSubstring = (received, start, length) => (0, import_expectBundle.RECEIVED_COLOR)(
|
38
|
+
'"' + printSubstring(received.slice(0, start)) + (0, import_expectBundle.INVERTED_COLOR)(printSubstring(received.slice(start, start + length))) + printSubstring(received.slice(start + length)) + '"'
|
39
|
+
);
|
40
|
+
const printReceivedStringContainExpectedResult = (received, result) => result === null ? (0, import_expectBundle.printReceived)(received) : printReceivedStringContainExpectedSubstring(
|
41
|
+
received,
|
42
|
+
result.index,
|
43
|
+
result[0].length
|
44
|
+
);
|
45
|
+
function createMatchers(actual, info, prefix) {
|
46
|
+
return new Proxy((0, import_expectBundle.expect)(actual), new ExpectMetaInfoProxyHandler(info, prefix));
|
47
|
+
}
|
48
|
+
const userMatchersSymbol = Symbol("userMatchers");
|
49
|
+
function qualifiedMatcherName(qualifier, matcherName) {
|
50
|
+
return qualifier.join(":") + "$" + matcherName;
|
51
|
+
}
|
52
|
+
function createExpect(info, prefix, userMatchers) {
|
53
|
+
const expectInstance = new Proxy(import_expectBundle.expect, {
|
54
|
+
apply: function(target, thisArg, argumentsList) {
|
55
|
+
const [actual, messageOrOptions] = argumentsList;
|
56
|
+
const message = (0, import_utils.isString)(messageOrOptions) ? messageOrOptions : messageOrOptions?.message || info.message;
|
57
|
+
const newInfo = { ...info, message };
|
58
|
+
if (newInfo.poll) {
|
59
|
+
if (typeof actual !== "function")
|
60
|
+
throw new Error("`expect.poll()` accepts only function as a first argument");
|
61
|
+
newInfo.poll.generator = actual;
|
62
|
+
}
|
63
|
+
return createMatchers(actual, newInfo, prefix);
|
64
|
+
},
|
65
|
+
get: function(target, property) {
|
66
|
+
if (property === "configure")
|
67
|
+
return configure;
|
68
|
+
if (property === "extend") {
|
69
|
+
return (matchers) => {
|
70
|
+
const qualifier = [...prefix, (0, import_utils.createGuid)()];
|
71
|
+
const wrappedMatchers = {};
|
72
|
+
for (const [name, matcher] of Object.entries(matchers)) {
|
73
|
+
wrappedMatchers[name] = wrapPlaywrightMatcherToPassNiceThis(matcher);
|
74
|
+
const key = qualifiedMatcherName(qualifier, name);
|
75
|
+
wrappedMatchers[key] = wrappedMatchers[name];
|
76
|
+
Object.defineProperty(wrappedMatchers[key], "name", { value: name });
|
77
|
+
}
|
78
|
+
import_expectBundle.expect.extend(wrappedMatchers);
|
79
|
+
return createExpect(info, qualifier, { ...userMatchers, ...matchers });
|
80
|
+
};
|
81
|
+
}
|
82
|
+
if (property === "soft") {
|
83
|
+
return (actual, messageOrOptions) => {
|
84
|
+
return configure({ soft: true })(actual, messageOrOptions);
|
85
|
+
};
|
86
|
+
}
|
87
|
+
if (property === userMatchersSymbol)
|
88
|
+
return userMatchers;
|
89
|
+
if (property === "poll") {
|
90
|
+
return (actual, messageOrOptions) => {
|
91
|
+
const poll = (0, import_utils.isString)(messageOrOptions) ? {} : messageOrOptions || {};
|
92
|
+
return configure({ _poll: poll })(actual, messageOrOptions);
|
93
|
+
};
|
94
|
+
}
|
95
|
+
return import_expectBundle.expect[property];
|
96
|
+
}
|
97
|
+
});
|
98
|
+
const configure = (configuration) => {
|
99
|
+
const newInfo = { ...info };
|
100
|
+
if ("message" in configuration)
|
101
|
+
newInfo.message = configuration.message;
|
102
|
+
if ("timeout" in configuration)
|
103
|
+
newInfo.timeout = configuration.timeout;
|
104
|
+
if ("soft" in configuration)
|
105
|
+
newInfo.isSoft = configuration.soft;
|
106
|
+
if ("_poll" in configuration) {
|
107
|
+
newInfo.poll = configuration._poll ? { ...info.poll, generator: () => {
|
108
|
+
} } : void 0;
|
109
|
+
if (typeof configuration._poll === "object") {
|
110
|
+
newInfo.poll.timeout = configuration._poll.timeout ?? newInfo.poll.timeout;
|
111
|
+
newInfo.poll.intervals = configuration._poll.intervals ?? newInfo.poll.intervals;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
return createExpect(newInfo, prefix, userMatchers);
|
115
|
+
};
|
116
|
+
return expectInstance;
|
117
|
+
}
|
118
|
+
let matcherCallContext;
|
119
|
+
function setMatcherCallContext(context) {
|
120
|
+
matcherCallContext = context;
|
121
|
+
}
|
122
|
+
function takeMatcherCallContext() {
|
123
|
+
try {
|
124
|
+
return matcherCallContext;
|
125
|
+
} finally {
|
126
|
+
matcherCallContext = void 0;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
const defaultExpectTimeout = 5e3;
|
130
|
+
function wrapPlaywrightMatcherToPassNiceThis(matcher) {
|
131
|
+
return function(...args) {
|
132
|
+
const { isNot, promise, utils } = this;
|
133
|
+
const context = takeMatcherCallContext();
|
134
|
+
const timeout = context?.expectInfo.timeout ?? context?.testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;
|
135
|
+
const newThis = {
|
136
|
+
isNot,
|
137
|
+
promise,
|
138
|
+
utils,
|
139
|
+
timeout,
|
140
|
+
_stepInfo: context?.step
|
141
|
+
};
|
142
|
+
newThis.equals = throwUnsupportedExpectMatcherError;
|
143
|
+
return matcher.call(newThis, ...args);
|
144
|
+
};
|
145
|
+
}
|
146
|
+
function throwUnsupportedExpectMatcherError() {
|
147
|
+
throw new Error("It looks like you are using custom expect matchers that are not compatible with Playwright. See https://aka.ms/playwright/expect-compatibility");
|
148
|
+
}
|
149
|
+
import_expectBundle.expect.setState({ expand: false });
|
150
|
+
const customAsyncMatchers = {
|
151
|
+
toBeAttached: import_matchers.toBeAttached,
|
152
|
+
toBeChecked: import_matchers.toBeChecked,
|
153
|
+
toBeDisabled: import_matchers.toBeDisabled,
|
154
|
+
toBeEditable: import_matchers.toBeEditable,
|
155
|
+
toBeEmpty: import_matchers.toBeEmpty,
|
156
|
+
toBeEnabled: import_matchers.toBeEnabled,
|
157
|
+
toBeFocused: import_matchers.toBeFocused,
|
158
|
+
toBeHidden: import_matchers.toBeHidden,
|
159
|
+
toBeInViewport: import_matchers.toBeInViewport,
|
160
|
+
toBeOK: import_matchers.toBeOK,
|
161
|
+
toBeVisible: import_matchers.toBeVisible,
|
162
|
+
toContainText: import_matchers.toContainText,
|
163
|
+
toContainClass: import_matchers.toContainClass,
|
164
|
+
toHaveAccessibleDescription: import_matchers.toHaveAccessibleDescription,
|
165
|
+
toHaveAccessibleName: import_matchers.toHaveAccessibleName,
|
166
|
+
toHaveAccessibleErrorMessage: import_matchers.toHaveAccessibleErrorMessage,
|
167
|
+
toHaveAttribute: import_matchers.toHaveAttribute,
|
168
|
+
toHaveClass: import_matchers.toHaveClass,
|
169
|
+
toHaveCount: import_matchers.toHaveCount,
|
170
|
+
toHaveCSS: import_matchers.toHaveCSS,
|
171
|
+
toHaveId: import_matchers.toHaveId,
|
172
|
+
toHaveJSProperty: import_matchers.toHaveJSProperty,
|
173
|
+
toHaveRole: import_matchers.toHaveRole,
|
174
|
+
toHaveText: import_matchers.toHaveText,
|
175
|
+
toHaveTitle: import_matchers.toHaveTitle,
|
176
|
+
toHaveURL: import_matchers.toHaveURL,
|
177
|
+
toHaveValue: import_matchers.toHaveValue,
|
178
|
+
toHaveValues: import_matchers.toHaveValues,
|
179
|
+
toHaveScreenshot: import_toMatchSnapshot.toHaveScreenshot,
|
180
|
+
toMatchAriaSnapshot: import_toMatchAriaSnapshot.toMatchAriaSnapshot,
|
181
|
+
toPass: import_matchers.toPass
|
182
|
+
};
|
183
|
+
const customMatchers = {
|
184
|
+
...customAsyncMatchers,
|
185
|
+
toMatchSnapshot: import_toMatchSnapshot.toMatchSnapshot
|
186
|
+
};
|
187
|
+
class ExpectMetaInfoProxyHandler {
|
188
|
+
constructor(info, prefix) {
|
189
|
+
this._info = { ...info };
|
190
|
+
this._prefix = prefix;
|
191
|
+
}
|
192
|
+
get(target, matcherName, receiver) {
|
193
|
+
let matcher = Reflect.get(target, matcherName, receiver);
|
194
|
+
if (typeof matcherName !== "string")
|
195
|
+
return matcher;
|
196
|
+
let resolvedMatcherName = matcherName;
|
197
|
+
for (let i = this._prefix.length; i > 0; i--) {
|
198
|
+
const qualifiedName = qualifiedMatcherName(this._prefix.slice(0, i), matcherName);
|
199
|
+
if (Reflect.has(target, qualifiedName)) {
|
200
|
+
matcher = Reflect.get(target, qualifiedName, receiver);
|
201
|
+
resolvedMatcherName = qualifiedName;
|
202
|
+
break;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
if (matcher === void 0)
|
206
|
+
throw new Error(`expect: Property '${matcherName}' not found.`);
|
207
|
+
if (typeof matcher !== "function") {
|
208
|
+
if (matcherName === "not")
|
209
|
+
this._info.isNot = !this._info.isNot;
|
210
|
+
return new Proxy(matcher, this);
|
211
|
+
}
|
212
|
+
if (this._info.poll) {
|
213
|
+
if (customAsyncMatchers[matcherName] || matcherName === "resolves" || matcherName === "rejects")
|
214
|
+
throw new Error(`\`expect.poll()\` does not support "${matcherName}" matcher.`);
|
215
|
+
matcher = (...args) => pollMatcher(resolvedMatcherName, this._info, this._prefix, ...args);
|
216
|
+
}
|
217
|
+
return (...args) => {
|
218
|
+
const testInfo = (0, import_globals.currentTestInfo)();
|
219
|
+
setMatcherCallContext({ expectInfo: this._info, testInfo });
|
220
|
+
if (!testInfo)
|
221
|
+
return matcher.call(target, ...args);
|
222
|
+
const customMessage = this._info.message || "";
|
223
|
+
const argsSuffix = computeArgsSuffix(matcherName, args);
|
224
|
+
const defaultTitle = `${this._info.poll ? "poll " : ""}${this._info.isSoft ? "soft " : ""}${this._info.isNot ? "not " : ""}${matcherName}${argsSuffix}`;
|
225
|
+
const title = customMessage || `Expect ${(0, import_utils.escapeWithQuotes)(defaultTitle, '"')}`;
|
226
|
+
const apiName = `expect${this._info.poll ? ".poll " : ""}${this._info.isSoft ? ".soft " : ""}${this._info.isNot ? ".not" : ""}.${matcherName}${argsSuffix}`;
|
227
|
+
const stackFrames = (0, import_util.filteredStackTrace)((0, import_utils.captureRawStack)());
|
228
|
+
const stepInfo = {
|
229
|
+
category: "expect",
|
230
|
+
apiName,
|
231
|
+
title,
|
232
|
+
params: args[0] ? { expected: args[0] } : void 0,
|
233
|
+
infectParentStepsWithError: this._info.isSoft
|
234
|
+
};
|
235
|
+
const step = testInfo._addStep(stepInfo);
|
236
|
+
const reportStepError = (e) => {
|
237
|
+
const jestError = (0, import_matcherHint.isJestError)(e) ? e : null;
|
238
|
+
const expectError = jestError ? new import_matcherHint.ExpectError(jestError, customMessage, stackFrames) : void 0;
|
239
|
+
if (jestError?.matcherResult.suggestedRebaseline) {
|
240
|
+
step.complete({ suggestedRebaseline: jestError?.matcherResult.suggestedRebaseline });
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
const error = expectError ?? e;
|
244
|
+
step.complete({ error });
|
245
|
+
if (this._info.isSoft)
|
246
|
+
testInfo._failWithError(error);
|
247
|
+
else
|
248
|
+
throw error;
|
249
|
+
};
|
250
|
+
const finalizer = () => {
|
251
|
+
step.complete({});
|
252
|
+
};
|
253
|
+
try {
|
254
|
+
setMatcherCallContext({ expectInfo: this._info, testInfo, step: step.info });
|
255
|
+
const callback = () => matcher.call(target, ...args);
|
256
|
+
const result = (0, import_utils.currentZone)().with("stepZone", step).run(callback);
|
257
|
+
if (result instanceof Promise)
|
258
|
+
return result.then(finalizer).catch(reportStepError);
|
259
|
+
finalizer();
|
260
|
+
return result;
|
261
|
+
} catch (e) {
|
262
|
+
void reportStepError(e);
|
263
|
+
}
|
264
|
+
};
|
265
|
+
}
|
266
|
+
}
|
267
|
+
async function pollMatcher(qualifiedMatcherName2, info, prefix, ...args) {
|
268
|
+
const testInfo = (0, import_globals.currentTestInfo)();
|
269
|
+
const poll = info.poll;
|
270
|
+
const timeout = poll.timeout ?? info.timeout ?? testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;
|
271
|
+
const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
|
272
|
+
const result = await (0, import_utils.pollAgainstDeadline)(async () => {
|
273
|
+
if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
|
274
|
+
return { continuePolling: false, result: void 0 };
|
275
|
+
const innerInfo = {
|
276
|
+
...info,
|
277
|
+
isSoft: false,
|
278
|
+
// soft is outside of poll, not inside
|
279
|
+
poll: void 0
|
280
|
+
};
|
281
|
+
const value = await poll.generator();
|
282
|
+
try {
|
283
|
+
let matchers = createMatchers(value, innerInfo, prefix);
|
284
|
+
if (info.isNot)
|
285
|
+
matchers = matchers.not;
|
286
|
+
matchers[qualifiedMatcherName2](...args);
|
287
|
+
return { continuePolling: false, result: void 0 };
|
288
|
+
} catch (error) {
|
289
|
+
return { continuePolling: true, result: error };
|
290
|
+
}
|
291
|
+
}, deadline, poll.intervals ?? [100, 250, 500, 1e3]);
|
292
|
+
if (result.timedOut) {
|
293
|
+
const message = result.result ? [
|
294
|
+
result.result.message,
|
295
|
+
"",
|
296
|
+
`Call Log:`,
|
297
|
+
`- ${timeoutMessage}`
|
298
|
+
].join("\n") : timeoutMessage;
|
299
|
+
throw new Error(message);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
function computeArgsSuffix(matcherName, args) {
|
303
|
+
let value = "";
|
304
|
+
if (matcherName === "toHaveScreenshot")
|
305
|
+
value = (0, import_toMatchSnapshot.toHaveScreenshotStepTitle)(...args);
|
306
|
+
return value ? `(${value})` : "";
|
307
|
+
}
|
308
|
+
const expect = createExpect({}, [], {}).extend(customMatchers);
|
309
|
+
function mergeExpects(...expects) {
|
310
|
+
let merged = expect;
|
311
|
+
for (const e of expects) {
|
312
|
+
const internals = e[userMatchersSymbol];
|
313
|
+
if (!internals)
|
314
|
+
continue;
|
315
|
+
merged = merged.extend(internals);
|
316
|
+
}
|
317
|
+
return merged;
|
318
|
+
}
|
319
|
+
// Annotate the CommonJS export names for ESM import in node:
|
320
|
+
0 && (module.exports = {
|
321
|
+
expect,
|
322
|
+
mergeExpects,
|
323
|
+
printReceivedStringContainExpectedResult,
|
324
|
+
printReceivedStringContainExpectedSubstring
|
325
|
+
});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/matchers/expect.ts"],
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n captureRawStack,\n createGuid,\n currentZone,\n escapeWithQuotes,\n isString,\n pollAgainstDeadline } from 'playwright-core/lib/utils';\n\nimport { ExpectError, isJestError } from './matcherHint';\nimport {\n toBeAttached,\n toBeChecked,\n toBeDisabled,\n toBeEditable,\n toBeEmpty,\n toBeEnabled,\n toBeFocused,\n toBeHidden,\n toBeInViewport,\n toBeOK,\n toBeVisible,\n toContainClass,\n toContainText,\n toHaveAccessibleDescription,\n toHaveAccessibleErrorMessage,\n toHaveAccessibleName,\n toHaveAttribute,\n toHaveCSS,\n toHaveClass,\n toHaveCount,\n toHaveId,\n toHaveJSProperty,\n toHaveRole,\n toHaveText,\n toHaveTitle,\n toHaveURL,\n toHaveValue,\n toHaveValues,\n toPass\n} from './matchers';\nimport { toMatchAriaSnapshot } from './toMatchAriaSnapshot';\nimport { toHaveScreenshot, toHaveScreenshotStepTitle, toMatchSnapshot } from './toMatchSnapshot';\nimport {\n INVERTED_COLOR,\n RECEIVED_COLOR,\n expect as expectLibrary,\n printReceived,\n} from '../common/expectBundle';\nimport { currentTestInfo } from '../common/globals';\nimport { filteredStackTrace } from '../util';\nimport { TestInfoImpl } from '../worker/testInfo';\n\nimport type { ExpectMatcherStateInternal } from './matchers';\nimport type { Expect } from '../../types/test';\nimport type { TestStepCategory, TestStepInfoImpl } from '../worker/testInfo';\n\n\n// #region\n// Mirrored from https://github.com/facebook/jest/blob/f13abff8df9a0e1148baf3584bcde6d1b479edc7/packages/expect/src/print.ts\n/**\n * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n *\n * This source code is licensed under the MIT license found here\n * https://github.com/facebook/jest/blob/1547740bbc26400d69f4576bf35645163e942829/LICENSE\n */\n\n// Format substring but do not enclose in double quote marks.\n// The replacement is compatible with pretty-format package.\nconst printSubstring = (val: string): string => val.replace(/\"|\\\\/g, '\\\\$&');\n\nexport const printReceivedStringContainExpectedSubstring = (\n received: string,\n start: number,\n length: number, // not end\n): string =>\n RECEIVED_COLOR(\n '\"' +\n printSubstring(received.slice(0, start)) +\n INVERTED_COLOR(printSubstring(received.slice(start, start + length))) +\n printSubstring(received.slice(start + length)) +\n '\"',\n );\n\nexport const printReceivedStringContainExpectedResult = (\n received: string,\n result: RegExpExecArray | null,\n): string =>\n result === null\n ? printReceived(received)\n : printReceivedStringContainExpectedSubstring(\n received,\n result.index,\n result[0].length,\n );\n\n// #endregion\n\ntype ExpectMessage = string | { message?: string };\n\nfunction createMatchers(actual: unknown, info: ExpectMetaInfo, prefix: string[]): any {\n return new Proxy(expectLibrary(actual), new ExpectMetaInfoProxyHandler(info, prefix));\n}\n\nconst userMatchersSymbol = Symbol('userMatchers');\n\nfunction qualifiedMatcherName(qualifier: string[], matcherName: string) {\n return qualifier.join(':') + '$' + matcherName;\n}\n\nfunction createExpect(info: ExpectMetaInfo, prefix: string[], userMatchers: Record<string, Function>) {\n const expectInstance: Expect<{}> = new Proxy(expectLibrary, {\n apply: function(target: any, thisArg: any, argumentsList: [unknown, ExpectMessage?]) {\n const [actual, messageOrOptions] = argumentsList;\n const message = isString(messageOrOptions) ? messageOrOptions : messageOrOptions?.message || info.message;\n const newInfo = { ...info, message };\n if (newInfo.poll) {\n if (typeof actual !== 'function')\n throw new Error('`expect.poll()` accepts only function as a first argument');\n newInfo.poll.generator = actual as any;\n }\n return createMatchers(actual, newInfo, prefix);\n },\n\n get: function(target: any, property: string | typeof userMatchersSymbol) {\n if (property === 'configure')\n return configure;\n\n if (property === 'extend') {\n return (matchers: any) => {\n const qualifier = [...prefix, createGuid()];\n\n const wrappedMatchers: any = {};\n for (const [name, matcher] of Object.entries(matchers)) {\n wrappedMatchers[name] = wrapPlaywrightMatcherToPassNiceThis(matcher);\n const key = qualifiedMatcherName(qualifier, name);\n wrappedMatchers[key] = wrappedMatchers[name];\n Object.defineProperty(wrappedMatchers[key], 'name', { value: name });\n }\n expectLibrary.extend(wrappedMatchers);\n return createExpect(info, qualifier, { ...userMatchers, ...matchers });\n };\n }\n\n if (property === 'soft') {\n return (actual: unknown, messageOrOptions?: ExpectMessage) => {\n return configure({ soft: true })(actual, messageOrOptions) as any;\n };\n }\n\n if (property === userMatchersSymbol)\n return userMatchers;\n\n if (property === 'poll') {\n return (actual: unknown, messageOrOptions?: ExpectMessage & { timeout?: number, intervals?: number[] }) => {\n const poll = isString(messageOrOptions) ? {} : messageOrOptions || {};\n return configure({ _poll: poll })(actual, messageOrOptions) as any;\n };\n }\n return (expectLibrary as any)[property];\n },\n });\n\n const configure = (configuration: { message?: string, timeout?: number, soft?: boolean, _poll?: boolean | { timeout?: number, intervals?: number[] } }) => {\n const newInfo = { ...info };\n if ('message' in configuration)\n newInfo.message = configuration.message;\n if ('timeout' in configuration)\n newInfo.timeout = configuration.timeout;\n if ('soft' in configuration)\n newInfo.isSoft = configuration.soft;\n if ('_poll' in configuration) {\n newInfo.poll = configuration._poll ? { ...info.poll, generator: () => {} } : undefined;\n if (typeof configuration._poll === 'object') {\n newInfo.poll!.timeout = configuration._poll.timeout ?? newInfo.poll!.timeout;\n newInfo.poll!.intervals = configuration._poll.intervals ?? newInfo.poll!.intervals;\n }\n }\n return createExpect(newInfo, prefix, userMatchers);\n };\n\n return expectInstance;\n}\n\n// Expect wraps matchers, so there is no way to pass this information to the raw Playwright matcher.\n// Rely on sync call sequence to seed each matcher call with the context.\ntype MatcherCallContext = {\n expectInfo: ExpectMetaInfo;\n testInfo: TestInfoImpl | null;\n step?: TestStepInfoImpl;\n};\n\nlet matcherCallContext: MatcherCallContext | undefined;\n\nfunction setMatcherCallContext(context: MatcherCallContext) {\n matcherCallContext = context;\n}\n\nfunction takeMatcherCallContext(): MatcherCallContext | undefined {\n try {\n return matcherCallContext;\n } finally {\n // Any subsequent matcher following the first is assumed to be an unsupported legacy asymmetric matcher.\n // Lacking call context in these scenarios is not particularly important.\n matcherCallContext = undefined;\n }\n}\n\nconst defaultExpectTimeout = 5000;\n\nfunction wrapPlaywrightMatcherToPassNiceThis(matcher: any) {\n return function(this: any, ...args: any[]) {\n const { isNot, promise, utils } = this;\n const context = takeMatcherCallContext();\n const timeout = context?.expectInfo.timeout ?? context?.testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;\n const newThis: ExpectMatcherStateInternal = {\n isNot,\n promise,\n utils,\n timeout,\n _stepInfo: context?.step,\n };\n (newThis as any).equals = throwUnsupportedExpectMatcherError;\n return matcher.call(newThis, ...args);\n };\n}\n\nfunction throwUnsupportedExpectMatcherError() {\n throw new Error('It looks like you are using custom expect matchers that are not compatible with Playwright. See https://aka.ms/playwright/expect-compatibility');\n}\n\nexpectLibrary.setState({ expand: false });\n\nconst customAsyncMatchers = {\n toBeAttached,\n toBeChecked,\n toBeDisabled,\n toBeEditable,\n toBeEmpty,\n toBeEnabled,\n toBeFocused,\n toBeHidden,\n toBeInViewport,\n toBeOK,\n toBeVisible,\n toContainText,\n toContainClass,\n toHaveAccessibleDescription,\n toHaveAccessibleName,\n toHaveAccessibleErrorMessage,\n toHaveAttribute,\n toHaveClass,\n toHaveCount,\n toHaveCSS,\n toHaveId,\n toHaveJSProperty,\n toHaveRole,\n toHaveText,\n toHaveTitle,\n toHaveURL,\n toHaveValue,\n toHaveValues,\n toHaveScreenshot,\n toMatchAriaSnapshot,\n toPass,\n};\n\nconst customMatchers = {\n ...customAsyncMatchers,\n toMatchSnapshot,\n};\n\ntype Generator = () => any;\n\ntype ExpectMetaInfo = {\n message?: string;\n isNot?: boolean;\n isSoft?: boolean;\n poll?: {\n timeout?: number;\n intervals?: number[];\n generator: Generator;\n };\n timeout?: number;\n};\n\nclass ExpectMetaInfoProxyHandler implements ProxyHandler<any> {\n private _info: ExpectMetaInfo;\n private _prefix: string[];\n\n constructor(info: ExpectMetaInfo, prefix: string[]) {\n this._info = { ...info };\n this._prefix = prefix;\n }\n\n get(target: Object, matcherName: string | symbol, receiver: any): any {\n let matcher = Reflect.get(target, matcherName, receiver);\n if (typeof matcherName !== 'string')\n return matcher;\n\n let resolvedMatcherName = matcherName;\n for (let i = this._prefix.length; i > 0; i--) {\n const qualifiedName = qualifiedMatcherName(this._prefix.slice(0, i), matcherName);\n if (Reflect.has(target, qualifiedName)) {\n matcher = Reflect.get(target, qualifiedName, receiver);\n resolvedMatcherName = qualifiedName;\n break;\n }\n }\n\n if (matcher === undefined)\n throw new Error(`expect: Property '${matcherName}' not found.`);\n if (typeof matcher !== 'function') {\n if (matcherName === 'not')\n this._info.isNot = !this._info.isNot;\n return new Proxy(matcher, this);\n }\n if (this._info.poll) {\n if ((customAsyncMatchers as any)[matcherName] || matcherName === 'resolves' || matcherName === 'rejects')\n throw new Error(`\\`expect.poll()\\` does not support \"${matcherName}\" matcher.`);\n matcher = (...args: any[]) => pollMatcher(resolvedMatcherName, this._info, this._prefix, ...args);\n }\n return (...args: any[]) => {\n const testInfo = currentTestInfo();\n setMatcherCallContext({ expectInfo: this._info, testInfo });\n if (!testInfo)\n return matcher.call(target, ...args);\n\n const customMessage = this._info.message || '';\n const argsSuffix = computeArgsSuffix(matcherName, args);\n\n const defaultTitle = `${this._info.poll ? 'poll ' : ''}${this._info.isSoft ? 'soft ' : ''}${this._info.isNot ? 'not ' : ''}${matcherName}${argsSuffix}`;\n const title = customMessage || `Expect ${escapeWithQuotes(defaultTitle, '\"')}`;\n const apiName = `expect${this._info.poll ? '.poll ' : ''}${this._info.isSoft ? '.soft ' : ''}${this._info.isNot ? '.not' : ''}.${matcherName}${argsSuffix}`;\n\n // This looks like it is unnecessary, but it isn't - we need to filter\n // out all the frames that belong to the test runner from caught runtime errors.\n const stackFrames = filteredStackTrace(captureRawStack());\n const category = matcherName === 'toPass' || this._info.poll ? 'test.step' : 'expect' as TestStepCategory;\n\n // toPass and poll matchers can contain other steps, expects and API calls,\n // so they behave like a retriable step.\n const stepInfo = {\n category,\n apiName,\n title,\n params: args[0] ? { expected: args[0] } : undefined,\n infectParentStepsWithError: this._info.isSoft,\n };\n\n const step = testInfo._addStep(stepInfo);\n\n const reportStepError = (e: Error | unknown) => {\n const jestError = isJestError(e) ? e : null;\n const expectError = jestError ? new ExpectError(jestError, customMessage, stackFrames) : undefined;\n if (jestError?.matcherResult.suggestedRebaseline) {\n // NOTE: this is a workaround for the fact that we can't pass the suggested rebaseline\n // for passing matchers. See toMatchAriaSnapshot for a counterpart.\n step.complete({ suggestedRebaseline: jestError?.matcherResult.suggestedRebaseline });\n return;\n }\n\n const error = expectError ?? e;\n step.complete({ error });\n\n if (this._info.isSoft)\n testInfo._failWithError(error);\n else\n throw error;\n };\n\n const finalizer = () => {\n step.complete({});\n };\n\n try {\n setMatcherCallContext({ expectInfo: this._info, testInfo, step: step.info });\n const callback = () => matcher.call(target, ...args);\n const result = currentZone().with('stepZone', step).run(callback);\n if (result instanceof Promise)\n return result.then(finalizer).catch(reportStepError);\n finalizer();\n return result;\n } catch (e) {\n void reportStepError(e);\n }\n };\n }\n}\n\nasync function pollMatcher(qualifiedMatcherName: string, info: ExpectMetaInfo, prefix: string[], ...args: any[]) {\n const testInfo = currentTestInfo();\n const poll = info.poll!;\n const timeout = poll.timeout ?? info.timeout ?? testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;\n const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : TestInfoImpl._defaultDeadlineForMatcher(timeout);\n\n const result = await pollAgainstDeadline<Error|undefined>(async () => {\n if (testInfo && currentTestInfo() !== testInfo)\n return { continuePolling: false, result: undefined };\n\n const innerInfo: ExpectMetaInfo = {\n ...info,\n isSoft: false, // soft is outside of poll, not inside\n poll: undefined,\n };\n const value = await poll.generator();\n try {\n let matchers = createMatchers(value, innerInfo, prefix);\n if (info.isNot)\n matchers = matchers.not;\n matchers[qualifiedMatcherName](...args);\n return { continuePolling: false, result: undefined };\n } catch (error) {\n return { continuePolling: true, result: error };\n }\n }, deadline, poll.intervals ?? [100, 250, 500, 1000]);\n\n if (result.timedOut) {\n const message = result.result ? [\n result.result.message,\n '',\n `Call Log:`,\n `- ${timeoutMessage}`,\n ].join('\\n') : timeoutMessage;\n\n throw new Error(message);\n }\n}\n\nfunction computeArgsSuffix(matcherName: string, args: any[]) {\n let value = '';\n if (matcherName === 'toHaveScreenshot')\n value = toHaveScreenshotStepTitle(...args);\n return value ? `(${value})` : '';\n}\n\nexport const expect: Expect<{}> = createExpect({}, [], {}).extend(customMatchers);\n\nexport function mergeExpects(...expects: any[]) {\n let merged = expect;\n for (const e of expects) {\n const internals = e[userMatchersSymbol];\n if (!internals) // non-playwright expects mutate the global expect, so we don't need to do anything special\n continue;\n merged = merged.extend(internals);\n }\n return merged;\n}\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,mBAM6B;AAE7B,yBAAyC;AACzC,sBA8BO;AACP,iCAAoC;AACpC,6BAA6E;AAC7E,0BAKO;AACP,qBAAgC;AAChC,kBAAmC;AACnC,sBAA6B;AAkB7B,MAAM,iBAAiB,CAAC,QAAwB,IAAI,QAAQ,SAAS,MAAM;AAEpE,MAAM,8CAA8C,CACzD,UACA,OACA,eAEA;AAAA,EACI,MACA,eAAe,SAAS,MAAM,GAAG,KAAK,CAAC,QACvC,oCAAe,eAAe,SAAS,MAAM,OAAO,QAAQ,MAAM,CAAC,CAAC,IACpE,eAAe,SAAS,MAAM,QAAQ,MAAM,CAAC,IAC7C;AACJ;AAEK,MAAM,2CAA2C,CACtD,UACA,WAEA,WAAW,WACP,mCAAc,QAAQ,IACtB;AAAA,EACE;AAAA,EACA,OAAO;AAAA,EACP,OAAO,CAAC,EAAE;AACd;AAMJ,SAAS,eAAe,QAAiB,MAAsB,QAAuB;AACpF,SAAO,IAAI,UAAM,oBAAAA,QAAc,MAAM,GAAG,IAAI,2BAA2B,MAAM,MAAM,CAAC;AACtF;AAEA,MAAM,qBAAqB,OAAO,cAAc;AAEhD,SAAS,qBAAqB,WAAqB,aAAqB;AACtE,SAAO,UAAU,KAAK,GAAG,IAAI,MAAM;AACrC;AAEA,SAAS,aAAa,MAAsB,QAAkB,cAAwC;AACpG,QAAM,iBAA6B,IAAI,MAAM,oBAAAA,QAAe;AAAA,IAC1D,OAAO,SAAS,QAAa,SAAc,eAA0C;AACnF,YAAM,CAAC,QAAQ,gBAAgB,IAAI;AACnC,Y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AM,QAAQ,MAAM,KAAK,UAAU;AACnC,QAAI;AACF,UAAI,WAAW,eAAe,OAAO,WAAW,MAAM;AACtD,UAAI,KAAK;AACP,mBAAW,SAAS;AACtB,eAASA,qBAAoB,EAAE,GAAG,IAAI;AACtC,aAAO,EAAE,iBAAiB,OAAO,QAAQ,OAAU;AAAA,IACrD,SAAS,OAAO;AACd,aAAO,EAAE,iBAAiB,MAAM,QAAQ,MAAM;AAAA,IAChD;AAAA,EACF,GAAG,UAAU,KAAK,aAAa,CAAC,KAAK,KAAK,KAAK,GAAI,CAAC;AAEpD,MAAI,OAAO,UAAU;AACnB,UAAM,UAAU,OAAO,SAAS;AAAA,MAC9B,OAAO,OAAO;AAAA,MACd;AAAA,MACA;AAAA,MACA,KAAK,cAAc;AAAA,IACrB,EAAE,KAAK,IAAI,IAAI;AAEf,UAAM,IAAI,MAAM,OAAO;AAAA,EACzB;AACF;AAEA,SAAS,kBAAkB,aAAqB,MAAa;AAC3D,MAAI,QAAQ;AACZ,MAAI,gBAAgB;AAClB,gBAAQ,kDAA0B,GAAG,IAAI;AAC3C,SAAO,QAAQ,IAAI,KAAK,MAAM;AAChC;AAEO,MAAM,SAAqB,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,cAAc;AAEzE,SAAS,gBAAgB,SAAgB;AAC9C,MAAI,SAAS;AACb,aAAW,KAAK,SAAS;AACvB,UAAM,YAAY,EAAE,kBAAkB;AACtC,QAAI,CAAC;AACH;AACF,aAAS,OAAO,OAAO,SAAS;AAAA,EAClC;AACA,SAAO;AACT;",
|
6
|
+
"names": ["expectLibrary", "qualifiedMatcherName"]
|
7
|
+
}
|
@@ -0,0 +1,87 @@
|
|
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 matcherHint_exports = {};
|
20
|
+
__export(matcherHint_exports, {
|
21
|
+
ExpectError: () => ExpectError,
|
22
|
+
callLogText: () => callLogText,
|
23
|
+
formatMatcherMessage: () => formatMatcherMessage,
|
24
|
+
isJestError: () => isJestError
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(matcherHint_exports);
|
27
|
+
var import_utils = require("playwright-core/lib/utils");
|
28
|
+
var import_expectBundle = require("../common/expectBundle");
|
29
|
+
function formatMatcherMessage(state, details) {
|
30
|
+
const receiver = details.receiver ?? (details.locator ? "locator" : "page");
|
31
|
+
let message = (0, import_expectBundle.DIM_COLOR)("expect(") + (0, import_expectBundle.RECEIVED_COLOR)(receiver) + (0, import_expectBundle.DIM_COLOR)(")" + (state.promise ? "." + state.promise : "") + (state.isNot ? ".not" : "") + ".") + details.matcherName + (0, import_expectBundle.DIM_COLOR)("(") + (0, import_expectBundle.EXPECTED_COLOR)(details.expectation) + (0, import_expectBundle.DIM_COLOR)(")") + " failed\n\n";
|
32
|
+
const diffLines = details.printedDiff?.split("\n");
|
33
|
+
if (diffLines?.length === 2) {
|
34
|
+
details.printedExpected = diffLines[0];
|
35
|
+
details.printedReceived = diffLines[1];
|
36
|
+
details.printedDiff = void 0;
|
37
|
+
}
|
38
|
+
const align = !details.errorMessage && details.printedExpected?.startsWith("Expected:") && (!details.printedReceived || details.printedReceived.startsWith("Received:"));
|
39
|
+
if (details.locator)
|
40
|
+
message += `Locator: ${align ? " " : ""}${String(details.locator)}
|
41
|
+
`;
|
42
|
+
if (details.printedExpected)
|
43
|
+
message += details.printedExpected + "\n";
|
44
|
+
if (details.printedReceived)
|
45
|
+
message += details.printedReceived + "\n";
|
46
|
+
if (details.timedOut && details.timeout)
|
47
|
+
message += `Timeout: ${align ? " " : ""}${details.timeout}ms
|
48
|
+
`;
|
49
|
+
if (details.printedDiff)
|
50
|
+
message += details.printedDiff + "\n";
|
51
|
+
if (details.errorMessage) {
|
52
|
+
message += details.errorMessage;
|
53
|
+
if (!details.errorMessage.endsWith("\n"))
|
54
|
+
message += "\n";
|
55
|
+
}
|
56
|
+
message += callLogText(details.log);
|
57
|
+
return message;
|
58
|
+
}
|
59
|
+
class ExpectError extends Error {
|
60
|
+
constructor(jestError, customMessage, stackFrames) {
|
61
|
+
super("");
|
62
|
+
this.name = jestError.name;
|
63
|
+
this.message = jestError.message;
|
64
|
+
this.matcherResult = jestError.matcherResult;
|
65
|
+
if (customMessage)
|
66
|
+
this.message = customMessage + "\n\n" + this.message;
|
67
|
+
this.stack = this.name + ": " + this.message + "\n" + (0, import_utils.stringifyStackFrames)(stackFrames).join("\n");
|
68
|
+
}
|
69
|
+
}
|
70
|
+
function isJestError(e) {
|
71
|
+
return e instanceof Error && "matcherResult" in e;
|
72
|
+
}
|
73
|
+
const callLogText = (log) => {
|
74
|
+
if (!log || !log.some((l) => !!l))
|
75
|
+
return "";
|
76
|
+
return `
|
77
|
+
Call log:
|
78
|
+
${(0, import_expectBundle.DIM_COLOR)(log.join("\n"))}
|
79
|
+
`;
|
80
|
+
};
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
82
|
+
0 && (module.exports = {
|
83
|
+
ExpectError,
|
84
|
+
callLogText,
|
85
|
+
formatMatcherMessage,
|
86
|
+
isJestError
|
87
|
+
});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/matchers/matcherHint.ts"],
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { stringifyStackFrames } from 'playwright-core/lib/utils';\n\nimport type { ExpectMatcherState } from '../../types/test';\nimport type { StackFrame } from '@protocol/channels';\nimport type { Locator } from 'playwright-core';\n\nexport const kNoElementsFoundError = '<element(s) not found>';\n\nexport function matcherHint(state: ExpectMatcherState, locator: Locator | undefined, matcherName: string, expression: any, actual: any, matcherOptions: any, timeout: number | undefined, expectedReceivedString?: string, preventExtraStatIndent: boolean = false) {\n let header = state.utils.matcherHint(matcherName, expression, actual, matcherOptions).replace(/ \\/\\/ deep equality/, '') + ' failed\\n\\n';\n // Extra space added after locator and timeout to match Jest's received/expected output\n const extraSpace = preventExtraStatIndent ? '' : ' ';\n if (locator)\n header += `Locator: ${extraSpace}${String(locator)}\\n`;\n if (expectedReceivedString)\n header += `${expectedReceivedString}\\n`;\n if (timeout)\n header += `Timeout: ${extraSpace}${timeout}ms\\n`;\n return header;\n}\n\nexport type MatcherResult<E, A> = {\n name: string;\n expected?: E;\n message: () => string;\n pass: boolean;\n actual?: A;\n log?: string[];\n timeout?: number;\n suggestedRebaseline?: string;\n};\n\nexport type MatcherResultProperty = Omit<MatcherResult<unknown, unknown>, 'message'> & {\n message: string;\n};\n\ntype JestError = Error & {\n matcherResult: MatcherResultProperty;\n};\n\nexport class ExpectError extends Error {\n matcherResult: MatcherResultProperty;\n\n constructor(jestError: JestError, customMessage: string, stackFrames: StackFrame[]) {\n super('');\n // Copy to erase the JestMatcherError constructor name from the console.log(error).\n this.name = jestError.name;\n this.message = jestError.message;\n this.matcherResult = jestError.matcherResult;\n\n if (customMessage)\n this.message = customMessage + '\\n\\n' + this.message;\n this.stack = this.name + ': ' + this.message + '\\n' + stringifyStackFrames(stackFrames).join('\\n');\n }\n}\n\nexport function isJestError(e: unknown): e is JestError {\n return e instanceof Error && 'matcherResult' in e;\n}\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,mBAAqC;AAM9B,MAAM,wBAAwB;AAE9B,SAAS,YAAY,OAA2B,SAA8B,aAAqB,YAAiB,QAAa,gBAAqB,SAA6B,wBAAiC,yBAAkC,OAAO;AAClQ,MAAI,SAAS,MAAM,MAAM,YAAY,aAAa,YAAY,QAAQ,cAAc,EAAE,QAAQ,uBAAuB,EAAE,IAAI;AAE3H,QAAM,aAAa,yBAAyB,KAAK;AACjD,MAAI;AACF,cAAU,YAAY,UAAU,GAAG,OAAO,OAAO,CAAC;AAAA;AACpD,MAAI;AACF,cAAU,GAAG,sBAAsB;AAAA;AACrC,MAAI;AACF,cAAU,YAAY,UAAU,GAAG,OAAO;AAAA;AAC5C,SAAO;AACT;AAqBO,MAAM,oBAAoB,MAAM;AAAA,EAGrC,YAAY,WAAsB,eAAuB,aAA2B;AAClF,UAAM,EAAE;AAER,SAAK,OAAO,UAAU;AACtB,SAAK,UAAU,UAAU;AACzB,SAAK,gBAAgB,UAAU;AAE/B,QAAI;AACF,WAAK,UAAU,gBAAgB,SAAS,KAAK;AAC/C,SAAK,QAAQ,KAAK,OAAO,OAAO,KAAK,UAAU,WAAO,mCAAqB,WAAW,EAAE,KAAK,IAAI;AAAA,EACnG;AACF;AAEO,SAAS,YAAY,GAA4B;AACtD,SAAO,aAAa,SAAS,mBAAmB;AAClD;",
|
6
|
+
"names": []
|
7
|
+
}
|