@pedropaulovc/playwright 1.59.0-next
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThirdPartyNotices.txt +5042 -0
- package/cli.js +19 -0
- package/index.d.ts +17 -0
- package/index.js +17 -0
- package/index.mjs +18 -0
- package/jsx-runtime.js +42 -0
- package/jsx-runtime.mjs +21 -0
- package/lib/agents/agentParser.js +89 -0
- package/lib/agents/copilot-setup-steps.yml +34 -0
- package/lib/agents/generateAgents.js +348 -0
- package/lib/agents/playwright-test-coverage.prompt.md +31 -0
- package/lib/agents/playwright-test-generate.prompt.md +8 -0
- package/lib/agents/playwright-test-generator.agent.md +88 -0
- package/lib/agents/playwright-test-heal.prompt.md +6 -0
- package/lib/agents/playwright-test-healer.agent.md +55 -0
- package/lib/agents/playwright-test-plan.prompt.md +9 -0
- package/lib/agents/playwright-test-planner.agent.md +73 -0
- package/lib/common/config.js +282 -0
- package/lib/common/configLoader.js +344 -0
- package/lib/common/esmLoaderHost.js +104 -0
- package/lib/common/expectBundle.js +28 -0
- package/lib/common/expectBundleImpl.js +407 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/process.js +132 -0
- package/lib/common/suiteUtils.js +140 -0
- package/lib/common/test.js +321 -0
- package/lib/common/testLoader.js +101 -0
- package/lib/common/testType.js +298 -0
- package/lib/common/validators.js +68 -0
- package/lib/fsWatcher.js +67 -0
- package/lib/index.js +726 -0
- package/lib/internalsForTest.js +42 -0
- package/lib/isomorphic/events.js +77 -0
- package/lib/isomorphic/folders.js +30 -0
- package/lib/isomorphic/stringInternPool.js +69 -0
- package/lib/isomorphic/teleReceiver.js +521 -0
- package/lib/isomorphic/teleSuiteUpdater.js +157 -0
- package/lib/isomorphic/testServerConnection.js +225 -0
- package/lib/isomorphic/testServerInterface.js +16 -0
- package/lib/isomorphic/testTree.js +329 -0
- package/lib/isomorphic/types.d.js +16 -0
- package/lib/loader/loaderMain.js +59 -0
- package/lib/matchers/expect.js +311 -0
- package/lib/matchers/matcherHint.js +44 -0
- package/lib/matchers/matchers.js +383 -0
- package/lib/matchers/toBeTruthy.js +75 -0
- package/lib/matchers/toEqual.js +100 -0
- package/lib/matchers/toHaveURL.js +101 -0
- package/lib/matchers/toMatchAriaSnapshot.js +159 -0
- package/lib/matchers/toMatchSnapshot.js +342 -0
- package/lib/matchers/toMatchText.js +99 -0
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/browserContextFactory.js +329 -0
- package/lib/mcp/browser/browserServerBackend.js +84 -0
- package/lib/mcp/browser/config.js +421 -0
- package/lib/mcp/browser/context.js +244 -0
- package/lib/mcp/browser/response.js +278 -0
- package/lib/mcp/browser/sessionLog.js +75 -0
- package/lib/mcp/browser/tab.js +351 -0
- package/lib/mcp/browser/tools/common.js +65 -0
- package/lib/mcp/browser/tools/console.js +61 -0
- package/lib/mcp/browser/tools/dialogs.js +60 -0
- package/lib/mcp/browser/tools/evaluate.js +61 -0
- package/lib/mcp/browser/tools/files.js +58 -0
- package/lib/mcp/browser/tools/form.js +63 -0
- package/lib/mcp/browser/tools/install.js +72 -0
- package/lib/mcp/browser/tools/keyboard.js +144 -0
- package/lib/mcp/browser/tools/mouse.js +159 -0
- package/lib/mcp/browser/tools/navigate.js +136 -0
- package/lib/mcp/browser/tools/navigateAndWait.js +66 -0
- package/lib/mcp/browser/tools/network.js +78 -0
- package/lib/mcp/browser/tools/pdf.js +49 -0
- package/lib/mcp/browser/tools/runCode.js +78 -0
- package/lib/mcp/browser/tools/screenshot.js +93 -0
- package/lib/mcp/browser/tools/snapshot.js +205 -0
- package/lib/mcp/browser/tools/snapshotViewport.js +63 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +47 -0
- package/lib/mcp/browser/tools/tracing.js +74 -0
- package/lib/mcp/browser/tools/utils.js +94 -0
- package/lib/mcp/browser/tools/verify.js +143 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools.js +82 -0
- package/lib/mcp/browser/watchdog.js +44 -0
- package/lib/mcp/config.d.js +16 -0
- package/lib/mcp/extension/cdpRelay.js +351 -0
- package/lib/mcp/extension/extensionContextFactory.js +76 -0
- package/lib/mcp/extension/protocol.js +28 -0
- package/lib/mcp/index.js +61 -0
- package/lib/mcp/log.js +35 -0
- package/lib/mcp/program.js +110 -0
- package/lib/mcp/sdk/exports.js +28 -0
- package/lib/mcp/sdk/http.js +152 -0
- package/lib/mcp/sdk/inProcessTransport.js +71 -0
- package/lib/mcp/sdk/server.js +223 -0
- package/lib/mcp/sdk/tool.js +47 -0
- package/lib/mcp/terminal/cli.js +296 -0
- package/lib/mcp/terminal/command.js +56 -0
- package/lib/mcp/terminal/commands.js +519 -0
- package/lib/mcp/terminal/daemon.js +135 -0
- package/lib/mcp/terminal/help.json +47 -0
- package/lib/mcp/terminal/helpGenerator.js +115 -0
- package/lib/mcp/terminal/socketConnection.js +80 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/plannerTools.js +145 -0
- package/lib/mcp/test/seed.js +82 -0
- package/lib/mcp/test/streams.js +44 -0
- package/lib/mcp/test/testBackend.js +99 -0
- package/lib/mcp/test/testContext.js +285 -0
- package/lib/mcp/test/testTool.js +30 -0
- package/lib/mcp/test/testTools.js +108 -0
- package/lib/plugins/gitCommitInfoPlugin.js +198 -0
- package/lib/plugins/index.js +28 -0
- package/lib/plugins/webServerPlugin.js +237 -0
- package/lib/program.js +417 -0
- package/lib/reporters/base.js +634 -0
- package/lib/reporters/blob.js +138 -0
- package/lib/reporters/dot.js +99 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/github.js +128 -0
- package/lib/reporters/html.js +633 -0
- package/lib/reporters/internalReporter.js +138 -0
- package/lib/reporters/json.js +254 -0
- package/lib/reporters/junit.js +232 -0
- package/lib/reporters/line.js +131 -0
- package/lib/reporters/list.js +253 -0
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/markdown.js +144 -0
- package/lib/reporters/merge.js +558 -0
- package/lib/reporters/multiplexer.js +112 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/teleEmitter.js +317 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/runner/dispatcher.js +530 -0
- package/lib/runner/failureTracker.js +72 -0
- package/lib/runner/lastRun.js +77 -0
- package/lib/runner/loadUtils.js +334 -0
- package/lib/runner/loaderHost.js +89 -0
- package/lib/runner/processHost.js +180 -0
- package/lib/runner/projectUtils.js +241 -0
- package/lib/runner/rebase.js +189 -0
- package/lib/runner/reporters.js +138 -0
- package/lib/runner/sigIntWatcher.js +96 -0
- package/lib/runner/storage.js +91 -0
- package/lib/runner/taskRunner.js +127 -0
- package/lib/runner/tasks.js +410 -0
- package/lib/runner/testGroups.js +125 -0
- package/lib/runner/testRunner.js +398 -0
- package/lib/runner/testServer.js +269 -0
- package/lib/runner/uiModeReporter.js +30 -0
- package/lib/runner/vcs.js +72 -0
- package/lib/runner/watchMode.js +396 -0
- package/lib/runner/workerHost.js +104 -0
- package/lib/third_party/pirates.js +62 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/transform/babelBundle.js +46 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/compilationCache.js +274 -0
- package/lib/transform/esmLoader.js +103 -0
- package/lib/transform/md.js +221 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/transform.js +303 -0
- package/lib/util.js +400 -0
- package/lib/utilsBundle.js +50 -0
- package/lib/utilsBundleImpl.js +103 -0
- package/lib/worker/fixtureRunner.js +262 -0
- package/lib/worker/testInfo.js +536 -0
- package/lib/worker/testTracing.js +345 -0
- package/lib/worker/timeoutManager.js +174 -0
- package/lib/worker/util.js +31 -0
- package/lib/worker/workerMain.js +530 -0
- package/package.json +72 -0
- package/test.d.ts +18 -0
- package/test.js +24 -0
- package/test.mjs +34 -0
- package/types/test.d.ts +10251 -0
- package/types/testReporter.d.ts +822 -0
|
@@ -0,0 +1,530 @@
|
|
|
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 dispatcher_exports = {};
|
|
20
|
+
__export(dispatcher_exports, {
|
|
21
|
+
Dispatcher: () => Dispatcher
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(dispatcher_exports);
|
|
24
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
25
|
+
var import_utils2 = require("playwright-core/lib/utils");
|
|
26
|
+
var import_rebase = require("./rebase");
|
|
27
|
+
var import_workerHost = require("./workerHost");
|
|
28
|
+
var import_ipc = require("../common/ipc");
|
|
29
|
+
var import_internalReporter = require("../reporters/internalReporter");
|
|
30
|
+
var import_util = require("../util");
|
|
31
|
+
var import_storage = require("./storage");
|
|
32
|
+
class Dispatcher {
|
|
33
|
+
constructor(config, reporter, failureTracker) {
|
|
34
|
+
this._workerSlots = [];
|
|
35
|
+
this._queue = [];
|
|
36
|
+
this._workerLimitPerProjectId = /* @__PURE__ */ new Map();
|
|
37
|
+
this._queuedOrRunningHashCount = /* @__PURE__ */ new Map();
|
|
38
|
+
this._finished = new import_utils.ManualPromise();
|
|
39
|
+
this._isStopped = true;
|
|
40
|
+
this._extraEnvByProjectId = /* @__PURE__ */ new Map();
|
|
41
|
+
this._producedEnvByProjectId = /* @__PURE__ */ new Map();
|
|
42
|
+
this._config = config;
|
|
43
|
+
this._reporter = reporter;
|
|
44
|
+
this._failureTracker = failureTracker;
|
|
45
|
+
for (const project of config.projects) {
|
|
46
|
+
if (project.workers)
|
|
47
|
+
this._workerLimitPerProjectId.set(project.id, project.workers);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
_findFirstJobToRun() {
|
|
51
|
+
for (let index = 0; index < this._queue.length; index++) {
|
|
52
|
+
const job = this._queue[index];
|
|
53
|
+
const projectIdWorkerLimit = this._workerLimitPerProjectId.get(job.projectId);
|
|
54
|
+
if (!projectIdWorkerLimit)
|
|
55
|
+
return index;
|
|
56
|
+
const runningWorkersWithSameProjectId = this._workerSlots.filter((w) => w.busy && w.worker && w.worker.projectId() === job.projectId).length;
|
|
57
|
+
if (runningWorkersWithSameProjectId < projectIdWorkerLimit)
|
|
58
|
+
return index;
|
|
59
|
+
}
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
_scheduleJob() {
|
|
63
|
+
if (this._isStopped)
|
|
64
|
+
return;
|
|
65
|
+
const jobIndex = this._findFirstJobToRun();
|
|
66
|
+
if (jobIndex === -1)
|
|
67
|
+
return;
|
|
68
|
+
const job = this._queue[jobIndex];
|
|
69
|
+
let workerIndex = this._workerSlots.findIndex((w) => !w.busy && w.worker && w.worker.hash() === job.workerHash && !w.worker.didSendStop());
|
|
70
|
+
if (workerIndex === -1)
|
|
71
|
+
workerIndex = this._workerSlots.findIndex((w) => !w.busy);
|
|
72
|
+
if (workerIndex === -1) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this._queue.splice(jobIndex, 1);
|
|
76
|
+
const jobDispatcher = new JobDispatcher(job, this._config, this._reporter, this._failureTracker, () => this.stop().catch(() => {
|
|
77
|
+
}));
|
|
78
|
+
this._workerSlots[workerIndex].busy = true;
|
|
79
|
+
this._workerSlots[workerIndex].jobDispatcher = jobDispatcher;
|
|
80
|
+
void this._runJobInWorker(workerIndex, jobDispatcher).then(() => {
|
|
81
|
+
this._workerSlots[workerIndex].jobDispatcher = void 0;
|
|
82
|
+
this._workerSlots[workerIndex].busy = false;
|
|
83
|
+
this._checkFinished();
|
|
84
|
+
this._scheduleJob();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async _runJobInWorker(index, jobDispatcher) {
|
|
88
|
+
const job = jobDispatcher.job;
|
|
89
|
+
if (jobDispatcher.skipWholeJob())
|
|
90
|
+
return;
|
|
91
|
+
let worker = this._workerSlots[index].worker;
|
|
92
|
+
if (worker && (worker.hash() !== job.workerHash || worker.didSendStop())) {
|
|
93
|
+
await worker.stop();
|
|
94
|
+
worker = void 0;
|
|
95
|
+
if (this._isStopped)
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
let startError;
|
|
99
|
+
if (!worker) {
|
|
100
|
+
worker = this._createWorker(job, index, (0, import_ipc.serializeConfig)(this._config, true));
|
|
101
|
+
this._workerSlots[index].worker = worker;
|
|
102
|
+
worker.on("exit", () => this._workerSlots[index].worker = void 0);
|
|
103
|
+
startError = await worker.start();
|
|
104
|
+
if (this._isStopped)
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (startError)
|
|
108
|
+
jobDispatcher.onExit(startError);
|
|
109
|
+
else
|
|
110
|
+
jobDispatcher.runInWorker(worker);
|
|
111
|
+
const result = await jobDispatcher.jobResult;
|
|
112
|
+
this._updateCounterForWorkerHash(job.workerHash, -1);
|
|
113
|
+
if (result.didFail)
|
|
114
|
+
void worker.stop(
|
|
115
|
+
true
|
|
116
|
+
/* didFail */
|
|
117
|
+
);
|
|
118
|
+
else if (this._isWorkerRedundant(worker))
|
|
119
|
+
void worker.stop();
|
|
120
|
+
if (!this._isStopped && result.newJob) {
|
|
121
|
+
this._queue.unshift(result.newJob);
|
|
122
|
+
this._updateCounterForWorkerHash(result.newJob.workerHash, 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_checkFinished() {
|
|
126
|
+
if (this._finished.isDone())
|
|
127
|
+
return;
|
|
128
|
+
if (this._queue.length && !this._isStopped)
|
|
129
|
+
return;
|
|
130
|
+
if (this._workerSlots.some((w) => w.busy))
|
|
131
|
+
return;
|
|
132
|
+
this._finished.resolve();
|
|
133
|
+
}
|
|
134
|
+
_isWorkerRedundant(worker) {
|
|
135
|
+
let workersWithSameHash = 0;
|
|
136
|
+
for (const slot of this._workerSlots) {
|
|
137
|
+
if (slot.worker && !slot.worker.didSendStop() && slot.worker.hash() === worker.hash())
|
|
138
|
+
workersWithSameHash++;
|
|
139
|
+
}
|
|
140
|
+
return workersWithSameHash > this._queuedOrRunningHashCount.get(worker.hash());
|
|
141
|
+
}
|
|
142
|
+
_updateCounterForWorkerHash(hash, delta) {
|
|
143
|
+
this._queuedOrRunningHashCount.set(hash, delta + (this._queuedOrRunningHashCount.get(hash) || 0));
|
|
144
|
+
}
|
|
145
|
+
async run(testGroups, extraEnvByProjectId) {
|
|
146
|
+
this._extraEnvByProjectId = extraEnvByProjectId;
|
|
147
|
+
this._queue = testGroups;
|
|
148
|
+
for (const group of testGroups)
|
|
149
|
+
this._updateCounterForWorkerHash(group.workerHash, 1);
|
|
150
|
+
this._isStopped = false;
|
|
151
|
+
this._workerSlots = [];
|
|
152
|
+
if (this._failureTracker.hasReachedMaxFailures())
|
|
153
|
+
void this.stop();
|
|
154
|
+
for (let i = 0; i < this._config.config.workers; i++)
|
|
155
|
+
this._workerSlots.push({ busy: false });
|
|
156
|
+
for (let i = 0; i < this._workerSlots.length; i++)
|
|
157
|
+
this._scheduleJob();
|
|
158
|
+
this._checkFinished();
|
|
159
|
+
await this._finished;
|
|
160
|
+
}
|
|
161
|
+
_createWorker(testGroup, parallelIndex, loaderData) {
|
|
162
|
+
const projectConfig = this._config.projects.find((p) => p.id === testGroup.projectId);
|
|
163
|
+
const outputDir = projectConfig.project.outputDir;
|
|
164
|
+
const worker = new import_workerHost.WorkerHost(testGroup, {
|
|
165
|
+
parallelIndex,
|
|
166
|
+
config: loaderData,
|
|
167
|
+
extraEnv: this._extraEnvByProjectId.get(testGroup.projectId) || {},
|
|
168
|
+
outputDir,
|
|
169
|
+
pauseOnError: this._failureTracker.pauseOnError(),
|
|
170
|
+
pauseAtEnd: this._failureTracker.pauseAtEnd(projectConfig)
|
|
171
|
+
});
|
|
172
|
+
const handleOutput = (params) => {
|
|
173
|
+
const chunk = chunkFromParams(params);
|
|
174
|
+
if (worker.didFail()) {
|
|
175
|
+
return { chunk };
|
|
176
|
+
}
|
|
177
|
+
const currentlyRunning = this._workerSlots[parallelIndex].jobDispatcher?.currentlyRunning();
|
|
178
|
+
if (!currentlyRunning)
|
|
179
|
+
return { chunk };
|
|
180
|
+
return { chunk, test: currentlyRunning.test, result: currentlyRunning.result };
|
|
181
|
+
};
|
|
182
|
+
worker.on("stdOut", (params) => {
|
|
183
|
+
const { chunk, test, result } = handleOutput(params);
|
|
184
|
+
result?.stdout.push(chunk);
|
|
185
|
+
this._reporter.onStdOut?.(chunk, test, result);
|
|
186
|
+
});
|
|
187
|
+
worker.on("stdErr", (params) => {
|
|
188
|
+
const { chunk, test, result } = handleOutput(params);
|
|
189
|
+
result?.stderr.push(chunk);
|
|
190
|
+
this._reporter.onStdErr?.(chunk, test, result);
|
|
191
|
+
});
|
|
192
|
+
worker.on("teardownErrors", (params) => {
|
|
193
|
+
this._failureTracker.onWorkerError();
|
|
194
|
+
for (const error of params.fatalErrors)
|
|
195
|
+
this._reporter.onError?.(error);
|
|
196
|
+
});
|
|
197
|
+
worker.on("exit", () => {
|
|
198
|
+
const producedEnv = this._producedEnvByProjectId.get(testGroup.projectId) || {};
|
|
199
|
+
this._producedEnvByProjectId.set(testGroup.projectId, { ...producedEnv, ...worker.producedEnv() });
|
|
200
|
+
});
|
|
201
|
+
worker.onRequest("cloneStorage", async (params) => {
|
|
202
|
+
return await import_storage.Storage.clone(params.storageFile, outputDir);
|
|
203
|
+
});
|
|
204
|
+
worker.onRequest("upstreamStorage", async (params) => {
|
|
205
|
+
await import_storage.Storage.upstream(params.storageFile, params.storageOutFile);
|
|
206
|
+
});
|
|
207
|
+
return worker;
|
|
208
|
+
}
|
|
209
|
+
producedEnvByProjectId() {
|
|
210
|
+
return this._producedEnvByProjectId;
|
|
211
|
+
}
|
|
212
|
+
async stop() {
|
|
213
|
+
if (this._isStopped)
|
|
214
|
+
return;
|
|
215
|
+
this._isStopped = true;
|
|
216
|
+
await Promise.all(this._workerSlots.map(({ worker }) => worker?.stop()));
|
|
217
|
+
this._checkFinished();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
class JobDispatcher {
|
|
221
|
+
constructor(job, config, reporter, failureTracker, stopCallback) {
|
|
222
|
+
this.jobResult = new import_utils.ManualPromise();
|
|
223
|
+
this._listeners = [];
|
|
224
|
+
this._failedTests = /* @__PURE__ */ new Set();
|
|
225
|
+
this._failedWithNonRetriableError = /* @__PURE__ */ new Set();
|
|
226
|
+
this._remainingByTestId = /* @__PURE__ */ new Map();
|
|
227
|
+
this._dataByTestId = /* @__PURE__ */ new Map();
|
|
228
|
+
this._parallelIndex = 0;
|
|
229
|
+
this._workerIndex = 0;
|
|
230
|
+
this.job = job;
|
|
231
|
+
this._config = config;
|
|
232
|
+
this._reporter = reporter;
|
|
233
|
+
this._failureTracker = failureTracker;
|
|
234
|
+
this._stopCallback = stopCallback;
|
|
235
|
+
this._remainingByTestId = new Map(this.job.tests.map((e) => [e.id, e]));
|
|
236
|
+
}
|
|
237
|
+
_onTestBegin(params) {
|
|
238
|
+
const test = this._remainingByTestId.get(params.testId);
|
|
239
|
+
if (!test) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const result = test._appendTestResult();
|
|
243
|
+
this._dataByTestId.set(test.id, { test, result, steps: /* @__PURE__ */ new Map() });
|
|
244
|
+
result.parallelIndex = this._parallelIndex;
|
|
245
|
+
result.workerIndex = this._workerIndex;
|
|
246
|
+
result.startTime = new Date(params.startWallTime);
|
|
247
|
+
this._reporter.onTestBegin?.(test, result);
|
|
248
|
+
this._currentlyRunning = { test, result };
|
|
249
|
+
}
|
|
250
|
+
_onTestEnd(params) {
|
|
251
|
+
if (this._failureTracker.hasReachedMaxFailures()) {
|
|
252
|
+
params.status = "interrupted";
|
|
253
|
+
params.errors = [];
|
|
254
|
+
}
|
|
255
|
+
const data = this._dataByTestId.get(params.testId);
|
|
256
|
+
if (!data) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
this._dataByTestId.delete(params.testId);
|
|
260
|
+
this._remainingByTestId.delete(params.testId);
|
|
261
|
+
const { result, test } = data;
|
|
262
|
+
result.duration = params.duration;
|
|
263
|
+
result.errors = params.errors;
|
|
264
|
+
result.error = result.errors[0];
|
|
265
|
+
result.status = params.status;
|
|
266
|
+
result.annotations = params.annotations;
|
|
267
|
+
test.annotations = [...params.annotations];
|
|
268
|
+
test.expectedStatus = params.expectedStatus;
|
|
269
|
+
test.timeout = params.timeout;
|
|
270
|
+
const isFailure = result.status !== "skipped" && result.status !== test.expectedStatus;
|
|
271
|
+
if (isFailure)
|
|
272
|
+
this._failedTests.add(test);
|
|
273
|
+
if (params.hasNonRetriableError)
|
|
274
|
+
this._addNonretriableTestAndSerialModeParents(test);
|
|
275
|
+
this._reportTestEnd(test, result);
|
|
276
|
+
this._currentlyRunning = void 0;
|
|
277
|
+
}
|
|
278
|
+
_addNonretriableTestAndSerialModeParents(test) {
|
|
279
|
+
this._failedWithNonRetriableError.add(test);
|
|
280
|
+
for (let parent = test.parent; parent; parent = parent.parent) {
|
|
281
|
+
if (parent._parallelMode === "serial")
|
|
282
|
+
this._failedWithNonRetriableError.add(parent);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
_onStepBegin(params) {
|
|
286
|
+
const data = this._dataByTestId.get(params.testId);
|
|
287
|
+
if (!data) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const { result, steps, test } = data;
|
|
291
|
+
const parentStep = params.parentStepId ? steps.get(params.parentStepId) : void 0;
|
|
292
|
+
const step = {
|
|
293
|
+
title: params.title,
|
|
294
|
+
titlePath: () => {
|
|
295
|
+
const parentPath = parentStep?.titlePath() || [];
|
|
296
|
+
return [...parentPath, params.title];
|
|
297
|
+
},
|
|
298
|
+
parent: parentStep,
|
|
299
|
+
category: params.category,
|
|
300
|
+
startTime: new Date(params.wallTime),
|
|
301
|
+
duration: -1,
|
|
302
|
+
steps: [],
|
|
303
|
+
attachments: [],
|
|
304
|
+
annotations: [],
|
|
305
|
+
location: params.location
|
|
306
|
+
};
|
|
307
|
+
steps.set(params.stepId, step);
|
|
308
|
+
(parentStep || result).steps.push(step);
|
|
309
|
+
this._reporter.onStepBegin?.(test, result, step);
|
|
310
|
+
}
|
|
311
|
+
_onStepEnd(params) {
|
|
312
|
+
const data = this._dataByTestId.get(params.testId);
|
|
313
|
+
if (!data) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const { result, steps, test } = data;
|
|
317
|
+
const step = steps.get(params.stepId);
|
|
318
|
+
if (!step) {
|
|
319
|
+
this._reporter.onStdErr?.("Internal error: step end without step begin: " + params.stepId, test, result);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
step.duration = params.wallTime - step.startTime.getTime();
|
|
323
|
+
if (params.error)
|
|
324
|
+
step.error = params.error;
|
|
325
|
+
if (params.suggestedRebaseline)
|
|
326
|
+
(0, import_rebase.addSuggestedRebaseline)(step.location, params.suggestedRebaseline);
|
|
327
|
+
step.annotations = params.annotations;
|
|
328
|
+
steps.delete(params.stepId);
|
|
329
|
+
this._reporter.onStepEnd?.(test, result, step);
|
|
330
|
+
}
|
|
331
|
+
_onAttach(params) {
|
|
332
|
+
const data = this._dataByTestId.get(params.testId);
|
|
333
|
+
if (!data) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const attachment = {
|
|
337
|
+
name: params.name,
|
|
338
|
+
path: params.path,
|
|
339
|
+
contentType: params.contentType,
|
|
340
|
+
body: params.body !== void 0 ? Buffer.from(params.body, "base64") : void 0
|
|
341
|
+
};
|
|
342
|
+
data.result.attachments.push(attachment);
|
|
343
|
+
if (params.stepId) {
|
|
344
|
+
const step = data.steps.get(params.stepId);
|
|
345
|
+
if (step)
|
|
346
|
+
step.attachments.push(attachment);
|
|
347
|
+
else
|
|
348
|
+
this._reporter.onStdErr?.("Internal error: step id not found: " + params.stepId);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
_failTestWithErrors(test, errors) {
|
|
352
|
+
const runData = this._dataByTestId.get(test.id);
|
|
353
|
+
let result;
|
|
354
|
+
if (runData) {
|
|
355
|
+
result = runData.result;
|
|
356
|
+
} else {
|
|
357
|
+
result = test._appendTestResult();
|
|
358
|
+
this._reporter.onTestBegin?.(test, result);
|
|
359
|
+
}
|
|
360
|
+
result.errors = [...errors];
|
|
361
|
+
result.error = result.errors[0];
|
|
362
|
+
result.status = errors.length ? "failed" : "skipped";
|
|
363
|
+
this._reportTestEnd(test, result);
|
|
364
|
+
this._failedTests.add(test);
|
|
365
|
+
}
|
|
366
|
+
_massSkipTestsFromRemaining(testIds, errors) {
|
|
367
|
+
for (const test of this._remainingByTestId.values()) {
|
|
368
|
+
if (!testIds.has(test.id))
|
|
369
|
+
continue;
|
|
370
|
+
if (!this._failureTracker.hasReachedMaxFailures()) {
|
|
371
|
+
this._failTestWithErrors(test, errors);
|
|
372
|
+
errors = [];
|
|
373
|
+
}
|
|
374
|
+
this._remainingByTestId.delete(test.id);
|
|
375
|
+
}
|
|
376
|
+
if (errors.length) {
|
|
377
|
+
this._failureTracker.onWorkerError();
|
|
378
|
+
for (const error of errors)
|
|
379
|
+
this._reporter.onError?.(error);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
_onDone(params) {
|
|
383
|
+
if (!this._remainingByTestId.size && !this._failedTests.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError && !params.stoppedDueToUnhandledErrorInTestFail) {
|
|
384
|
+
this._finished({ didFail: false });
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
for (const testId of params.fatalUnknownTestIds || []) {
|
|
388
|
+
const test = this._remainingByTestId.get(testId);
|
|
389
|
+
if (test) {
|
|
390
|
+
this._remainingByTestId.delete(testId);
|
|
391
|
+
this._failTestWithErrors(test, [{ message: `Test not found in the worker process. Make sure test title does not change.` }]);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (params.fatalErrors.length) {
|
|
395
|
+
this._massSkipTestsFromRemaining(new Set(this._remainingByTestId.keys()), params.fatalErrors);
|
|
396
|
+
}
|
|
397
|
+
this._massSkipTestsFromRemaining(new Set(params.skipTestsDueToSetupFailure), []);
|
|
398
|
+
if (params.unexpectedExitError) {
|
|
399
|
+
if (this._currentlyRunning)
|
|
400
|
+
this._massSkipTestsFromRemaining(/* @__PURE__ */ new Set([this._currentlyRunning.test.id]), [params.unexpectedExitError]);
|
|
401
|
+
else
|
|
402
|
+
this._massSkipTestsFromRemaining(new Set(this._remainingByTestId.keys()), [params.unexpectedExitError]);
|
|
403
|
+
}
|
|
404
|
+
const retryCandidates = /* @__PURE__ */ new Set();
|
|
405
|
+
const serialSuitesWithFailures = /* @__PURE__ */ new Set();
|
|
406
|
+
for (const failedTest of this._failedTests) {
|
|
407
|
+
if (this._failedWithNonRetriableError.has(failedTest))
|
|
408
|
+
continue;
|
|
409
|
+
retryCandidates.add(failedTest);
|
|
410
|
+
let outermostSerialSuite;
|
|
411
|
+
for (let parent = failedTest.parent; parent; parent = parent.parent) {
|
|
412
|
+
if (parent._parallelMode === "serial")
|
|
413
|
+
outermostSerialSuite = parent;
|
|
414
|
+
}
|
|
415
|
+
if (outermostSerialSuite && !this._failedWithNonRetriableError.has(outermostSerialSuite))
|
|
416
|
+
serialSuitesWithFailures.add(outermostSerialSuite);
|
|
417
|
+
}
|
|
418
|
+
const testsBelongingToSomeSerialSuiteWithFailures = [...this._remainingByTestId.values()].filter((test) => {
|
|
419
|
+
let parent = test.parent;
|
|
420
|
+
while (parent && !serialSuitesWithFailures.has(parent))
|
|
421
|
+
parent = parent.parent;
|
|
422
|
+
return !!parent;
|
|
423
|
+
});
|
|
424
|
+
this._massSkipTestsFromRemaining(new Set(testsBelongingToSomeSerialSuiteWithFailures.map((test) => test.id)), []);
|
|
425
|
+
for (const serialSuite of serialSuitesWithFailures) {
|
|
426
|
+
serialSuite.allTests().forEach((test) => retryCandidates.add(test));
|
|
427
|
+
}
|
|
428
|
+
const remaining = [...this._remainingByTestId.values()];
|
|
429
|
+
for (const test of retryCandidates) {
|
|
430
|
+
if (test.results.length < test.retries + 1)
|
|
431
|
+
remaining.push(test);
|
|
432
|
+
}
|
|
433
|
+
const newJob = remaining.length ? { ...this.job, tests: remaining } : void 0;
|
|
434
|
+
this._finished({ didFail: true, newJob });
|
|
435
|
+
}
|
|
436
|
+
onExit(data) {
|
|
437
|
+
const unexpectedExitError = data.unexpectedly ? {
|
|
438
|
+
message: `Error: worker process exited unexpectedly (code=${data.code}, signal=${data.signal})`
|
|
439
|
+
} : void 0;
|
|
440
|
+
this._onDone({ skipTestsDueToSetupFailure: [], fatalErrors: [], unexpectedExitError });
|
|
441
|
+
}
|
|
442
|
+
_finished(result) {
|
|
443
|
+
import_utils.eventsHelper.removeEventListeners(this._listeners);
|
|
444
|
+
this.jobResult.resolve(result);
|
|
445
|
+
}
|
|
446
|
+
runInWorker(worker) {
|
|
447
|
+
this._parallelIndex = worker.parallelIndex;
|
|
448
|
+
this._workerIndex = worker.workerIndex;
|
|
449
|
+
const runPayload = {
|
|
450
|
+
file: this.job.requireFile,
|
|
451
|
+
entries: this.job.tests.map((test) => {
|
|
452
|
+
return { testId: test.id, retry: test.results.length };
|
|
453
|
+
})
|
|
454
|
+
};
|
|
455
|
+
worker.runTestGroup(runPayload);
|
|
456
|
+
this._listeners = [
|
|
457
|
+
import_utils.eventsHelper.addEventListener(worker, "testBegin", this._onTestBegin.bind(this)),
|
|
458
|
+
import_utils.eventsHelper.addEventListener(worker, "testEnd", this._onTestEnd.bind(this)),
|
|
459
|
+
import_utils.eventsHelper.addEventListener(worker, "stepBegin", this._onStepBegin.bind(this)),
|
|
460
|
+
import_utils.eventsHelper.addEventListener(worker, "stepEnd", this._onStepEnd.bind(this)),
|
|
461
|
+
import_utils.eventsHelper.addEventListener(worker, "attach", this._onAttach.bind(this)),
|
|
462
|
+
import_utils.eventsHelper.addEventListener(worker, "testPaused", this._onTestPaused.bind(this, worker)),
|
|
463
|
+
import_utils.eventsHelper.addEventListener(worker, "done", this._onDone.bind(this)),
|
|
464
|
+
import_utils.eventsHelper.addEventListener(worker, "exit", this.onExit.bind(this))
|
|
465
|
+
];
|
|
466
|
+
}
|
|
467
|
+
_onTestPaused(worker, params) {
|
|
468
|
+
const data = this._dataByTestId.get(params.testId);
|
|
469
|
+
if (!data)
|
|
470
|
+
return;
|
|
471
|
+
const { result, test } = data;
|
|
472
|
+
const sendMessage = async (message) => {
|
|
473
|
+
try {
|
|
474
|
+
if (this.jobResult.isDone())
|
|
475
|
+
throw new Error("Test has already stopped");
|
|
476
|
+
const response = await worker.sendCustomMessage({ testId: test.id, request: message.request });
|
|
477
|
+
if (response.error)
|
|
478
|
+
(0, import_internalReporter.addLocationAndSnippetToError)(this._config.config, response.error);
|
|
479
|
+
return response;
|
|
480
|
+
} catch (e) {
|
|
481
|
+
const error = (0, import_util.serializeError)(e);
|
|
482
|
+
(0, import_internalReporter.addLocationAndSnippetToError)(this._config.config, error);
|
|
483
|
+
return { response: void 0, error };
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
result.status = params.status;
|
|
487
|
+
result.errors = params.errors;
|
|
488
|
+
result.error = result.errors[0];
|
|
489
|
+
void this._reporter.onTestPaused?.(test, result).then(() => {
|
|
490
|
+
worker.sendResume({});
|
|
491
|
+
});
|
|
492
|
+
this._failureTracker.onTestPaused?.({ ...params, sendMessage });
|
|
493
|
+
}
|
|
494
|
+
skipWholeJob() {
|
|
495
|
+
const allTestsSkipped = this.job.tests.every((test) => test.expectedStatus === "skipped");
|
|
496
|
+
if (allTestsSkipped && !this._failureTracker.hasReachedMaxFailures()) {
|
|
497
|
+
for (const test of this.job.tests) {
|
|
498
|
+
const result = test._appendTestResult();
|
|
499
|
+
this._reporter.onTestBegin?.(test, result);
|
|
500
|
+
result.status = "skipped";
|
|
501
|
+
result.annotations = [...test.annotations];
|
|
502
|
+
this._reportTestEnd(test, result);
|
|
503
|
+
}
|
|
504
|
+
return true;
|
|
505
|
+
}
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
currentlyRunning() {
|
|
509
|
+
return this._currentlyRunning;
|
|
510
|
+
}
|
|
511
|
+
_reportTestEnd(test, result) {
|
|
512
|
+
this._reporter.onTestEnd?.(test, result);
|
|
513
|
+
const hadMaxFailures = this._failureTracker.hasReachedMaxFailures();
|
|
514
|
+
this._failureTracker.onTestEnd(test, result);
|
|
515
|
+
if (this._failureTracker.hasReachedMaxFailures()) {
|
|
516
|
+
this._stopCallback();
|
|
517
|
+
if (!hadMaxFailures)
|
|
518
|
+
this._reporter.onError?.({ message: import_utils2.colors.red(`Testing stopped early after ${this._failureTracker.maxFailures()} maximum allowed failures.`) });
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function chunkFromParams(params) {
|
|
523
|
+
if (typeof params.text === "string")
|
|
524
|
+
return params.text;
|
|
525
|
+
return Buffer.from(params.buffer, "base64");
|
|
526
|
+
}
|
|
527
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
528
|
+
0 && (module.exports = {
|
|
529
|
+
Dispatcher
|
|
530
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
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 failureTracker_exports = {};
|
|
20
|
+
__export(failureTracker_exports, {
|
|
21
|
+
FailureTracker: () => FailureTracker
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(failureTracker_exports);
|
|
24
|
+
class FailureTracker {
|
|
25
|
+
constructor(config, options) {
|
|
26
|
+
this._failureCount = 0;
|
|
27
|
+
this._hasWorkerErrors = false;
|
|
28
|
+
this._topLevelProjects = [];
|
|
29
|
+
this._config = config;
|
|
30
|
+
this._pauseOnError = !!options?.pauseOnError;
|
|
31
|
+
this._pauseAtEnd = !!options?.pauseAtEnd;
|
|
32
|
+
}
|
|
33
|
+
onRootSuite(rootSuite, topLevelProjects) {
|
|
34
|
+
this._rootSuite = rootSuite;
|
|
35
|
+
this._topLevelProjects = topLevelProjects;
|
|
36
|
+
}
|
|
37
|
+
onTestEnd(test, result) {
|
|
38
|
+
if (test.outcome() === "unexpected" && test.results.length > test.retries)
|
|
39
|
+
++this._failureCount;
|
|
40
|
+
}
|
|
41
|
+
onWorkerError() {
|
|
42
|
+
this._hasWorkerErrors = true;
|
|
43
|
+
}
|
|
44
|
+
pauseOnError() {
|
|
45
|
+
return this._pauseOnError;
|
|
46
|
+
}
|
|
47
|
+
pauseAtEnd(inProject) {
|
|
48
|
+
return this._topLevelProjects.includes(inProject) && this._pauseAtEnd;
|
|
49
|
+
}
|
|
50
|
+
hasReachedMaxFailures() {
|
|
51
|
+
return this.maxFailures() > 0 && this._failureCount >= this.maxFailures();
|
|
52
|
+
}
|
|
53
|
+
hasWorkerErrors() {
|
|
54
|
+
return this._hasWorkerErrors;
|
|
55
|
+
}
|
|
56
|
+
result() {
|
|
57
|
+
return this._hasWorkerErrors || this.hasReachedMaxFailures() || this.hasFailedTests() || this._config.failOnFlakyTests && this.hasFlakyTests() ? "failed" : "passed";
|
|
58
|
+
}
|
|
59
|
+
hasFailedTests() {
|
|
60
|
+
return this._rootSuite?.allTests().some((test) => !test.ok());
|
|
61
|
+
}
|
|
62
|
+
hasFlakyTests() {
|
|
63
|
+
return this._rootSuite?.allTests().some((test) => test.outcome() === "flaky");
|
|
64
|
+
}
|
|
65
|
+
maxFailures() {
|
|
66
|
+
return this._config.config.maxFailures;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
FailureTracker
|
|
72
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
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 lastRun_exports = {};
|
|
30
|
+
__export(lastRun_exports, {
|
|
31
|
+
LastRunReporter: () => LastRunReporter
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(lastRun_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_projectUtils = require("./projectUtils");
|
|
37
|
+
class LastRunReporter {
|
|
38
|
+
constructor(config) {
|
|
39
|
+
this._config = config;
|
|
40
|
+
const [project] = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
|
|
41
|
+
if (project)
|
|
42
|
+
this._lastRunFile = import_path.default.join(project.project.outputDir, ".last-run.json");
|
|
43
|
+
}
|
|
44
|
+
async filterLastFailed() {
|
|
45
|
+
if (!this._lastRunFile)
|
|
46
|
+
return;
|
|
47
|
+
try {
|
|
48
|
+
const lastRunInfo = JSON.parse(await import_fs.default.promises.readFile(this._lastRunFile, "utf8"));
|
|
49
|
+
const failedTestIds = new Set(lastRunInfo.failedTests);
|
|
50
|
+
this._config.postShardTestFilters.push((test) => failedTestIds.has(test.id));
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
version() {
|
|
55
|
+
return "v2";
|
|
56
|
+
}
|
|
57
|
+
printsToStdio() {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
onBegin(suite) {
|
|
61
|
+
this._suite = suite;
|
|
62
|
+
}
|
|
63
|
+
async onEnd(result) {
|
|
64
|
+
if (!this._lastRunFile || this._config.cliListOnly)
|
|
65
|
+
return;
|
|
66
|
+
const lastRunInfo = {
|
|
67
|
+
status: result.status,
|
|
68
|
+
failedTests: this._suite?.allTests().filter((t) => !t.ok()).map((t) => t.id) || []
|
|
69
|
+
};
|
|
70
|
+
await import_fs.default.promises.mkdir(import_path.default.dirname(this._lastRunFile), { recursive: true });
|
|
71
|
+
await import_fs.default.promises.writeFile(this._lastRunFile, JSON.stringify(lastRunInfo, void 0, 2));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
LastRunReporter
|
|
77
|
+
});
|