@ohos-ports/playwright 1.52.0-beta.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.
Files changed (110) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +168 -0
  4. package/ThirdPartyNotices.txt +4011 -0
  5. package/cli.js +19 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/jsx-runtime.js +42 -0
  10. package/jsx-runtime.mjs +21 -0
  11. package/lib/common/config.js +272 -0
  12. package/lib/common/configLoader.js +373 -0
  13. package/lib/common/esmLoaderHost.js +100 -0
  14. package/lib/common/expectBundle.js +49 -0
  15. package/lib/common/expectBundleImpl.js +389 -0
  16. package/lib/common/fixtures.js +302 -0
  17. package/lib/common/globals.js +58 -0
  18. package/lib/common/ipc.js +60 -0
  19. package/lib/common/poolBuilder.js +85 -0
  20. package/lib/common/process.js +109 -0
  21. package/lib/common/suiteUtils.js +149 -0
  22. package/lib/common/test.js +313 -0
  23. package/lib/common/testLoader.js +100 -0
  24. package/lib/common/testType.js +306 -0
  25. package/lib/errorContext.js +149 -0
  26. package/lib/fsWatcher.js +67 -0
  27. package/lib/index.js +692 -0
  28. package/lib/internalsForTest.js +42 -0
  29. package/lib/isomorphic/events.js +77 -0
  30. package/lib/isomorphic/folders.js +30 -0
  31. package/lib/isomorphic/stringInternPool.js +69 -0
  32. package/lib/isomorphic/teleReceiver.js +484 -0
  33. package/lib/isomorphic/teleSuiteUpdater.js +137 -0
  34. package/lib/isomorphic/testServerConnection.js +211 -0
  35. package/lib/isomorphic/testServerInterface.js +16 -0
  36. package/lib/isomorphic/testTree.js +307 -0
  37. package/lib/isomorphic/types.d.js +16 -0
  38. package/lib/isomorphic/util.js +28 -0
  39. package/lib/loader/loaderMain.js +59 -0
  40. package/lib/matchers/expect.js +322 -0
  41. package/lib/matchers/matcherHint.js +59 -0
  42. package/lib/matchers/matchers.js +362 -0
  43. package/lib/matchers/toBeTruthy.js +71 -0
  44. package/lib/matchers/toEqual.js +94 -0
  45. package/lib/matchers/toHaveURL.js +117 -0
  46. package/lib/matchers/toMatchAriaSnapshot.js +180 -0
  47. package/lib/matchers/toMatchSnapshot.js +365 -0
  48. package/lib/matchers/toMatchText.js +105 -0
  49. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  50. package/lib/plugins/index.js +28 -0
  51. package/lib/plugins/webServerPlugin.js +207 -0
  52. package/lib/program.js +407 -0
  53. package/lib/reporters/base.js +540 -0
  54. package/lib/reporters/blob.js +135 -0
  55. package/lib/reporters/dot.js +82 -0
  56. package/lib/reporters/empty.js +32 -0
  57. package/lib/reporters/github.js +127 -0
  58. package/lib/reporters/html.js +579 -0
  59. package/lib/reporters/internalReporter.js +129 -0
  60. package/lib/reporters/json.js +254 -0
  61. package/lib/reporters/junit.js +230 -0
  62. package/lib/reporters/line.js +113 -0
  63. package/lib/reporters/list.js +228 -0
  64. package/lib/reporters/merge.js +511 -0
  65. package/lib/reporters/multiplexer.js +104 -0
  66. package/lib/reporters/reporterV2.js +102 -0
  67. package/lib/reporters/teleEmitter.js +269 -0
  68. package/lib/reporters/versions/blobV1.js +16 -0
  69. package/lib/runner/dispatcher.js +484 -0
  70. package/lib/runner/failureTracker.js +62 -0
  71. package/lib/runner/lastRun.js +74 -0
  72. package/lib/runner/loadUtils.js +299 -0
  73. package/lib/runner/loaderHost.js +89 -0
  74. package/lib/runner/processHost.js +165 -0
  75. package/lib/runner/projectUtils.js +235 -0
  76. package/lib/runner/rebase.js +189 -0
  77. package/lib/runner/reporters.js +162 -0
  78. package/lib/runner/runner.js +110 -0
  79. package/lib/runner/sigIntWatcher.js +96 -0
  80. package/lib/runner/taskRunner.js +127 -0
  81. package/lib/runner/tasks.js +400 -0
  82. package/lib/runner/testGroups.js +117 -0
  83. package/lib/runner/testServer.js +477 -0
  84. package/lib/runner/uiModeReporter.js +30 -0
  85. package/lib/runner/vcs.js +72 -0
  86. package/lib/runner/watchMode.js +394 -0
  87. package/lib/runner/workerHost.js +93 -0
  88. package/lib/third_party/tsconfig-loader.js +103 -0
  89. package/lib/transform/babelBundle.js +43 -0
  90. package/lib/transform/babelBundleImpl.js +477 -0
  91. package/lib/transform/compilationCache.js +255 -0
  92. package/lib/transform/esmLoader.js +104 -0
  93. package/lib/transform/esmUtils.js +53 -0
  94. package/lib/transform/portTransport.js +66 -0
  95. package/lib/transform/transform.js +291 -0
  96. package/lib/util.js +407 -0
  97. package/lib/utilsBundle.js +46 -0
  98. package/lib/utilsBundleImpl.js +102 -0
  99. package/lib/worker/fixtureRunner.js +253 -0
  100. package/lib/worker/testInfo.js +422 -0
  101. package/lib/worker/testTracing.js +351 -0
  102. package/lib/worker/timeoutManager.js +174 -0
  103. package/lib/worker/util.js +31 -0
  104. package/lib/worker/workerMain.js +511 -0
  105. package/package.json +64 -0
  106. package/test.d.ts +18 -0
  107. package/test.js +24 -0
  108. package/test.mjs +33 -0
  109. package/types/test.d.ts +10061 -0
  110. package/types/testReporter.d.ts +799 -0
