@simplysf/simply-utam-core 0.2.0 → 0.3.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/README.md +72 -16
- package/lib/forceignore/forceignore-manager.d.ts +30 -0
- package/lib/forceignore/forceignore-manager.js +28 -10
- package/lib/forceignore/forceignore-manager.js.map +1 -1
- package/lib/forceignore/index.d.ts +1 -1
- package/lib/forceignore/index.js +1 -1
- package/lib/forceignore/index.js.map +1 -1
- package/lib/gitignore/gitignore-manager.d.ts +64 -0
- package/lib/gitignore/gitignore-manager.js +96 -0
- package/lib/gitignore/gitignore-manager.js.map +1 -0
- package/lib/gitignore/index.d.ts +1 -0
- package/lib/gitignore/index.js +17 -0
- package/lib/gitignore/index.js.map +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/namespaces/namespace-map.d.ts +18 -0
- package/lib/namespaces/namespace-map.js +75 -0
- package/lib/namespaces/namespace-map.js.map +1 -0
- package/lib/namespaces/namespace-rewriter.js +2 -47
- package/lib/namespaces/namespace-rewriter.js.map +1 -1
- package/lib/scaffold/project-scaffolder.d.ts +26 -1
- package/lib/scaffold/project-scaffolder.js +81 -11
- package/lib/scaffold/project-scaffolder.js.map +1 -1
- package/lib/snapshot/capture.d.ts +56 -0
- package/lib/snapshot/capture.js +115 -0
- package/lib/snapshot/capture.js.map +1 -0
- package/lib/snapshot/console.d.ts +25 -0
- package/lib/snapshot/console.js +74 -0
- package/lib/snapshot/console.js.map +1 -0
- package/lib/snapshot/describe.d.ts +27 -0
- package/lib/snapshot/describe.js +76 -0
- package/lib/snapshot/describe.js.map +1 -0
- package/lib/snapshot/files.d.ts +85 -0
- package/lib/snapshot/files.js +185 -0
- package/lib/snapshot/files.js.map +1 -0
- package/lib/snapshot/find.d.ts +36 -0
- package/lib/snapshot/find.js +186 -0
- package/lib/snapshot/find.js.map +1 -0
- package/lib/snapshot/format.d.ts +96 -0
- package/lib/snapshot/format.js +100 -0
- package/lib/snapshot/format.js.map +1 -0
- package/lib/snapshot/header.d.ts +38 -0
- package/lib/snapshot/header.js +120 -0
- package/lib/snapshot/header.js.map +1 -0
- package/lib/snapshot/index.d.ts +13 -0
- package/lib/snapshot/index.js +28 -0
- package/lib/snapshot/index.js.map +1 -0
- package/lib/snapshot/locate.d.ts +61 -0
- package/lib/snapshot/locate.js +110 -0
- package/lib/snapshot/locate.js.map +1 -0
- package/lib/snapshot/lookup.d.ts +53 -0
- package/lib/snapshot/lookup.js +188 -0
- package/lib/snapshot/lookup.js.map +1 -0
- package/lib/snapshot/page-object-index.d.ts +149 -0
- package/lib/snapshot/page-object-index.js +806 -0
- package/lib/snapshot/page-object-index.js.map +1 -0
- package/lib/snapshot/page-object-packages.d.ts +41 -0
- package/lib/snapshot/page-object-packages.js +115 -0
- package/lib/snapshot/page-object-packages.js.map +1 -0
- package/lib/snapshot/path.d.ts +102 -0
- package/lib/snapshot/path.js +381 -0
- package/lib/snapshot/path.js.map +1 -0
- package/lib/snapshot/query-result.d.ts +20 -0
- package/lib/snapshot/query-result.js +32 -0
- package/lib/snapshot/query-result.js.map +1 -0
- package/lib/snapshot/selector.d.ts +103 -0
- package/lib/snapshot/selector.js +280 -0
- package/lib/snapshot/selector.js.map +1 -0
- package/lib/snapshot/tree.d.ts +76 -0
- package/lib/snapshot/tree.js +201 -0
- package/lib/snapshot/tree.js.map +1 -0
- package/lib/snapshot/walker.js +532 -0
- package/package.json +12 -4
- package/templates/dom-snapshot.steps.mjs +34 -0
- package/templates/wdio.conf.mjs +81 -4
package/templates/wdio.conf.mjs
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import { UtamWdioService } from 'wdio-utam-service';
|
|
2
|
+
import allureReporter from '@wdio/allure-reporter';
|
|
3
|
+
|
|
4
|
+
// Imported here rather than with a static import, so a project whose @simplysf/simply-utam predates
|
|
5
|
+
// DOM snapshots still loads this config: the snapshot hooks then skip, and onPrepare says to upgrade.
|
|
6
|
+
const snapshots = await loadSnapshotApi();
|
|
7
|
+
|
|
8
|
+
async function loadSnapshotApi() {
|
|
9
|
+
const api = await import('@simplysf/simply-utam');
|
|
10
|
+
const names = [
|
|
11
|
+
'captureDomSnapshot',
|
|
12
|
+
'pruneDomSnapshots',
|
|
13
|
+
'serializeDomSnapshot',
|
|
14
|
+
'snapshotRunId',
|
|
15
|
+
'writeDomSnapshot',
|
|
16
|
+
];
|
|
17
|
+
return names.every((name) => typeof api[name] === 'function') ? api : undefined;
|
|
18
|
+
}
|
|
2
19
|
|
|
3
20
|
const { DEBUG } = process.env;
|
|
21
|
+
// How long element waits run before failing (waitforTimeout). DEBUG leaves it alone, so a wrong
|
|
22
|
+
// locator still fails within a minute instead of stalling the session you're debugging.
|
|
4
23
|
const EXPLICIT_TIMEOUT = 60 * 1000;
|
|
5
|
-
|
|
24
|
+
// How long a Cucumber step may run under DEBUG, so pausing in browser.debug() or at a breakpoint
|
|
25
|
+
// doesn't end the step while you're still inspecting the page.
|
|
26
|
+
const DEBUG_TIMEOUT = 30 * 60 * 1000;
|
|
27
|
+
// A step must outlast UTAM's waits, so a failure reports UTAM's error (which names the locator it
|
|
28
|
+
// couldn't find) rather than only Cucumber's timeout, and the DOM snapshot shows the page UTAM searched.
|
|
29
|
+
const STEP_TIMEOUT_MARGIN = 30 * 1000;
|
|
6
30
|
|
|
7
31
|
export const config = {
|
|
8
32
|
runner: 'local',
|
|
@@ -16,7 +40,7 @@ export const config = {
|
|
|
16
40
|
],
|
|
17
41
|
logLevel: 'debug',
|
|
18
42
|
bail: 0,
|
|
19
|
-
waitforTimeout:
|
|
43
|
+
waitforTimeout: EXPLICIT_TIMEOUT,
|
|
20
44
|
connectionRetryTimeout: 120000,
|
|
21
45
|
connectionRetryCount: 3,
|
|
22
46
|
automationProtocol: 'webdriver',
|
|
@@ -32,7 +56,7 @@ export const config = {
|
|
|
32
56
|
framework: 'cucumber',
|
|
33
57
|
cucumberOpts: {
|
|
34
58
|
require: ['{{sourceDir}}/**/test/*.steps.mjs', '{{sourceDir}}/**/test/**/*.steps.mjs'],
|
|
35
|
-
timeout:
|
|
59
|
+
timeout: (DEBUG ? DEBUG_TIMEOUT : EXPLICIT_TIMEOUT) + STEP_TIMEOUT_MARGIN,
|
|
36
60
|
},
|
|
37
61
|
reporters: [
|
|
38
62
|
'spec',
|
|
@@ -40,11 +64,39 @@ export const config = {
|
|
|
40
64
|
'allure',
|
|
41
65
|
{
|
|
42
66
|
outputDir: 'allure-results',
|
|
43
|
-
|
|
67
|
+
disableWebdriverScreenshotsReporting: false,
|
|
44
68
|
},
|
|
45
69
|
],
|
|
46
70
|
],
|
|
47
71
|
screenshotPath: './errorShots/',
|
|
72
|
+
onPrepare: async function () {
|
|
73
|
+
if (!snapshots) {
|
|
74
|
+
console.warn(
|
|
75
|
+
'The installed @simplysf/simply-utam has no DOM snapshots, so none are captured. Upgrade it in package.json to capture them.',
|
|
76
|
+
);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// One DOM snapshot folder per test run, shared by every worker.
|
|
80
|
+
process.env.UTAM_SNAPSHOT_RUN_ID ??= snapshots.snapshotRunId();
|
|
81
|
+
},
|
|
82
|
+
onComplete: async function () {
|
|
83
|
+
if (!snapshots) return;
|
|
84
|
+
// Keep the last 10 runs, this one included. Housekeeping must never cost the run: on Windows a
|
|
85
|
+
// locked old run folder can't be deleted.
|
|
86
|
+
try {
|
|
87
|
+
await snapshots.pruneDomSnapshots({ keepRuns: 10 });
|
|
88
|
+
} catch (pruneError) {
|
|
89
|
+
console.warn(`Old DOM snapshot runs not pruned: ${pruneError?.message ?? pruneError}`);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
before: async function () {
|
|
93
|
+
if (!snapshots) return;
|
|
94
|
+
// browser.domSnapshot('label') captures the page from the REPL during browser.debug().
|
|
95
|
+
browser.addCommand('domSnapshot', async (label) => {
|
|
96
|
+
const snapshot = await snapshots.captureDomSnapshot({ trigger: 'manual', label });
|
|
97
|
+
return snapshot ? snapshots.writeDomSnapshot(snapshot) : undefined;
|
|
98
|
+
});
|
|
99
|
+
},
|
|
48
100
|
afterTest: async function (test, context, { passed }) {
|
|
49
101
|
if (!passed) {
|
|
50
102
|
await browser.takeScreenshot();
|
|
@@ -52,6 +104,31 @@ export const config = {
|
|
|
52
104
|
},
|
|
53
105
|
afterStep: async function (step, scenario, { error }) {
|
|
54
106
|
if (error) {
|
|
107
|
+
// Capture the DOM snapshot first, before anything else changes the page.
|
|
108
|
+
const snapshot = await snapshots?.captureDomSnapshot({
|
|
109
|
+
trigger: 'failure',
|
|
110
|
+
scenario: scenario.name,
|
|
111
|
+
step: step.text,
|
|
112
|
+
error,
|
|
113
|
+
});
|
|
114
|
+
if (snapshot) {
|
|
115
|
+
// Saving and attaching each get their own try: neither failing may cost the other, or the
|
|
116
|
+
// screenshot below.
|
|
117
|
+
try {
|
|
118
|
+
console.log(`DOM snapshot written to ${await snapshots.writeDomSnapshot(snapshot)}`);
|
|
119
|
+
} catch (writeError) {
|
|
120
|
+
console.warn(`DOM snapshot not saved: ${writeError?.message ?? writeError}`);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
allureReporter.addAttachment(
|
|
124
|
+
'dom-snapshot.json',
|
|
125
|
+
snapshots.serializeDomSnapshot(snapshot),
|
|
126
|
+
'application/json',
|
|
127
|
+
);
|
|
128
|
+
} catch (attachError) {
|
|
129
|
+
console.warn(`DOM snapshot not attached to the Allure report: ${attachError?.message ?? attachError}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
55
132
|
await browser.takeScreenshot();
|
|
56
133
|
}
|
|
57
134
|
},
|