@smoothdeploy/playwright 1.58.4 → 1.60.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.
Files changed (182) hide show
  1. package/ThirdPartyNotices.txt +8 -5036
  2. package/lib/agents/agentParser.js +2 -2
  3. package/lib/agents/generateAgents.js +21 -22
  4. package/lib/agents/playwright-test-healer.agent.md +1 -0
  5. package/lib/agents/playwright-test-planner.agent.md +2 -1
  6. package/lib/cli/reportActions.js +78 -0
  7. package/lib/cli/testActions.js +211 -0
  8. package/lib/common/index.js +2898 -0
  9. package/lib/common/index.js.txt +35 -0
  10. package/lib/errorContext.js +130 -0
  11. package/lib/index.js +258 -206
  12. package/lib/{isomorphic/testServerConnection.js → isomorphic.js} +70 -35
  13. package/lib/isomorphic.js.txt +9 -0
  14. package/lib/loader/loaderProcessEntry.js +34 -0
  15. package/lib/loader/loaderProcessEntry.js.txt +9 -0
  16. package/lib/matchers/expect.js +12988 -249
  17. package/lib/matchers/expect.js.LICENSE +693 -0
  18. package/lib/matchers/expect.js.txt +72 -0
  19. package/lib/mcp/test/browserBackend.js +49 -22
  20. package/lib/mcp/test/generatorTools.js +16 -16
  21. package/lib/mcp/test/plannerTools.js +25 -20
  22. package/lib/mcp/test/seed.js +7 -7
  23. package/lib/mcp/test/testBackend.js +30 -30
  24. package/lib/mcp/test/testContext.js +50 -33
  25. package/lib/mcp/test/testTools.js +15 -25
  26. package/lib/{internalsForTest.js → package.js} +13 -8
  27. package/lib/program.js +63 -263
  28. package/lib/runner/index.js +8339 -0
  29. package/lib/runner/index.js.txt +60 -0
  30. package/lib/transform/babelBundle.js +71002 -18
  31. package/lib/transform/babelBundle.js.LICENSE +2359 -0
  32. package/lib/transform/babelBundle.js.txt +325 -0
  33. package/lib/transform/esmLoader.js +5884 -30
  34. package/lib/transform/esmLoader.js.LICENSE +335 -0
  35. package/lib/transform/esmLoader.js.txt +55 -0
  36. package/lib/util.js +37 -34
  37. package/lib/worker/workerProcessEntry.js +3251 -0
  38. package/lib/worker/workerProcessEntry.js.txt +24 -0
  39. package/package.json +5 -16
  40. package/test.mjs +1 -0
  41. package/types/test.d.ts +172 -12
  42. package/types/testReporter.d.ts +7 -5
  43. package/lib/common/config.js +0 -282
  44. package/lib/common/configLoader.js +0 -344
  45. package/lib/common/esmLoaderHost.js +0 -104
  46. package/lib/common/expectBundle.js +0 -28
  47. package/lib/common/expectBundleImpl.js +0 -407
  48. package/lib/common/fixtures.js +0 -302
  49. package/lib/common/ipc.js +0 -60
  50. package/lib/common/poolBuilder.js +0 -85
  51. package/lib/common/process.js +0 -132
  52. package/lib/common/suiteUtils.js +0 -140
  53. package/lib/common/test.js +0 -321
  54. package/lib/common/testLoader.js +0 -101
  55. package/lib/common/testType.js +0 -298
  56. package/lib/common/validators.js +0 -68
  57. package/lib/fsWatcher.js +0 -67
  58. package/lib/isomorphic/events.js +0 -77
  59. package/lib/isomorphic/folders.js +0 -30
  60. package/lib/isomorphic/stringInternPool.js +0 -69
  61. package/lib/isomorphic/teleReceiver.js +0 -521
  62. package/lib/isomorphic/teleSuiteUpdater.js +0 -157
  63. package/lib/isomorphic/testServerInterface.js +0 -16
  64. package/lib/isomorphic/testTree.js +0 -329
  65. package/lib/isomorphic/types.d.js +0 -16
  66. package/lib/loader/loaderMain.js +0 -59
  67. package/lib/matchers/matcherHint.js +0 -44
  68. package/lib/matchers/matchers.js +0 -383
  69. package/lib/matchers/toBeTruthy.js +0 -75
  70. package/lib/matchers/toEqual.js +0 -100
  71. package/lib/matchers/toHaveURL.js +0 -101
  72. package/lib/matchers/toMatchAriaSnapshot.js +0 -159
  73. package/lib/matchers/toMatchSnapshot.js +0 -342
  74. package/lib/matchers/toMatchText.js +0 -99
  75. package/lib/mcp/browser/browserContextFactory.js +0 -329
  76. package/lib/mcp/browser/browserServerBackend.js +0 -84
  77. package/lib/mcp/browser/config.js +0 -421
  78. package/lib/mcp/browser/context.js +0 -244
  79. package/lib/mcp/browser/response.js +0 -278
  80. package/lib/mcp/browser/sessionLog.js +0 -75
  81. package/lib/mcp/browser/tab.js +0 -343
  82. package/lib/mcp/browser/tools/common.js +0 -65
  83. package/lib/mcp/browser/tools/console.js +0 -46
  84. package/lib/mcp/browser/tools/dialogs.js +0 -60
  85. package/lib/mcp/browser/tools/evaluate.js +0 -61
  86. package/lib/mcp/browser/tools/files.js +0 -58
  87. package/lib/mcp/browser/tools/form.js +0 -63
  88. package/lib/mcp/browser/tools/install.js +0 -72
  89. package/lib/mcp/browser/tools/keyboard.js +0 -107
  90. package/lib/mcp/browser/tools/mouse.js +0 -107
  91. package/lib/mcp/browser/tools/navigate.js +0 -71
  92. package/lib/mcp/browser/tools/network.js +0 -63
  93. package/lib/mcp/browser/tools/open.js +0 -57
  94. package/lib/mcp/browser/tools/pdf.js +0 -49
  95. package/lib/mcp/browser/tools/runCode.js +0 -78
  96. package/lib/mcp/browser/tools/screenshot.js +0 -93
  97. package/lib/mcp/browser/tools/snapshot.js +0 -173
  98. package/lib/mcp/browser/tools/tabs.js +0 -67
  99. package/lib/mcp/browser/tools/tool.js +0 -47
  100. package/lib/mcp/browser/tools/tracing.js +0 -74
  101. package/lib/mcp/browser/tools/utils.js +0 -94
  102. package/lib/mcp/browser/tools/verify.js +0 -143
  103. package/lib/mcp/browser/tools/wait.js +0 -63
  104. package/lib/mcp/browser/tools.js +0 -84
  105. package/lib/mcp/browser/watchdog.js +0 -44
  106. package/lib/mcp/config.d.js +0 -16
  107. package/lib/mcp/extension/cdpRelay.js +0 -351
  108. package/lib/mcp/extension/extensionContextFactory.js +0 -76
  109. package/lib/mcp/extension/protocol.js +0 -28
  110. package/lib/mcp/index.js +0 -61
  111. package/lib/mcp/log.js +0 -35
  112. package/lib/mcp/program.js +0 -111
  113. package/lib/mcp/sdk/exports.js +0 -28
  114. package/lib/mcp/sdk/http.js +0 -152
  115. package/lib/mcp/sdk/inProcessTransport.js +0 -71
  116. package/lib/mcp/sdk/server.js +0 -223
  117. package/lib/mcp/sdk/tool.js +0 -47
  118. package/lib/mcp/terminal/cli.js +0 -296
  119. package/lib/mcp/terminal/command.js +0 -56
  120. package/lib/mcp/terminal/commands.js +0 -333
  121. package/lib/mcp/terminal/daemon.js +0 -129
  122. package/lib/mcp/terminal/help.json +0 -32
  123. package/lib/mcp/terminal/helpGenerator.js +0 -88
  124. package/lib/mcp/terminal/socketConnection.js +0 -80
  125. package/lib/plugins/gitCommitInfoPlugin.js +0 -198
  126. package/lib/plugins/index.js +0 -28
  127. package/lib/plugins/webServerPlugin.js +0 -237
  128. package/lib/reporters/base.js +0 -634
  129. package/lib/reporters/blob.js +0 -138
  130. package/lib/reporters/dot.js +0 -99
  131. package/lib/reporters/empty.js +0 -32
  132. package/lib/reporters/github.js +0 -128
  133. package/lib/reporters/html.js +0 -633
  134. package/lib/reporters/internalReporter.js +0 -138
  135. package/lib/reporters/json.js +0 -254
  136. package/lib/reporters/junit.js +0 -232
  137. package/lib/reporters/line.js +0 -131
  138. package/lib/reporters/list.js +0 -253
  139. package/lib/reporters/listModeReporter.js +0 -69
  140. package/lib/reporters/markdown.js +0 -144
  141. package/lib/reporters/merge.js +0 -558
  142. package/lib/reporters/multiplexer.js +0 -112
  143. package/lib/reporters/reporterV2.js +0 -102
  144. package/lib/reporters/smoothdeploy.js +0 -333
  145. package/lib/reporters/teleEmitter.js +0 -317
  146. package/lib/reporters/versions/blobV1.js +0 -16
  147. package/lib/runner/dispatcher.js +0 -531
  148. package/lib/runner/failureTracker.js +0 -72
  149. package/lib/runner/lastRun.js +0 -77
  150. package/lib/runner/loadUtils.js +0 -334
  151. package/lib/runner/loaderHost.js +0 -89
  152. package/lib/runner/processHost.js +0 -180
  153. package/lib/runner/projectUtils.js +0 -241
  154. package/lib/runner/rebase.js +0 -189
  155. package/lib/runner/reporters.js +0 -140
  156. package/lib/runner/sigIntWatcher.js +0 -96
  157. package/lib/runner/storage.js +0 -91
  158. package/lib/runner/taskRunner.js +0 -127
  159. package/lib/runner/tasks.js +0 -410
  160. package/lib/runner/testGroups.js +0 -125
  161. package/lib/runner/testRunner.js +0 -398
  162. package/lib/runner/testServer.js +0 -269
  163. package/lib/runner/uiModeReporter.js +0 -30
  164. package/lib/runner/vcs.js +0 -72
  165. package/lib/runner/watchMode.js +0 -396
  166. package/lib/runner/workerHost.js +0 -104
  167. package/lib/third_party/pirates.js +0 -62
  168. package/lib/third_party/tsconfig-loader.js +0 -103
  169. package/lib/transform/babelBundleImpl.js +0 -461
  170. package/lib/transform/compilationCache.js +0 -274
  171. package/lib/transform/md.js +0 -221
  172. package/lib/transform/portTransport.js +0 -67
  173. package/lib/transform/transform.js +0 -303
  174. package/lib/utilsBundle.js +0 -50
  175. package/lib/utilsBundleImpl.js +0 -103
  176. package/lib/worker/fixtureRunner.js +0 -262
  177. package/lib/worker/testInfo.js +0 -536
  178. package/lib/worker/testTracing.js +0 -345
  179. package/lib/worker/timeoutManager.js +0 -174
  180. package/lib/worker/util.js +0 -31
  181. package/lib/worker/workerMain.js +0 -530
  182. /package/lib/{common/globals.js → globals.js} +0 -0
