@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.
- package/ThirdPartyNotices.txt +8 -5036
- package/lib/agents/agentParser.js +2 -2
- package/lib/agents/generateAgents.js +21 -22
- package/lib/agents/playwright-test-healer.agent.md +1 -0
- package/lib/agents/playwright-test-planner.agent.md +2 -1
- package/lib/cli/reportActions.js +78 -0
- package/lib/cli/testActions.js +211 -0
- package/lib/common/index.js +2898 -0
- package/lib/common/index.js.txt +35 -0
- package/lib/errorContext.js +130 -0
- package/lib/index.js +258 -206
- package/lib/{isomorphic/testServerConnection.js → isomorphic.js} +70 -35
- package/lib/isomorphic.js.txt +9 -0
- package/lib/loader/loaderProcessEntry.js +34 -0
- package/lib/loader/loaderProcessEntry.js.txt +9 -0
- package/lib/matchers/expect.js +12988 -249
- package/lib/matchers/expect.js.LICENSE +693 -0
- package/lib/matchers/expect.js.txt +72 -0
- package/lib/mcp/test/browserBackend.js +49 -22
- package/lib/mcp/test/generatorTools.js +16 -16
- package/lib/mcp/test/plannerTools.js +25 -20
- package/lib/mcp/test/seed.js +7 -7
- package/lib/mcp/test/testBackend.js +30 -30
- package/lib/mcp/test/testContext.js +50 -33
- package/lib/mcp/test/testTools.js +15 -25
- package/lib/{internalsForTest.js → package.js} +13 -8
- package/lib/program.js +63 -263
- package/lib/runner/index.js +8339 -0
- package/lib/runner/index.js.txt +60 -0
- package/lib/transform/babelBundle.js +71002 -18
- package/lib/transform/babelBundle.js.LICENSE +2359 -0
- package/lib/transform/babelBundle.js.txt +325 -0
- package/lib/transform/esmLoader.js +5884 -30
- package/lib/transform/esmLoader.js.LICENSE +335 -0
- package/lib/transform/esmLoader.js.txt +55 -0
- package/lib/util.js +37 -34
- package/lib/worker/workerProcessEntry.js +3251 -0
- package/lib/worker/workerProcessEntry.js.txt +24 -0
- package/package.json +5 -16
- package/test.mjs +1 -0
- package/types/test.d.ts +172 -12
- package/types/testReporter.d.ts +7 -5
- package/lib/common/config.js +0 -282
- package/lib/common/configLoader.js +0 -344
- package/lib/common/esmLoaderHost.js +0 -104
- package/lib/common/expectBundle.js +0 -28
- package/lib/common/expectBundleImpl.js +0 -407
- package/lib/common/fixtures.js +0 -302
- package/lib/common/ipc.js +0 -60
- package/lib/common/poolBuilder.js +0 -85
- package/lib/common/process.js +0 -132
- package/lib/common/suiteUtils.js +0 -140
- package/lib/common/test.js +0 -321
- package/lib/common/testLoader.js +0 -101
- package/lib/common/testType.js +0 -298
- package/lib/common/validators.js +0 -68
- package/lib/fsWatcher.js +0 -67
- package/lib/isomorphic/events.js +0 -77
- package/lib/isomorphic/folders.js +0 -30
- package/lib/isomorphic/stringInternPool.js +0 -69
- package/lib/isomorphic/teleReceiver.js +0 -521
- package/lib/isomorphic/teleSuiteUpdater.js +0 -157
- package/lib/isomorphic/testServerInterface.js +0 -16
- package/lib/isomorphic/testTree.js +0 -329
- package/lib/isomorphic/types.d.js +0 -16
- package/lib/loader/loaderMain.js +0 -59
- package/lib/matchers/matcherHint.js +0 -44
- package/lib/matchers/matchers.js +0 -383
- package/lib/matchers/toBeTruthy.js +0 -75
- package/lib/matchers/toEqual.js +0 -100
- package/lib/matchers/toHaveURL.js +0 -101
- package/lib/matchers/toMatchAriaSnapshot.js +0 -159
- package/lib/matchers/toMatchSnapshot.js +0 -342
- package/lib/matchers/toMatchText.js +0 -99
- package/lib/mcp/browser/browserContextFactory.js +0 -329
- package/lib/mcp/browser/browserServerBackend.js +0 -84
- package/lib/mcp/browser/config.js +0 -421
- package/lib/mcp/browser/context.js +0 -244
- package/lib/mcp/browser/response.js +0 -278
- package/lib/mcp/browser/sessionLog.js +0 -75
- package/lib/mcp/browser/tab.js +0 -343
- package/lib/mcp/browser/tools/common.js +0 -65
- package/lib/mcp/browser/tools/console.js +0 -46
- package/lib/mcp/browser/tools/dialogs.js +0 -60
- package/lib/mcp/browser/tools/evaluate.js +0 -61
- package/lib/mcp/browser/tools/files.js +0 -58
- package/lib/mcp/browser/tools/form.js +0 -63
- package/lib/mcp/browser/tools/install.js +0 -72
- package/lib/mcp/browser/tools/keyboard.js +0 -107
- package/lib/mcp/browser/tools/mouse.js +0 -107
- package/lib/mcp/browser/tools/navigate.js +0 -71
- package/lib/mcp/browser/tools/network.js +0 -63
- package/lib/mcp/browser/tools/open.js +0 -57
- package/lib/mcp/browser/tools/pdf.js +0 -49
- package/lib/mcp/browser/tools/runCode.js +0 -78
- package/lib/mcp/browser/tools/screenshot.js +0 -93
- package/lib/mcp/browser/tools/snapshot.js +0 -173
- package/lib/mcp/browser/tools/tabs.js +0 -67
- package/lib/mcp/browser/tools/tool.js +0 -47
- package/lib/mcp/browser/tools/tracing.js +0 -74
- package/lib/mcp/browser/tools/utils.js +0 -94
- package/lib/mcp/browser/tools/verify.js +0 -143
- package/lib/mcp/browser/tools/wait.js +0 -63
- package/lib/mcp/browser/tools.js +0 -84
- package/lib/mcp/browser/watchdog.js +0 -44
- package/lib/mcp/config.d.js +0 -16
- package/lib/mcp/extension/cdpRelay.js +0 -351
- package/lib/mcp/extension/extensionContextFactory.js +0 -76
- package/lib/mcp/extension/protocol.js +0 -28
- package/lib/mcp/index.js +0 -61
- package/lib/mcp/log.js +0 -35
- package/lib/mcp/program.js +0 -111
- package/lib/mcp/sdk/exports.js +0 -28
- package/lib/mcp/sdk/http.js +0 -152
- package/lib/mcp/sdk/inProcessTransport.js +0 -71
- package/lib/mcp/sdk/server.js +0 -223
- package/lib/mcp/sdk/tool.js +0 -47
- package/lib/mcp/terminal/cli.js +0 -296
- package/lib/mcp/terminal/command.js +0 -56
- package/lib/mcp/terminal/commands.js +0 -333
- package/lib/mcp/terminal/daemon.js +0 -129
- package/lib/mcp/terminal/help.json +0 -32
- package/lib/mcp/terminal/helpGenerator.js +0 -88
- package/lib/mcp/terminal/socketConnection.js +0 -80
- package/lib/plugins/gitCommitInfoPlugin.js +0 -198
- package/lib/plugins/index.js +0 -28
- package/lib/plugins/webServerPlugin.js +0 -237
- package/lib/reporters/base.js +0 -634
- package/lib/reporters/blob.js +0 -138
- package/lib/reporters/dot.js +0 -99
- package/lib/reporters/empty.js +0 -32
- package/lib/reporters/github.js +0 -128
- package/lib/reporters/html.js +0 -633
- package/lib/reporters/internalReporter.js +0 -138
- package/lib/reporters/json.js +0 -254
- package/lib/reporters/junit.js +0 -232
- package/lib/reporters/line.js +0 -131
- package/lib/reporters/list.js +0 -253
- package/lib/reporters/listModeReporter.js +0 -69
- package/lib/reporters/markdown.js +0 -144
- package/lib/reporters/merge.js +0 -558
- package/lib/reporters/multiplexer.js +0 -112
- package/lib/reporters/reporterV2.js +0 -102
- package/lib/reporters/smoothdeploy.js +0 -333
- package/lib/reporters/teleEmitter.js +0 -317
- package/lib/reporters/versions/blobV1.js +0 -16
- package/lib/runner/dispatcher.js +0 -531
- package/lib/runner/failureTracker.js +0 -72
- package/lib/runner/lastRun.js +0 -77
- package/lib/runner/loadUtils.js +0 -334
- package/lib/runner/loaderHost.js +0 -89
- package/lib/runner/processHost.js +0 -180
- package/lib/runner/projectUtils.js +0 -241
- package/lib/runner/rebase.js +0 -189
- package/lib/runner/reporters.js +0 -140
- package/lib/runner/sigIntWatcher.js +0 -96
- package/lib/runner/storage.js +0 -91
- package/lib/runner/taskRunner.js +0 -127
- package/lib/runner/tasks.js +0 -410
- package/lib/runner/testGroups.js +0 -125
- package/lib/runner/testRunner.js +0 -398
- package/lib/runner/testServer.js +0 -269
- package/lib/runner/uiModeReporter.js +0 -30
- package/lib/runner/vcs.js +0 -72
- package/lib/runner/watchMode.js +0 -396
- package/lib/runner/workerHost.js +0 -104
- package/lib/third_party/pirates.js +0 -62
- package/lib/third_party/tsconfig-loader.js +0 -103
- package/lib/transform/babelBundleImpl.js +0 -461
- package/lib/transform/compilationCache.js +0 -274
- package/lib/transform/md.js +0 -221
- package/lib/transform/portTransport.js +0 -67
- package/lib/transform/transform.js +0 -303
- package/lib/utilsBundle.js +0 -50
- package/lib/utilsBundleImpl.js +0 -103
- package/lib/worker/fixtureRunner.js +0 -262
- package/lib/worker/testInfo.js +0 -536
- package/lib/worker/testTracing.js +0 -345
- package/lib/worker/timeoutManager.js +0 -174
- package/lib/worker/util.js +0 -31
- package/lib/worker/workerMain.js +0 -530
- /package/lib/{common/globals.js → globals.js} +0 -0
|
@@ -1,102 +0,0 @@
|
|
|
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 reporterV2_exports = {};
|
|
20
|
-
__export(reporterV2_exports, {
|
|
21
|
-
wrapReporterAsV2: () => wrapReporterAsV2
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(reporterV2_exports);
|
|
24
|
-
function wrapReporterAsV2(reporter) {
|
|
25
|
-
try {
|
|
26
|
-
if ("version" in reporter && reporter.version() === "v2")
|
|
27
|
-
return reporter;
|
|
28
|
-
} catch (e) {
|
|
29
|
-
}
|
|
30
|
-
return new ReporterV2Wrapper(reporter);
|
|
31
|
-
}
|
|
32
|
-
class ReporterV2Wrapper {
|
|
33
|
-
constructor(reporter) {
|
|
34
|
-
this._deferred = [];
|
|
35
|
-
this._reporter = reporter;
|
|
36
|
-
}
|
|
37
|
-
version() {
|
|
38
|
-
return "v2";
|
|
39
|
-
}
|
|
40
|
-
onConfigure(config) {
|
|
41
|
-
this._config = config;
|
|
42
|
-
}
|
|
43
|
-
onBegin(suite) {
|
|
44
|
-
this._reporter.onBegin?.(this._config, suite);
|
|
45
|
-
const deferred = this._deferred;
|
|
46
|
-
this._deferred = null;
|
|
47
|
-
for (const item of deferred) {
|
|
48
|
-
if (item.error)
|
|
49
|
-
this.onError(item.error);
|
|
50
|
-
if (item.stdout)
|
|
51
|
-
this.onStdOut(item.stdout.chunk, item.stdout.test, item.stdout.result);
|
|
52
|
-
if (item.stderr)
|
|
53
|
-
this.onStdErr(item.stderr.chunk, item.stderr.test, item.stderr.result);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
onTestBegin(test, result) {
|
|
57
|
-
this._reporter.onTestBegin?.(test, result);
|
|
58
|
-
}
|
|
59
|
-
onStdOut(chunk, test, result) {
|
|
60
|
-
if (this._deferred) {
|
|
61
|
-
this._deferred.push({ stdout: { chunk, test, result } });
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this._reporter.onStdOut?.(chunk, test, result);
|
|
65
|
-
}
|
|
66
|
-
onStdErr(chunk, test, result) {
|
|
67
|
-
if (this._deferred) {
|
|
68
|
-
this._deferred.push({ stderr: { chunk, test, result } });
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this._reporter.onStdErr?.(chunk, test, result);
|
|
72
|
-
}
|
|
73
|
-
onTestEnd(test, result) {
|
|
74
|
-
this._reporter.onTestEnd?.(test, result);
|
|
75
|
-
}
|
|
76
|
-
async onEnd(result) {
|
|
77
|
-
return await this._reporter.onEnd?.(result);
|
|
78
|
-
}
|
|
79
|
-
async onExit() {
|
|
80
|
-
await this._reporter.onExit?.();
|
|
81
|
-
}
|
|
82
|
-
onError(error) {
|
|
83
|
-
if (this._deferred) {
|
|
84
|
-
this._deferred.push({ error });
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
this._reporter.onError?.(error);
|
|
88
|
-
}
|
|
89
|
-
onStepBegin(test, result, step) {
|
|
90
|
-
this._reporter.onStepBegin?.(test, result, step);
|
|
91
|
-
}
|
|
92
|
-
onStepEnd(test, result, step) {
|
|
93
|
-
this._reporter.onStepEnd?.(test, result, step);
|
|
94
|
-
}
|
|
95
|
-
printsToStdio() {
|
|
96
|
-
return this._reporter.printsToStdio ? this._reporter.printsToStdio() : true;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
-
0 && (module.exports = {
|
|
101
|
-
wrapReporterAsV2
|
|
102
|
-
});
|
|
@@ -1,333 +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 smoothdeploy_exports = {};
|
|
30
|
-
__export(smoothdeploy_exports, {
|
|
31
|
-
default: () => smoothdeploy_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(smoothdeploy_exports);
|
|
34
|
-
var fs = __toESM(require("fs"));
|
|
35
|
-
var path = __toESM(require("path"));
|
|
36
|
-
class SmoothDeployReporter {
|
|
37
|
-
constructor() {
|
|
38
|
-
this._configDir = "";
|
|
39
|
-
this._manifest = null;
|
|
40
|
-
// Resolved manifest test + paramIndex for each active pw test
|
|
41
|
-
this._resolvedTests = /* @__PURE__ */ new Map();
|
|
42
|
-
// Map pw TestStep → matched manifest step
|
|
43
|
-
this._stepToManifest = /* @__PURE__ */ new WeakMap();
|
|
44
|
-
// Child counter per parent (TestStep for nested, test.id string for root-level)
|
|
45
|
-
this._childCounters = /* @__PURE__ */ new Map();
|
|
46
|
-
// Accumulate nested step data per test for output manifest
|
|
47
|
-
this._testSteps = /* @__PURE__ */ new Map();
|
|
48
|
-
// Track parent step → output StepData for nesting output
|
|
49
|
-
this._stepToOutput = /* @__PURE__ */ new WeakMap();
|
|
50
|
-
// ID remap: pw IDs → manifest IDs (sanitized). Built during execution, applied in onEnd.
|
|
51
|
-
this._testIdMap = /* @__PURE__ */ new Map();
|
|
52
|
-
// safePwTestId → safeManifestTestId
|
|
53
|
-
this._stepIdMap = /* @__PURE__ */ new Map();
|
|
54
|
-
}
|
|
55
|
-
// safePwStepId → safeManifestStepId
|
|
56
|
-
version() {
|
|
57
|
-
return "v2";
|
|
58
|
-
}
|
|
59
|
-
printsToStdio() {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
onConfigure(config) {
|
|
63
|
-
this._configDir = config.configFile ? path.dirname(config.configFile) : config.rootDir;
|
|
64
|
-
this._loadManifest();
|
|
65
|
-
}
|
|
66
|
-
_loadManifest() {
|
|
67
|
-
const manifestPath = path.join(this._configDir, ".smoothdeploy-manifest.json");
|
|
68
|
-
if (!fs.existsSync(manifestPath))
|
|
69
|
-
throw new Error(`SmoothDeploy reporter requires .smoothdeploy-manifest.json in ${this._configDir}`);
|
|
70
|
-
const raw = fs.readFileSync(manifestPath, "utf-8");
|
|
71
|
-
this._manifest = JSON.parse(raw);
|
|
72
|
-
}
|
|
73
|
-
_emit(event) {
|
|
74
|
-
process.stdout.write(`[SMOOTHDEPLOY_EVENT]${JSON.stringify(event)}
|
|
75
|
-
`);
|
|
76
|
-
}
|
|
77
|
-
_isUserStep(step) {
|
|
78
|
-
const title = step.title;
|
|
79
|
-
if (title === "Before Hooks" || title === "After Hooks" || title === "Worker Cleanup")
|
|
80
|
-
return false;
|
|
81
|
-
if (title.startsWith('Fixture "'))
|
|
82
|
-
return false;
|
|
83
|
-
const internalSteps = [
|
|
84
|
-
"Launch browser",
|
|
85
|
-
"Launch persistent context",
|
|
86
|
-
"Connect over CDP",
|
|
87
|
-
"Close browser",
|
|
88
|
-
"Create context",
|
|
89
|
-
"Close context",
|
|
90
|
-
"Create page",
|
|
91
|
-
"Close page",
|
|
92
|
-
"Create CDP session"
|
|
93
|
-
];
|
|
94
|
-
if (internalSteps.includes(title))
|
|
95
|
-
return false;
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
// Resolve a pw TestCase to its manifest test entry + param index.
|
|
99
|
-
// For parameterized tests: manifest title "Foo" with params=3 matches pw titles "Foo0", "Foo1", "Foo2".
|
|
100
|
-
// For non-parameterized tests: exact match, paramIndex=0.
|
|
101
|
-
_resolveManifestTest(test) {
|
|
102
|
-
if (!this._manifest)
|
|
103
|
-
return null;
|
|
104
|
-
const titlePath = test.titlePath();
|
|
105
|
-
const relFile = path.relative(this._configDir, test.location.file);
|
|
106
|
-
const fileManifest = this._manifest.files[relFile];
|
|
107
|
-
if (!fileManifest)
|
|
108
|
-
return null;
|
|
109
|
-
const fileIdx = titlePath.indexOf(relFile);
|
|
110
|
-
const describeTitles = fileIdx >= 0 ? titlePath.slice(fileIdx + 1, -1) : [];
|
|
111
|
-
const testTitle = test.title;
|
|
112
|
-
let currentSuites = fileManifest.suites;
|
|
113
|
-
let currentTests = fileManifest.tests;
|
|
114
|
-
for (const desc of describeTitles) {
|
|
115
|
-
const suite = currentSuites.find((s) => s.title === desc);
|
|
116
|
-
if (!suite)
|
|
117
|
-
return null;
|
|
118
|
-
currentSuites = suite.suites;
|
|
119
|
-
currentTests = suite.tests;
|
|
120
|
-
}
|
|
121
|
-
const exactMatch = currentTests.find((t) => t.title === testTitle);
|
|
122
|
-
if (exactMatch)
|
|
123
|
-
return { manifestTest: exactMatch, paramIndex: 0 };
|
|
124
|
-
for (const mt of currentTests) {
|
|
125
|
-
if (!mt.params || mt.params < 1)
|
|
126
|
-
continue;
|
|
127
|
-
if (!testTitle.startsWith(mt.title))
|
|
128
|
-
continue;
|
|
129
|
-
const suffix = testTitle.slice(mt.title.length);
|
|
130
|
-
const idx = parseInt(suffix, 10);
|
|
131
|
-
if (String(idx) === suffix && idx >= 0 && idx < mt.params)
|
|
132
|
-
return { manifestTest: mt, paramIndex: idx };
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
onTestBegin(test, result) {
|
|
137
|
-
const resolved = this._resolveManifestTest(test);
|
|
138
|
-
if (!resolved)
|
|
139
|
-
return;
|
|
140
|
-
this._resolvedTests.set(test.id, resolved);
|
|
141
|
-
const safePw = test.id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
142
|
-
const safeManifest = resolved.manifestTest.id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
143
|
-
this._testIdMap.set(safePw, safeManifest);
|
|
144
|
-
this._childCounters.set(test.id, 0);
|
|
145
|
-
this._testSteps.set(test.id, []);
|
|
146
|
-
this._emit({
|
|
147
|
-
event: "testBegin",
|
|
148
|
-
testId: resolved.manifestTest.id,
|
|
149
|
-
paramIndex: resolved.paramIndex,
|
|
150
|
-
testTitle: test.title,
|
|
151
|
-
timestamp: Date.now()
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
onTestEnd(test, result) {
|
|
155
|
-
const resolved = this._resolvedTests.get(test.id);
|
|
156
|
-
if (!resolved)
|
|
157
|
-
return;
|
|
158
|
-
this._emit({
|
|
159
|
-
event: "testEnd",
|
|
160
|
-
testId: resolved.manifestTest.id,
|
|
161
|
-
paramIndex: resolved.paramIndex,
|
|
162
|
-
testTitle: test.title,
|
|
163
|
-
status: result.status,
|
|
164
|
-
duration: result.duration,
|
|
165
|
-
timestamp: Date.now()
|
|
166
|
-
});
|
|
167
|
-
this._childCounters.delete(test.id);
|
|
168
|
-
}
|
|
169
|
-
onStepBegin(test, result, step) {
|
|
170
|
-
if (!this._isUserStep(step))
|
|
171
|
-
return;
|
|
172
|
-
const resolved = this._resolvedTests.get(test.id);
|
|
173
|
-
if (!resolved)
|
|
174
|
-
return;
|
|
175
|
-
let parentStep = step.parent;
|
|
176
|
-
while (parentStep && !this._stepToOutput.has(parentStep))
|
|
177
|
-
parentStep = parentStep.parent;
|
|
178
|
-
const parentKey = parentStep ?? test.id;
|
|
179
|
-
const parentManifest = parentStep ? this._stepToManifest.get(parentStep) : void 0;
|
|
180
|
-
const parentSteps = parentManifest ? parentManifest.children : resolved.manifestTest.steps;
|
|
181
|
-
const idx = this._childCounters.get(parentKey) ?? 0;
|
|
182
|
-
this._childCounters.set(parentKey, idx + 1);
|
|
183
|
-
const manifestStep = parentSteps?.[idx] ?? null;
|
|
184
|
-
if (manifestStep)
|
|
185
|
-
this._stepToManifest.set(step, manifestStep);
|
|
186
|
-
this._childCounters.set(step, 0);
|
|
187
|
-
const outputStep = {
|
|
188
|
-
id: manifestStep?.id,
|
|
189
|
-
action: manifestStep?.action,
|
|
190
|
-
title: step.title,
|
|
191
|
-
category: step.category,
|
|
192
|
-
duration: 0,
|
|
193
|
-
error: null,
|
|
194
|
-
screenshots: null,
|
|
195
|
-
children: []
|
|
196
|
-
};
|
|
197
|
-
this._stepToOutput.set(step, outputStep);
|
|
198
|
-
const parentOutput = parentStep ? this._stepToOutput.get(parentStep) : void 0;
|
|
199
|
-
if (parentOutput)
|
|
200
|
-
parentOutput.children.push(outputStep);
|
|
201
|
-
else
|
|
202
|
-
this._testSteps.get(test.id)?.push(outputStep);
|
|
203
|
-
this._emit({
|
|
204
|
-
event: "stepBegin",
|
|
205
|
-
testId: resolved.manifestTest.id,
|
|
206
|
-
paramIndex: resolved.paramIndex,
|
|
207
|
-
id: manifestStep?.id,
|
|
208
|
-
action: manifestStep?.action,
|
|
209
|
-
title: step.title,
|
|
210
|
-
category: step.category,
|
|
211
|
-
timestamp: Date.now()
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
onStepEnd(test, result, step) {
|
|
215
|
-
if (!this._isUserStep(step))
|
|
216
|
-
return;
|
|
217
|
-
const resolved = this._resolvedTests.get(test.id);
|
|
218
|
-
if (!resolved)
|
|
219
|
-
return;
|
|
220
|
-
const manifestStep = this._stepToManifest.get(step) ?? null;
|
|
221
|
-
const outputStep = this._stepToOutput.get(step);
|
|
222
|
-
const safeTestId = test.id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
223
|
-
const noScreenshotPrefixes = [
|
|
224
|
-
"Navigate",
|
|
225
|
-
"Go back",
|
|
226
|
-
"Go forward",
|
|
227
|
-
"Reload",
|
|
228
|
-
"Screenshot",
|
|
229
|
-
"Wait for",
|
|
230
|
-
"Pause",
|
|
231
|
-
"Evaluate"
|
|
232
|
-
];
|
|
233
|
-
const hasScreenshot = step.category === "pw:api" && !noScreenshotPrefixes.some((prefix) => step.title.startsWith(prefix));
|
|
234
|
-
const internalStepId = step._stepId ?? step.title;
|
|
235
|
-
const safeStepId = internalStepId.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
236
|
-
const screenshots = hasScreenshot ? {
|
|
237
|
-
page: `.smoothdeploy-output/screenshots/${safeTestId}/${safeStepId}-page.png`,
|
|
238
|
-
element: `.smoothdeploy-output/screenshots/${safeTestId}/${safeStepId}-element.png`
|
|
239
|
-
} : null;
|
|
240
|
-
if (manifestStep) {
|
|
241
|
-
const safeManifestStepId = manifestStep.id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
242
|
-
this._stepIdMap.set(safeStepId, safeManifestStepId);
|
|
243
|
-
}
|
|
244
|
-
if (outputStep) {
|
|
245
|
-
outputStep.duration = step.duration;
|
|
246
|
-
const hasDescendantError = (steps) => steps.some((c) => c.error !== null || hasDescendantError(c.children));
|
|
247
|
-
outputStep.error = step.error && !hasDescendantError(outputStep.children) ? { message: step.error.message } : null;
|
|
248
|
-
outputStep.screenshots = screenshots;
|
|
249
|
-
}
|
|
250
|
-
this._childCounters.delete(step);
|
|
251
|
-
this._emit({
|
|
252
|
-
event: "stepEnd",
|
|
253
|
-
testId: resolved.manifestTest.id,
|
|
254
|
-
paramIndex: resolved.paramIndex,
|
|
255
|
-
id: manifestStep?.id,
|
|
256
|
-
action: manifestStep?.action,
|
|
257
|
-
title: step.title,
|
|
258
|
-
duration: step.duration,
|
|
259
|
-
error: step.error ? { message: step.error.message } : null,
|
|
260
|
-
timestamp: Date.now()
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
onEnd(result) {
|
|
264
|
-
const outputDir = path.join(process.cwd(), ".smoothdeploy-output");
|
|
265
|
-
const screenshotsDir = path.join(outputDir, "screenshots");
|
|
266
|
-
if (this._manifest) {
|
|
267
|
-
for (const [safePwTestId] of this._testIdMap) {
|
|
268
|
-
const testDir = path.join(screenshotsDir, safePwTestId);
|
|
269
|
-
if (!fs.existsSync(testDir))
|
|
270
|
-
continue;
|
|
271
|
-
for (const [safePwStepId, safeManifestStepId] of this._stepIdMap) {
|
|
272
|
-
for (const suffix of ["-page.png", "-element.png"]) {
|
|
273
|
-
const src = path.join(testDir, `${safePwStepId}${suffix}`);
|
|
274
|
-
const dst = path.join(testDir, `${safeManifestStepId}${suffix}`);
|
|
275
|
-
if (fs.existsSync(src))
|
|
276
|
-
fs.renameSync(src, dst);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
for (const [safePwTestId, safeManifestTestId] of this._testIdMap) {
|
|
281
|
-
const src = path.join(screenshotsDir, safePwTestId);
|
|
282
|
-
const dst = path.join(screenshotsDir, safeManifestTestId);
|
|
283
|
-
if (fs.existsSync(src)) {
|
|
284
|
-
if (fs.existsSync(dst))
|
|
285
|
-
fs.rmSync(dst, { recursive: true });
|
|
286
|
-
fs.renameSync(src, dst);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
const remapScreenshotPaths = (steps) => {
|
|
291
|
-
for (const step of steps) {
|
|
292
|
-
if (step.screenshots) {
|
|
293
|
-
step.screenshots.page = this._remapPath(step.screenshots.page);
|
|
294
|
-
step.screenshots.element = this._remapPath(step.screenshots.element);
|
|
295
|
-
}
|
|
296
|
-
remapScreenshotPaths(step.children);
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
const manifest = {};
|
|
300
|
-
for (const [testId, steps] of this._testSteps) {
|
|
301
|
-
const resolved = this._resolvedTests.get(testId);
|
|
302
|
-
if (!resolved)
|
|
303
|
-
continue;
|
|
304
|
-
remapScreenshotPaths(steps);
|
|
305
|
-
const safeManifestTestId = resolved.manifestTest.id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
306
|
-
const failurePath = path.join(screenshotsDir, safeManifestTestId, "failure.png");
|
|
307
|
-
const failureScreenshot = fs.existsSync(failurePath) ? `.smoothdeploy-output/screenshots/${safeManifestTestId}/failure.png` : null;
|
|
308
|
-
const key = resolved.manifestTest.id;
|
|
309
|
-
if (!manifest[key])
|
|
310
|
-
manifest[key] = [];
|
|
311
|
-
manifest[key].push({ paramIndex: resolved.paramIndex, steps, failureScreenshot });
|
|
312
|
-
}
|
|
313
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
314
|
-
fs.writeFileSync(
|
|
315
|
-
path.join(outputDir, "manifest.json"),
|
|
316
|
-
JSON.stringify(manifest, null, 2)
|
|
317
|
-
);
|
|
318
|
-
this._emit({
|
|
319
|
-
event: "runEnd",
|
|
320
|
-
status: result.status,
|
|
321
|
-
timestamp: Date.now()
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
_remapPath(screenshotPath) {
|
|
325
|
-
let result = screenshotPath;
|
|
326
|
-
for (const [safePwTestId, safeManifestTestId] of this._testIdMap)
|
|
327
|
-
result = result.replace(`/${safePwTestId}/`, `/${safeManifestTestId}/`);
|
|
328
|
-
for (const [safePwStepId, safeManifestStepId] of this._stepIdMap)
|
|
329
|
-
result = result.replace(`/${safePwStepId}-`, `/${safeManifestStepId}-`);
|
|
330
|
-
return result;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
var smoothdeploy_default = SmoothDeployReporter;
|