@scoutqa/playwright 1.58.0-fork.1
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 +3919 -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 +281 -0
- package/lib/common/configLoader.js +344 -0
- package/lib/common/esmLoaderHost.js +104 -0
- package/lib/common/expectBundle.js +43 -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 +322 -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 +721 -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 +523 -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 +324 -0
- package/lib/matchers/matcherHint.js +87 -0
- package/lib/matchers/matchers.js +382 -0
- package/lib/matchers/toBeTruthy.js +73 -0
- package/lib/matchers/toEqual.js +99 -0
- package/lib/matchers/toHaveURL.js +102 -0
- package/lib/matchers/toMatchAriaSnapshot.js +159 -0
- package/lib/matchers/toMatchSnapshot.js +341 -0
- package/lib/matchers/toMatchText.js +99 -0
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/browserContextFactory.js +321 -0
- package/lib/mcp/browser/browserServerBackend.js +77 -0
- package/lib/mcp/browser/config.js +418 -0
- package/lib/mcp/browser/context.js +285 -0
- package/lib/mcp/browser/response.js +352 -0
- package/lib/mcp/browser/sessionLog.js +160 -0
- package/lib/mcp/browser/tab.js +328 -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 +59 -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 +69 -0
- package/lib/mcp/browser/tools/keyboard.js +84 -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 +60 -0
- package/lib/mcp/browser/tools/pdf.js +48 -0
- package/lib/mcp/browser/tools/runCode.js +77 -0
- package/lib/mcp/browser/tools/screenshot.js +105 -0
- package/lib/mcp/browser/tools/snapshot.js +191 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +50 -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 +93 -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 +207 -0
- package/lib/mcp/sdk/tool.js +47 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/plannerTools.js +144 -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 +279 -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 +609 -0
- package/lib/reporters/blob.js +139 -0
- package/lib/reporters/dot.js +82 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/github.js +128 -0
- package/lib/reporters/html.js +623 -0
- package/lib/reporters/internalReporter.js +140 -0
- package/lib/reporters/json.js +255 -0
- package/lib/reporters/junit.js +232 -0
- package/lib/reporters/line.js +113 -0
- package/lib/reporters/list.js +231 -0
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/markdown.js +144 -0
- package/lib/reporters/merge.js +546 -0
- package/lib/reporters/multiplexer.js +112 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/teleEmitter.js +319 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/runner/dispatcher.js +533 -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 +43 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/babelHighlightUtils.js +63 -0
- package/lib/transform/compilationCache.js +272 -0
- package/lib/transform/esmLoader.js +103 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/transform.js +296 -0
- package/lib/util.js +403 -0
- package/lib/utilsBundle.js +43 -0
- package/lib/utilsBundleImpl.js +100 -0
- package/lib/worker/fixtureRunner.js +258 -0
- package/lib/worker/testInfo.js +557 -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 +529 -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 +10277 -0
- package/types/testReporter.d.ts +827 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var internalReporter_exports = {};
|
|
30
|
+
__export(internalReporter_exports, {
|
|
31
|
+
InternalReporter: () => InternalReporter,
|
|
32
|
+
addLocationAndSnippetToError: () => addLocationAndSnippetToError
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(internalReporter_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
37
|
+
var import_base = require("./base");
|
|
38
|
+
var import_multiplexer = require("./multiplexer");
|
|
39
|
+
var import_test = require("../common/test");
|
|
40
|
+
var import_babelBundle = require("../transform/babelBundle");
|
|
41
|
+
var import_reporterV2 = require("./reporterV2");
|
|
42
|
+
class InternalReporter {
|
|
43
|
+
constructor(reporters) {
|
|
44
|
+
this._didBegin = false;
|
|
45
|
+
this._reporter = new import_multiplexer.Multiplexer(reporters.map(import_reporterV2.wrapReporterAsV2));
|
|
46
|
+
}
|
|
47
|
+
version() {
|
|
48
|
+
return "v2";
|
|
49
|
+
}
|
|
50
|
+
onConfigure(config) {
|
|
51
|
+
this._config = config;
|
|
52
|
+
this._startTime = /* @__PURE__ */ new Date();
|
|
53
|
+
this._monotonicStartTime = (0, import_utils.monotonicTime)();
|
|
54
|
+
this._reporter.onConfigure?.(config);
|
|
55
|
+
}
|
|
56
|
+
onBegin(suite) {
|
|
57
|
+
this._didBegin = true;
|
|
58
|
+
this._reporter.onBegin?.(suite);
|
|
59
|
+
}
|
|
60
|
+
onTestBegin(test, result) {
|
|
61
|
+
this._reporter.onTestBegin?.(test, result);
|
|
62
|
+
}
|
|
63
|
+
onStdOut(chunk, test, result) {
|
|
64
|
+
this._reporter.onStdOut?.(chunk, test, result);
|
|
65
|
+
}
|
|
66
|
+
onStdErr(chunk, test, result) {
|
|
67
|
+
this._reporter.onStdErr?.(chunk, test, result);
|
|
68
|
+
}
|
|
69
|
+
async onTestPaused(test, result, step) {
|
|
70
|
+
this._addSnippetToTestErrors(test, result);
|
|
71
|
+
if (step)
|
|
72
|
+
this._addSnippetToStepError(test, step);
|
|
73
|
+
return await this._reporter.onTestPaused?.(test, result, step) ?? { action: void 0 };
|
|
74
|
+
}
|
|
75
|
+
onTestEnd(test, result) {
|
|
76
|
+
this._addSnippetToTestErrors(test, result);
|
|
77
|
+
this._reporter.onTestEnd?.(test, result);
|
|
78
|
+
}
|
|
79
|
+
async onEnd(result) {
|
|
80
|
+
if (!this._didBegin) {
|
|
81
|
+
this.onBegin(new import_test.Suite("", "root"));
|
|
82
|
+
}
|
|
83
|
+
return await this._reporter.onEnd?.({
|
|
84
|
+
...result,
|
|
85
|
+
startTime: this._startTime,
|
|
86
|
+
duration: (0, import_utils.monotonicTime)() - this._monotonicStartTime
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async onExit() {
|
|
90
|
+
await this._reporter.onExit?.();
|
|
91
|
+
}
|
|
92
|
+
onError(error) {
|
|
93
|
+
addLocationAndSnippetToError(this._config, error);
|
|
94
|
+
this._reporter.onError?.(error);
|
|
95
|
+
}
|
|
96
|
+
onStepBegin(test, result, step) {
|
|
97
|
+
this._reporter.onStepBegin?.(test, result, step);
|
|
98
|
+
}
|
|
99
|
+
onStepEnd(test, result, step) {
|
|
100
|
+
this._addSnippetToStepError(test, step);
|
|
101
|
+
this._reporter.onStepEnd?.(test, result, step);
|
|
102
|
+
}
|
|
103
|
+
printsToStdio() {
|
|
104
|
+
return this._reporter.printsToStdio ? this._reporter.printsToStdio() : true;
|
|
105
|
+
}
|
|
106
|
+
_addSnippetToTestErrors(test, result) {
|
|
107
|
+
for (const error of result.errors)
|
|
108
|
+
addLocationAndSnippetToError(this._config, error, test.location.file);
|
|
109
|
+
}
|
|
110
|
+
_addSnippetToStepError(test, step) {
|
|
111
|
+
if (step.error)
|
|
112
|
+
addLocationAndSnippetToError(this._config, step.error, test.location.file);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function addLocationAndSnippetToError(config, error, file) {
|
|
116
|
+
if (error.stack && !error.location)
|
|
117
|
+
error.location = (0, import_base.prepareErrorStack)(error.stack).location;
|
|
118
|
+
const location = error.location;
|
|
119
|
+
if (!location)
|
|
120
|
+
return;
|
|
121
|
+
if (!!error.snippet)
|
|
122
|
+
return;
|
|
123
|
+
try {
|
|
124
|
+
const tokens = [];
|
|
125
|
+
const source = import_fs.default.readFileSync(location.file, "utf8");
|
|
126
|
+
const codeFrame = (0, import_babelBundle.codeFrameColumns)(source, { start: location }, { highlightCode: true });
|
|
127
|
+
if (!file || import_fs.default.realpathSync(file) !== location.file) {
|
|
128
|
+
tokens.push(import_base.internalScreen.colors.gray(` at `) + `${(0, import_base.relativeFilePath)(import_base.internalScreen, config, location.file)}:${location.line}`);
|
|
129
|
+
tokens.push("");
|
|
130
|
+
}
|
|
131
|
+
tokens.push(codeFrame);
|
|
132
|
+
error.snippet = tokens.join("\n");
|
|
133
|
+
} catch (e) {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
137
|
+
0 && (module.exports = {
|
|
138
|
+
InternalReporter,
|
|
139
|
+
addLocationAndSnippetToError
|
|
140
|
+
});
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var json_exports = {};
|
|
30
|
+
__export(json_exports, {
|
|
31
|
+
default: () => json_default,
|
|
32
|
+
serializePatterns: () => serializePatterns
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(json_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
38
|
+
var import_base = require("./base");
|
|
39
|
+
var import_config = require("../common/config");
|
|
40
|
+
class JSONReporter {
|
|
41
|
+
constructor(options) {
|
|
42
|
+
this._errors = [];
|
|
43
|
+
this._resolvedOutputFile = (0, import_base.resolveOutputFile)("JSON", options)?.outputFile;
|
|
44
|
+
}
|
|
45
|
+
version() {
|
|
46
|
+
return "v2";
|
|
47
|
+
}
|
|
48
|
+
printsToStdio() {
|
|
49
|
+
return !this._resolvedOutputFile;
|
|
50
|
+
}
|
|
51
|
+
onConfigure(config) {
|
|
52
|
+
this.config = config;
|
|
53
|
+
}
|
|
54
|
+
onBegin(suite) {
|
|
55
|
+
this.suite = suite;
|
|
56
|
+
}
|
|
57
|
+
onError(error) {
|
|
58
|
+
this._errors.push(error);
|
|
59
|
+
}
|
|
60
|
+
async onEnd(result) {
|
|
61
|
+
await outputReport(this._serializeReport(result), this._resolvedOutputFile);
|
|
62
|
+
}
|
|
63
|
+
_serializeReport(result) {
|
|
64
|
+
const report = {
|
|
65
|
+
config: {
|
|
66
|
+
...removePrivateFields(this.config),
|
|
67
|
+
rootDir: (0, import_utils.toPosixPath)(this.config.rootDir),
|
|
68
|
+
projects: this.config.projects.map((project) => {
|
|
69
|
+
return {
|
|
70
|
+
outputDir: (0, import_utils.toPosixPath)(project.outputDir),
|
|
71
|
+
repeatEach: project.repeatEach,
|
|
72
|
+
retries: project.retries,
|
|
73
|
+
metadata: project.metadata,
|
|
74
|
+
id: (0, import_config.getProjectId)(project),
|
|
75
|
+
name: project.name,
|
|
76
|
+
testDir: (0, import_utils.toPosixPath)(project.testDir),
|
|
77
|
+
testIgnore: serializePatterns(project.testIgnore),
|
|
78
|
+
testMatch: serializePatterns(project.testMatch),
|
|
79
|
+
timeout: project.timeout
|
|
80
|
+
};
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
suites: this._mergeSuites(this.suite.suites),
|
|
84
|
+
errors: this._errors,
|
|
85
|
+
stats: {
|
|
86
|
+
startTime: result.startTime.toISOString(),
|
|
87
|
+
duration: result.duration,
|
|
88
|
+
expected: 0,
|
|
89
|
+
skipped: 0,
|
|
90
|
+
unexpected: 0,
|
|
91
|
+
flaky: 0
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
for (const test of this.suite.allTests())
|
|
95
|
+
++report.stats[test.outcome()];
|
|
96
|
+
return report;
|
|
97
|
+
}
|
|
98
|
+
_mergeSuites(suites) {
|
|
99
|
+
const fileSuites = new import_utils.MultiMap();
|
|
100
|
+
for (const projectSuite of suites) {
|
|
101
|
+
const projectId = (0, import_config.getProjectId)(projectSuite.project());
|
|
102
|
+
const projectName = projectSuite.project().name;
|
|
103
|
+
for (const fileSuite of projectSuite.suites) {
|
|
104
|
+
const file = fileSuite.location.file;
|
|
105
|
+
const serialized = this._serializeSuite(projectId, projectName, fileSuite);
|
|
106
|
+
if (serialized)
|
|
107
|
+
fileSuites.set(file, serialized);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const results = [];
|
|
111
|
+
for (const [, suites2] of fileSuites) {
|
|
112
|
+
const result = {
|
|
113
|
+
title: suites2[0].title,
|
|
114
|
+
file: suites2[0].file,
|
|
115
|
+
column: 0,
|
|
116
|
+
line: 0,
|
|
117
|
+
specs: []
|
|
118
|
+
};
|
|
119
|
+
for (const suite of suites2)
|
|
120
|
+
this._mergeTestsFromSuite(result, suite);
|
|
121
|
+
results.push(result);
|
|
122
|
+
}
|
|
123
|
+
return results;
|
|
124
|
+
}
|
|
125
|
+
_relativeLocation(location) {
|
|
126
|
+
if (!location)
|
|
127
|
+
return { file: "", line: 0, column: 0 };
|
|
128
|
+
return {
|
|
129
|
+
file: (0, import_utils.toPosixPath)(import_path.default.relative(this.config.rootDir, location.file)),
|
|
130
|
+
line: location.line,
|
|
131
|
+
column: location.column
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
_locationMatches(s1, s2) {
|
|
135
|
+
return s1.file === s2.file && s1.line === s2.line && s1.column === s2.column;
|
|
136
|
+
}
|
|
137
|
+
_mergeTestsFromSuite(to, from) {
|
|
138
|
+
for (const fromSuite of from.suites || []) {
|
|
139
|
+
const toSuite = (to.suites || []).find((s) => s.title === fromSuite.title && this._locationMatches(s, fromSuite));
|
|
140
|
+
if (toSuite) {
|
|
141
|
+
this._mergeTestsFromSuite(toSuite, fromSuite);
|
|
142
|
+
} else {
|
|
143
|
+
if (!to.suites)
|
|
144
|
+
to.suites = [];
|
|
145
|
+
to.suites.push(fromSuite);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
for (const spec of from.specs || []) {
|
|
149
|
+
const toSpec = to.specs.find((s) => s.title === spec.title && s.file === (0, import_utils.toPosixPath)(import_path.default.relative(this.config.rootDir, spec.file)) && s.line === spec.line && s.column === spec.column);
|
|
150
|
+
if (toSpec)
|
|
151
|
+
toSpec.tests.push(...spec.tests);
|
|
152
|
+
else
|
|
153
|
+
to.specs.push(spec);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_serializeSuite(projectId, projectName, suite) {
|
|
157
|
+
if (!suite.allTests().length)
|
|
158
|
+
return null;
|
|
159
|
+
const suites = suite.suites.map((suite2) => this._serializeSuite(projectId, projectName, suite2)).filter((s) => s);
|
|
160
|
+
return {
|
|
161
|
+
title: suite.title,
|
|
162
|
+
...this._relativeLocation(suite.location),
|
|
163
|
+
specs: suite.tests.map((test) => this._serializeTestSpec(projectId, projectName, test)),
|
|
164
|
+
suites: suites.length ? suites : void 0
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
_serializeTestSpec(projectId, projectName, test) {
|
|
168
|
+
return {
|
|
169
|
+
title: test.title,
|
|
170
|
+
ok: test.ok(),
|
|
171
|
+
tags: test.tags.map((tag) => tag.substring(1)),
|
|
172
|
+
// Strip '@'.
|
|
173
|
+
tests: [this._serializeTest(projectId, projectName, test)],
|
|
174
|
+
id: test.id,
|
|
175
|
+
...this._relativeLocation(test.location)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
_serializeTest(projectId, projectName, test) {
|
|
179
|
+
return {
|
|
180
|
+
timeout: test.timeout,
|
|
181
|
+
annotations: test.annotations,
|
|
182
|
+
expectedStatus: test.expectedStatus,
|
|
183
|
+
projectId,
|
|
184
|
+
projectName,
|
|
185
|
+
results: test.results.map((r) => this._serializeTestResult(r, test)),
|
|
186
|
+
status: test.outcome()
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
_serializeTestResult(result, test) {
|
|
190
|
+
const steps = result.steps.filter((s) => s.category === "test.step");
|
|
191
|
+
const jsonResult = {
|
|
192
|
+
workerIndex: result.workerIndex,
|
|
193
|
+
parallelIndex: result.parallelIndex,
|
|
194
|
+
shardIndex: result.shardIndex,
|
|
195
|
+
status: result.status,
|
|
196
|
+
duration: result.duration,
|
|
197
|
+
error: result.error,
|
|
198
|
+
errors: result.errors.map((e) => this._serializeError(e)),
|
|
199
|
+
stdout: result.stdout.map((s) => stdioEntry(s)),
|
|
200
|
+
stderr: result.stderr.map((s) => stdioEntry(s)),
|
|
201
|
+
retry: result.retry,
|
|
202
|
+
steps: steps.length ? steps.map((s) => this._serializeTestStep(s)) : void 0,
|
|
203
|
+
startTime: result.startTime.toISOString(),
|
|
204
|
+
annotations: result.annotations,
|
|
205
|
+
attachments: result.attachments.map((a) => ({
|
|
206
|
+
name: a.name,
|
|
207
|
+
contentType: a.contentType,
|
|
208
|
+
path: a.path,
|
|
209
|
+
body: a.body?.toString("base64")
|
|
210
|
+
}))
|
|
211
|
+
};
|
|
212
|
+
if (result.error?.stack)
|
|
213
|
+
jsonResult.errorLocation = (0, import_base.prepareErrorStack)(result.error.stack).location;
|
|
214
|
+
return jsonResult;
|
|
215
|
+
}
|
|
216
|
+
_serializeError(error) {
|
|
217
|
+
return (0, import_base.formatError)(import_base.nonTerminalScreen, error);
|
|
218
|
+
}
|
|
219
|
+
_serializeTestStep(step) {
|
|
220
|
+
const steps = step.steps.filter((s) => s.category === "test.step");
|
|
221
|
+
return {
|
|
222
|
+
title: step.title,
|
|
223
|
+
duration: step.duration,
|
|
224
|
+
error: step.error,
|
|
225
|
+
steps: steps.length ? steps.map((s) => this._serializeTestStep(s)) : void 0
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async function outputReport(report, resolvedOutputFile) {
|
|
230
|
+
const reportString = JSON.stringify(report, void 0, 2);
|
|
231
|
+
if (resolvedOutputFile) {
|
|
232
|
+
await import_fs.default.promises.mkdir(import_path.default.dirname(resolvedOutputFile), { recursive: true });
|
|
233
|
+
await import_fs.default.promises.writeFile(resolvedOutputFile, reportString);
|
|
234
|
+
} else {
|
|
235
|
+
console.log(reportString);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function stdioEntry(s) {
|
|
239
|
+
if (typeof s === "string")
|
|
240
|
+
return { text: s };
|
|
241
|
+
return { buffer: s.toString("base64") };
|
|
242
|
+
}
|
|
243
|
+
function removePrivateFields(config) {
|
|
244
|
+
return Object.fromEntries(Object.entries(config).filter(([name, value]) => !name.startsWith("_")));
|
|
245
|
+
}
|
|
246
|
+
function serializePatterns(patterns) {
|
|
247
|
+
if (!Array.isArray(patterns))
|
|
248
|
+
patterns = [patterns];
|
|
249
|
+
return patterns.map((s) => s.toString());
|
|
250
|
+
}
|
|
251
|
+
var json_default = JSONReporter;
|
|
252
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
253
|
+
0 && (module.exports = {
|
|
254
|
+
serializePatterns
|
|
255
|
+
});
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var junit_exports = {};
|
|
30
|
+
__export(junit_exports, {
|
|
31
|
+
default: () => junit_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(junit_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
37
|
+
var import_base = require("./base");
|
|
38
|
+
var import_util = require("../util");
|
|
39
|
+
class JUnitReporter {
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.totalTests = 0;
|
|
42
|
+
this.totalFailures = 0;
|
|
43
|
+
this.totalSkipped = 0;
|
|
44
|
+
this.stripANSIControlSequences = false;
|
|
45
|
+
this.includeProjectInTestName = false;
|
|
46
|
+
this.stripANSIControlSequences = (0, import_utils.getAsBooleanFromENV)("PLAYWRIGHT_JUNIT_STRIP_ANSI", !!options.stripANSIControlSequences);
|
|
47
|
+
this.includeProjectInTestName = (0, import_utils.getAsBooleanFromENV)("PLAYWRIGHT_JUNIT_INCLUDE_PROJECT_IN_TEST_NAME", !!options.includeProjectInTestName);
|
|
48
|
+
this.configDir = options.configDir;
|
|
49
|
+
this.resolvedOutputFile = (0, import_base.resolveOutputFile)("JUNIT", options)?.outputFile;
|
|
50
|
+
}
|
|
51
|
+
version() {
|
|
52
|
+
return "v2";
|
|
53
|
+
}
|
|
54
|
+
printsToStdio() {
|
|
55
|
+
return !this.resolvedOutputFile;
|
|
56
|
+
}
|
|
57
|
+
onConfigure(config) {
|
|
58
|
+
this.config = config;
|
|
59
|
+
}
|
|
60
|
+
onBegin(suite) {
|
|
61
|
+
this.suite = suite;
|
|
62
|
+
this.timestamp = /* @__PURE__ */ new Date();
|
|
63
|
+
}
|
|
64
|
+
async onEnd(result) {
|
|
65
|
+
const children = [];
|
|
66
|
+
for (const projectSuite of this.suite.suites) {
|
|
67
|
+
for (const fileSuite of projectSuite.suites)
|
|
68
|
+
children.push(await this._buildTestSuite(projectSuite.title, fileSuite));
|
|
69
|
+
}
|
|
70
|
+
const tokens = [];
|
|
71
|
+
const self = this;
|
|
72
|
+
const root = {
|
|
73
|
+
name: "testsuites",
|
|
74
|
+
attributes: {
|
|
75
|
+
id: process.env[`PLAYWRIGHT_JUNIT_SUITE_ID`] || "",
|
|
76
|
+
name: process.env[`PLAYWRIGHT_JUNIT_SUITE_NAME`] || "",
|
|
77
|
+
tests: self.totalTests,
|
|
78
|
+
failures: self.totalFailures,
|
|
79
|
+
skipped: self.totalSkipped,
|
|
80
|
+
errors: 0,
|
|
81
|
+
time: result.duration / 1e3
|
|
82
|
+
},
|
|
83
|
+
children
|
|
84
|
+
};
|
|
85
|
+
serializeXML(root, tokens, this.stripANSIControlSequences);
|
|
86
|
+
const reportString = tokens.join("\n");
|
|
87
|
+
if (this.resolvedOutputFile) {
|
|
88
|
+
await import_fs.default.promises.mkdir(import_path.default.dirname(this.resolvedOutputFile), { recursive: true });
|
|
89
|
+
await import_fs.default.promises.writeFile(this.resolvedOutputFile, reportString);
|
|
90
|
+
} else {
|
|
91
|
+
console.log(reportString);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async _buildTestSuite(projectName, suite) {
|
|
95
|
+
let tests = 0;
|
|
96
|
+
let skipped = 0;
|
|
97
|
+
let failures = 0;
|
|
98
|
+
let duration = 0;
|
|
99
|
+
const children = [];
|
|
100
|
+
const testCaseNamePrefix = projectName && this.includeProjectInTestName ? `[${projectName}] ` : "";
|
|
101
|
+
for (const test of suite.allTests()) {
|
|
102
|
+
++tests;
|
|
103
|
+
if (test.outcome() === "skipped")
|
|
104
|
+
++skipped;
|
|
105
|
+
if (!test.ok())
|
|
106
|
+
++failures;
|
|
107
|
+
for (const result of test.results)
|
|
108
|
+
duration += result.duration;
|
|
109
|
+
await this._addTestCase(suite.title, testCaseNamePrefix, test, children);
|
|
110
|
+
}
|
|
111
|
+
this.totalTests += tests;
|
|
112
|
+
this.totalSkipped += skipped;
|
|
113
|
+
this.totalFailures += failures;
|
|
114
|
+
const entry = {
|
|
115
|
+
name: "testsuite",
|
|
116
|
+
attributes: {
|
|
117
|
+
name: suite.title,
|
|
118
|
+
timestamp: this.timestamp.toISOString(),
|
|
119
|
+
hostname: projectName,
|
|
120
|
+
tests,
|
|
121
|
+
failures,
|
|
122
|
+
skipped,
|
|
123
|
+
time: duration / 1e3,
|
|
124
|
+
errors: 0
|
|
125
|
+
},
|
|
126
|
+
children
|
|
127
|
+
};
|
|
128
|
+
return entry;
|
|
129
|
+
}
|
|
130
|
+
async _addTestCase(suiteName, namePrefix, test, entries) {
|
|
131
|
+
const entry = {
|
|
132
|
+
name: "testcase",
|
|
133
|
+
attributes: {
|
|
134
|
+
// Skip root, project, file
|
|
135
|
+
name: namePrefix + test.titlePath().slice(3).join(" \u203A "),
|
|
136
|
+
// filename
|
|
137
|
+
classname: suiteName,
|
|
138
|
+
time: test.results.reduce((acc, value) => acc + value.duration, 0) / 1e3
|
|
139
|
+
},
|
|
140
|
+
children: []
|
|
141
|
+
};
|
|
142
|
+
entries.push(entry);
|
|
143
|
+
const properties = {
|
|
144
|
+
name: "properties",
|
|
145
|
+
children: []
|
|
146
|
+
};
|
|
147
|
+
for (const annotation of test.annotations) {
|
|
148
|
+
const property = {
|
|
149
|
+
name: "property",
|
|
150
|
+
attributes: {
|
|
151
|
+
name: annotation.type,
|
|
152
|
+
value: annotation?.description ? annotation.description : ""
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
properties.children?.push(property);
|
|
156
|
+
}
|
|
157
|
+
if (properties.children?.length)
|
|
158
|
+
entry.children.push(properties);
|
|
159
|
+
if (test.outcome() === "skipped") {
|
|
160
|
+
entry.children.push({ name: "skipped" });
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (!test.ok()) {
|
|
164
|
+
entry.children.push({
|
|
165
|
+
name: "failure",
|
|
166
|
+
attributes: {
|
|
167
|
+
message: `${import_path.default.basename(test.location.file)}:${test.location.line}:${test.location.column} ${test.title}`,
|
|
168
|
+
type: "FAILURE"
|
|
169
|
+
},
|
|
170
|
+
text: (0, import_util.stripAnsiEscapes)((0, import_base.formatFailure)(import_base.nonTerminalScreen, this.config, test))
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const systemOut = [];
|
|
174
|
+
const systemErr = [];
|
|
175
|
+
for (const result of test.results) {
|
|
176
|
+
for (const item of result.stdout)
|
|
177
|
+
systemOut.push(item.toString());
|
|
178
|
+
for (const item of result.stderr)
|
|
179
|
+
systemErr.push(item.toString());
|
|
180
|
+
for (const attachment of result.attachments) {
|
|
181
|
+
if (!attachment.path)
|
|
182
|
+
continue;
|
|
183
|
+
let attachmentPath = import_path.default.relative(this.configDir, attachment.path);
|
|
184
|
+
try {
|
|
185
|
+
if (this.resolvedOutputFile)
|
|
186
|
+
attachmentPath = import_path.default.relative(import_path.default.dirname(this.resolvedOutputFile), attachment.path);
|
|
187
|
+
} catch {
|
|
188
|
+
systemOut.push(`
|
|
189
|
+
Warning: Unable to make attachment path ${attachment.path} relative to report output file ${this.resolvedOutputFile}`);
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
await import_fs.default.promises.access(attachment.path);
|
|
193
|
+
systemOut.push(`
|
|
194
|
+
[[ATTACHMENT|${attachmentPath}]]
|
|
195
|
+
`);
|
|
196
|
+
} catch {
|
|
197
|
+
systemErr.push(`
|
|
198
|
+
Warning: attachment ${attachmentPath} is missing`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (systemOut.length)
|
|
203
|
+
entry.children.push({ name: "system-out", text: systemOut.join("") });
|
|
204
|
+
if (systemErr.length)
|
|
205
|
+
entry.children.push({ name: "system-err", text: systemErr.join("") });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function serializeXML(entry, tokens, stripANSIControlSequences) {
|
|
209
|
+
const attrs = [];
|
|
210
|
+
for (const [name, value] of Object.entries(entry.attributes || {}))
|
|
211
|
+
attrs.push(`${name}="${escape(String(value), stripANSIControlSequences, false)}"`);
|
|
212
|
+
tokens.push(`<${entry.name}${attrs.length ? " " : ""}${attrs.join(" ")}>`);
|
|
213
|
+
for (const child of entry.children || [])
|
|
214
|
+
serializeXML(child, tokens, stripANSIControlSequences);
|
|
215
|
+
if (entry.text)
|
|
216
|
+
tokens.push(escape(entry.text, stripANSIControlSequences, true));
|
|
217
|
+
tokens.push(`</${entry.name}>`);
|
|
218
|
+
}
|
|
219
|
+
const discouragedXMLCharacters = /[\u0000-\u0008\u000b-\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f]/g;
|
|
220
|
+
function escape(text, stripANSIControlSequences, isCharacterData) {
|
|
221
|
+
if (stripANSIControlSequences)
|
|
222
|
+
text = (0, import_util.stripAnsiEscapes)(text);
|
|
223
|
+
if (isCharacterData) {
|
|
224
|
+
text = "<![CDATA[" + text.replace(/]]>/g, "]]>") + "]]>";
|
|
225
|
+
} else {
|
|
226
|
+
const escapeRe = /[&"'<>]/g;
|
|
227
|
+
text = text.replace(escapeRe, (c) => ({ "&": "&", '"': """, "'": "'", "<": "<", ">": ">" })[c]);
|
|
228
|
+
}
|
|
229
|
+
text = text.replace(discouragedXMLCharacters, "");
|
|
230
|
+
return text;
|
|
231
|
+
}
|
|
232
|
+
var junit_default = JUnitReporter;
|