@@ -1,138 +0,0 @@
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) {
70
- this._addSnippetToTestErrors(test, result);
71
- return await this._reporter.onTestPaused?.(test, result);
72
- }
73
- onTestEnd(test, result) {
74
- this._addSnippetToTestErrors(test, result);
75
- this._reporter.onTestEnd?.(test, result);
76
- }
77
- async onEnd(result) {
78
- if (!this._didBegin) {
79
- this.onBegin(new import_test.Suite("", "root"));
80
- }
81
- return await this._reporter.onEnd?.({
82
- ...result,
83
- startTime: this._startTime,
84
- duration: (0, import_utils.monotonicTime)() - this._monotonicStartTime
85
- });
86
- }
87
- async onExit() {
88
- await this._reporter.onExit?.();
89
- }
90
- onError(error) {
91
- addLocationAndSnippetToError(this._config, error);
92
- this._reporter.onError?.(error);
93
- }
94
- onStepBegin(test, result, step) {
95
- this._reporter.onStepBegin?.(test, result, step);
96
- }
97
- onStepEnd(test, result, step) {
98
- this._addSnippetToStepError(test, step);
99
- this._reporter.onStepEnd?.(test, result, step);
100
- }
101
- printsToStdio() {
102
- return this._reporter.printsToStdio ? this._reporter.printsToStdio() : true;
103
- }
104
- _addSnippetToTestErrors(test, result) {
105
- for (const error of result.errors)
106
- addLocationAndSnippetToError(this._config, error, test.location.file);
107
- }
108
- _addSnippetToStepError(test, step) {
109
- if (step.error)
110
- addLocationAndSnippetToError(this._config, step.error, test.location.file);
111
- }
112
- }
113
- function addLocationAndSnippetToError(config, error, file) {
114
- if (error.stack && !error.location)
115
- error.location = (0, import_base.prepareErrorStack)(error.stack).location;
116
- const location = error.location;
117
- if (!location)
118
- return;
119
- if (!!error.snippet)
120
- return;
121
- try {
122
- const tokens = [];
123
- const source = import_fs.default.readFileSync(location.file, "utf8");
124
- const codeFrame = (0, import_babelBundle.codeFrameColumns)(source, { start: location }, { highlightCode: true });
125
- if (!file || import_fs.default.realpathSync(file) !== location.file) {
126
- tokens.push(import_base.internalScreen.colors.gray(` at `) + `${(0, import_base.relativeFilePath)(import_base.internalScreen, config, location.file)}:${location.line}`);
127
- tokens.push("");
128
- }
129
- tokens.push(codeFrame);
130
- error.snippet = tokens.join("\n");
131
- } catch (e) {
132
- }
133
- }
134
- // Annotate the CommonJS export names for ESM import in node:
135
- 0 && (module.exports = {
136
- InternalReporter,
137
- addLocationAndSnippetToError
138
- });
@@ -1,254 +0,0 @@
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
- status: result.status,
195
- duration: result.duration,
196
- error: result.error,
197
- errors: result.errors.map((e) => this._serializeError(e)),
198
- stdout: result.stdout.map((s) => stdioEntry(s)),
199
- stderr: result.stderr.map((s) => stdioEntry(s)),
200
- retry: result.retry,
201
- steps: steps.length ? steps.map((s) => this._serializeTestStep(s)) : void 0,
202
- startTime: result.startTime.toISOString(),
203
- annotations: result.annotations,
204
- attachments: result.attachments.map((a) => ({
205
- name: a.name,
206
- contentType: a.contentType,
207
- path: a.path,
208
- body: a.body?.toString("base64")
209
- }))
210
- };
211
- if (result.error?.stack)
212
- jsonResult.errorLocation = (0, import_base.prepareErrorStack)(result.error.stack).location;
213
- return jsonResult;
214
- }
215
- _serializeError(error) {
216
- return (0, import_base.formatError)(import_base.nonTerminalScreen, error);
217
- }
218
- _serializeTestStep(step) {
219
- const steps = step.steps.filter((s) => s.category === "test.step");
220
- return {
221
- title: step.title,
222
- duration: step.duration,
223
- error: step.error,
224
- steps: steps.length ? steps.map((s) => this._serializeTestStep(s)) : void 0
225
- };
226
- }
227
- }
228
- async function outputReport(report, resolvedOutputFile) {
229
- const reportString = JSON.stringify(report, void 0, 2);
230
- if (resolvedOutputFile) {
231
- await import_fs.default.promises.mkdir(import_path.default.dirname(resolvedOutputFile), { recursive: true });
232
- await import_fs.default.promises.writeFile(resolvedOutputFile, reportString);
233
- } else {
234
- console.log(reportString);
235
- }
236
- }
237
- function stdioEntry(s) {
238
- if (typeof s === "string")
239
- return { text: s };
240
- return { buffer: s.toString("base64") };
241
- }
242
- function removePrivateFields(config) {
243
- return Object.fromEntries(Object.entries(config).filter(([name, value]) => !name.startsWith("_")));
244
- }
245
- function serializePatterns(patterns) {
246
- if (!Array.isArray(patterns))
247
- patterns = [patterns];
248
- return patterns.map((s) => s.toString());
249
- }
250
- var json_default = JSONReporter;
251
- // Annotate the CommonJS export names for ESM import in node:
252
- 0 && (module.exports = {
253
- serializePatterns
254
- });
@@ -1,232 +0,0 @@
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, "]]&gt;") + "]]>";
225
- } else {
226
- const escapeRe = /[&"'<>]/g;
227
- text = text.replace(escapeRe, (c) => ({ "&": "&amp;", '"': "&quot;", "'": "&apos;", "<": "&lt;", ">": "&gt;" })[c]);
228
- }
229
- text = text.replace(discouragedXMLCharacters, "");
230
- return text;
231
- }
232
- var junit_default = JUnitReporter;