@@ -0,0 +1,113 @@
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 line_exports = {};
20
+ __export(line_exports, {
21
+ default: () => line_default
22
+ });
23
+ module.exports = __toCommonJS(line_exports);
24
+ var import_base = require("./base");
25
+ class LineReporter extends import_base.TerminalReporter {
26
+ constructor() {
27
+ super(...arguments);
28
+ this._current = 0;
29
+ this._failures = 0;
30
+ this._didBegin = false;
31
+ }
32
+ onBegin(suite) {
33
+ super.onBegin(suite);
34
+ const startingMessage = this.generateStartingMessage();
35
+ if (startingMessage) {
36
+ console.log(startingMessage);
37
+ console.log();
38
+ }
39
+ this._didBegin = true;
40
+ }
41
+ onStdOut(chunk, test, result) {
42
+ super.onStdOut(chunk, test, result);
43
+ this._dumpToStdio(test, chunk, process.stdout);
44
+ }
45
+ onStdErr(chunk, test, result) {
46
+ super.onStdErr(chunk, test, result);
47
+ this._dumpToStdio(test, chunk, process.stderr);
48
+ }
49
+ _dumpToStdio(test, chunk, stream) {
50
+ if (this.config.quiet)
51
+ return;
52
+ if (!process.env.PW_TEST_DEBUG_REPORTERS)
53
+ stream.write(`\x1B[1A\x1B[2K`);
54
+ if (test && this._lastTest !== test) {
55
+ const title = this.screen.colors.dim(this.formatTestTitle(test));
56
+ stream.write(this.fitToScreen(title) + `
57
+ `);
58
+ this._lastTest = test;
59
+ }
60
+ stream.write(chunk);
61
+ if (chunk[chunk.length - 1] !== "\n")
62
+ console.log();
63
+ console.log();
64
+ }
65
+ onTestBegin(test, result) {
66
+ ++this._current;
67
+ this._updateLine(test, result, void 0);
68
+ }
69
+ onStepBegin(test, result, step) {
70
+ if (this.screen.isTTY && step.category === "test.step")
71
+ this._updateLine(test, result, step);
72
+ }
73
+ onStepEnd(test, result, step) {
74
+ if (this.screen.isTTY && step.category === "test.step")
75
+ this._updateLine(test, result, step.parent);
76
+ }
77
+ onTestEnd(test, result) {
78
+ super.onTestEnd(test, result);
79
+ if (!this.willRetry(test) && (test.outcome() === "flaky" || test.outcome() === "unexpected" || result.status === "interrupted")) {
80
+ if (!process.env.PW_TEST_DEBUG_REPORTERS)
81
+ process.stdout.write(`\x1B[1A\x1B[2K`);
82
+ console.log(this.formatFailure(test, ++this._failures));
83
+ console.log();
84
+ }
85
+ }
86
+ _updateLine(test, result, step) {
87
+ const retriesPrefix = this.totalTestCount < this._current ? ` (retries)` : ``;
88
+ const prefix = `[${this._current}/${this.totalTestCount}]${retriesPrefix} `;
89
+ const currentRetrySuffix = result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : "";
90
+ const title = this.formatTestTitle(test, step) + currentRetrySuffix;
91
+ if (process.env.PW_TEST_DEBUG_REPORTERS)
92
+ process.stdout.write(`${prefix + title}
93
+ `);
94
+ else
95
+ process.stdout.write(`\x1B[1A\x1B[2K${prefix + this.fitToScreen(title, prefix)}
96
+ `);
97
+ }
98
+ onError(error) {
99
+ super.onError(error);
100
+ const message = this.formatError(error).message + "\n";
101
+ if (!process.env.PW_TEST_DEBUG_REPORTERS && this._didBegin)
102
+ process.stdout.write(`\x1B[1A\x1B[2K`);
103
+ process.stdout.write(message);
104
+ console.log();
105
+ }
106
+ async onEnd(result) {
107
+ if (!process.env.PW_TEST_DEBUG_REPORTERS && this._didBegin)
108
+ process.stdout.write(`\x1B[1A\x1B[2K`);
109
+ await super.onEnd(result);
110
+ this.epilogue(false);
111
+ }
112
+ }
113
+ var line_default = LineReporter;
@@ -0,0 +1,228 @@
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 list_exports = {};
20
+ __export(list_exports, {
21
+ default: () => list_default
22
+ });
23
+ module.exports = __toCommonJS(list_exports);
24
+ var import_utils = require("@ohos-ports/playwright-core/lib/utils");
25
+ var import_utilsBundle = require("@ohos-ports/playwright-core/lib/utilsBundle");
26
+ var import_base = require("./base");
27
+ var import_util = require("../util");
28
+ const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === "win32" && process.env.TERM_PROGRAM !== "vscode" && !process.env.WT_SESSION;
29
+ const POSITIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? "ok" : "\u2713";
30
+ const NEGATIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? "x" : "\u2718";
31
+ class ListReporter extends import_base.TerminalReporter {
32
+ constructor(options = {}) {
33
+ super();
34
+ this._lastRow = 0;
35
+ this._lastColumn = 0;
36
+ this._testRows = /* @__PURE__ */ new Map();
37
+ this._stepRows = /* @__PURE__ */ new Map();
38
+ this._resultIndex = /* @__PURE__ */ new Map();
39
+ this._stepIndex = /* @__PURE__ */ new Map();
40
+ this._needNewLine = false;
41
+ this._printSteps = (0, import_utils.getAsBooleanFromENV)("PLAYWRIGHT_LIST_PRINT_STEPS", options.printSteps);
42
+ }
43
+ onBegin(suite) {
44
+ super.onBegin(suite);
45
+ const startingMessage = this.generateStartingMessage();
46
+ if (startingMessage) {
47
+ console.log(startingMessage);
48
+ console.log();
49
+ }
50
+ }
51
+ onTestBegin(test, result) {
52
+ const index = String(this._resultIndex.size + 1);
53
+ this._resultIndex.set(result, index);
54
+ if (!this.screen.isTTY)
55
+ return;
56
+ this._maybeWriteNewLine();
57
+ this._testRows.set(test, this._lastRow);
58
+ const prefix = this._testPrefix(index, "");
59
+ const line = this.screen.colors.dim(this.formatTestTitle(test)) + this._retrySuffix(result);
60
+ this._appendLine(line, prefix);
61
+ }
62
+ onStdOut(chunk, test, result) {
63
+ super.onStdOut(chunk, test, result);
64
+ this._dumpToStdio(test, chunk, process.stdout);
65
+ }
66
+ onStdErr(chunk, test, result) {
67
+ super.onStdErr(chunk, test, result);
68
+ this._dumpToStdio(test, chunk, process.stderr);
69
+ }
70
+ getStepIndex(testIndex, result, step) {
71
+ if (this._stepIndex.has(step))
72
+ return this._stepIndex.get(step);
73
+ const ordinal = (result[lastStepOrdinalSymbol] || 0) + 1;
74
+ result[lastStepOrdinalSymbol] = ordinal;
75
+ const stepIndex = `${testIndex}.${ordinal}`;
76
+ this._stepIndex.set(step, stepIndex);
77
+ return stepIndex;
78
+ }
79
+ onStepBegin(test, result, step) {
80
+ if (step.category !== "test.step")
81
+ return;
82
+ const testIndex = this._resultIndex.get(result) || "";
83
+ if (!this.screen.isTTY)
84
+ return;
85
+ if (this._printSteps) {
86
+ this._maybeWriteNewLine();
87
+ this._stepRows.set(step, this._lastRow);
88
+ const prefix = this._testPrefix(this.getStepIndex(testIndex, result, step), "");
89
+ const line = test.title + this.screen.colors.dim((0, import_base.stepSuffix)(step));
90
+ this._appendLine(line, prefix);
91
+ } else {
92
+ this._updateLine(this._testRows.get(test), this.screen.colors.dim(this.formatTestTitle(test, step)) + this._retrySuffix(result), this._testPrefix(testIndex, ""));
93
+ }
94
+ }
95
+ onStepEnd(test, result, step) {
96
+ if (step.category !== "test.step")
97
+ return;
98
+ const testIndex = this._resultIndex.get(result) || "";
99
+ if (!this._printSteps) {
100
+ if (this.screen.isTTY)
101
+ this._updateLine(this._testRows.get(test), this.screen.colors.dim(this.formatTestTitle(test, step.parent)) + this._retrySuffix(result), this._testPrefix(testIndex, ""));
102
+ return;
103
+ }
104
+ const index = this.getStepIndex(testIndex, result, step);
105
+ const title = this.screen.isTTY ? test.title + this.screen.colors.dim((0, import_base.stepSuffix)(step)) : this.formatTestTitle(test, step);
106
+ const prefix = this._testPrefix(index, "");
107
+ let text = "";
108
+ if (step.error)
109
+ text = this.screen.colors.red(title);
110
+ else
111
+ text = title;
112
+ text += this.screen.colors.dim(` (${(0, import_utilsBundle.ms)(step.duration)})`);
113
+ this._updateOrAppendLine(this._stepRows.get(step), text, prefix);
114
+ }
115
+ _maybeWriteNewLine() {
116
+ if (this._needNewLine) {
117
+ this._needNewLine = false;
118
+ process.stdout.write("\n");
119
+ ++this._lastRow;
120
+ this._lastColumn = 0;
121
+ }
122
+ }
123
+ _updateLineCountAndNewLineFlagForOutput(text) {
124
+ this._needNewLine = text[text.length - 1] !== "\n";
125
+ if (!this.screen.ttyWidth)
126
+ return;
127
+ for (const ch of text) {
128
+ if (ch === "\n") {
129
+ this._lastColumn = 0;
130
+ ++this._lastRow;
131
+ continue;
132
+ }
133
+ ++this._lastColumn;
134
+ if (this._lastColumn > this.screen.ttyWidth) {
135
+ this._lastColumn = 0;
136
+ ++this._lastRow;
137
+ }
138
+ }
139
+ }
140
+ _dumpToStdio(test, chunk, stream) {
141
+ if (this.config.quiet)
142
+ return;
143
+ const text = chunk.toString("utf-8");
144
+ this._updateLineCountAndNewLineFlagForOutput(text);
145
+ stream.write(chunk);
146
+ }
147
+ onTestEnd(test, result) {
148
+ super.onTestEnd(test, result);
149
+ const title = this.formatTestTitle(test);
150
+ let prefix = "";
151
+ let text = "";
152
+ let index = this._resultIndex.get(result);
153
+ if (!index) {
154
+ index = String(this._resultIndex.size + 1);
155
+ this._resultIndex.set(result, index);
156
+ }
157
+ if (result.status === "skipped") {
158
+ prefix = this._testPrefix(index, this.screen.colors.green("-"));
159
+ text = this.screen.colors.cyan(title) + this._retrySuffix(result);
160
+ } else {
161
+ const statusMark = result.status === "passed" ? POSITIVE_STATUS_MARK : NEGATIVE_STATUS_MARK;
162
+ if (result.status === test.expectedStatus) {
163
+ prefix = this._testPrefix(index, this.screen.colors.green(statusMark));
164
+ text = title;
165
+ } else {
166
+ prefix = this._testPrefix(index, this.screen.colors.red(statusMark));
167
+ text = this.screen.colors.red(title);
168
+ }
169
+ text += this._retrySuffix(result) + this.screen.colors.dim(` (${(0, import_utilsBundle.ms)(result.duration)})`);
170
+ }
171
+ this._updateOrAppendLine(this._testRows.get(test), text, prefix);
172
+ }
173
+ _updateOrAppendLine(row, text, prefix) {
174
+ if (this.screen.isTTY) {
175
+ this._updateLine(row, text, prefix);
176
+ } else {
177
+ this._maybeWriteNewLine();
178
+ this._appendLine(text, prefix);
179
+ }
180
+ }
181
+ _appendLine(text, prefix) {
182
+ const line = prefix + this.fitToScreen(text, prefix);
183
+ if (process.env.PW_TEST_DEBUG_REPORTERS) {
184
+ process.stdout.write("#" + this._lastRow + " : " + line + "\n");
185
+ } else {
186
+ process.stdout.write(line);
187
+ process.stdout.write("\n");
188
+ }
189
+ ++this._lastRow;
190
+ this._lastColumn = 0;
191
+ }
192
+ _updateLine(row, text, prefix) {
193
+ const line = prefix + this.fitToScreen(text, prefix);
194
+ if (process.env.PW_TEST_DEBUG_REPORTERS)
195
+ process.stdout.write("#" + row + " : " + line + "\n");
196
+ else
197
+ this._updateLineForTTY(row, line);
198
+ }
199
+ _updateLineForTTY(row, line) {
200
+ if (row !== this._lastRow)
201
+ process.stdout.write(`\x1B[${this._lastRow - row}A`);
202
+ process.stdout.write("\x1B[2K\x1B[0G");
203
+ process.stdout.write(line);
204
+ if (row !== this._lastRow)
205
+ process.stdout.write(`\x1B[${this._lastRow - row}E`);
206
+ }
207
+ _testPrefix(index, statusMark) {
208
+ const statusMarkLength = (0, import_util.stripAnsiEscapes)(statusMark).length;
209
+ return " " + statusMark + " ".repeat(3 - statusMarkLength) + this.screen.colors.dim(index + " ");
210
+ }
211
+ _retrySuffix(result) {
212
+ return result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : "";
213
+ }
214
+ onError(error) {
215
+ super.onError(error);
216
+ this._maybeWriteNewLine();
217
+ const message = this.formatError(error).message + "\n";
218
+ this._updateLineCountAndNewLineFlagForOutput(message);
219
+ process.stdout.write(message);
220
+ }
221
+ async onEnd(result) {
222
+ await super.onEnd(result);
223
+ process.stdout.write("\n");
224
+ this.epilogue(true);
225
+ }
226
+ }
227
+ const lastStepOrdinalSymbol = Symbol("lastStepOrdinal");
228
+ var list_default = ListReporter;