@wdio/nightwatch-devtools 1.0.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.
- package/README.md +127 -0
- package/dist/constants.d.ts +57 -0
- package/dist/constants.js +97 -0
- package/dist/constants.js.map +1 -0
- package/dist/helpers/browserProxy.d.ts +46 -0
- package/dist/helpers/browserProxy.js +314 -0
- package/dist/helpers/browserProxy.js.map +1 -0
- package/dist/helpers/capturePerformance.d.ts +5 -0
- package/dist/helpers/capturePerformance.js +53 -0
- package/dist/helpers/capturePerformance.js.map +1 -0
- package/dist/helpers/cucumberHooks.cjs +54 -0
- package/dist/helpers/cucumberHooks.cjs.map +1 -0
- package/dist/helpers/cucumberHooks.d.cts +21 -0
- package/dist/helpers/suiteManager.d.ts +43 -0
- package/dist/helpers/suiteManager.js +143 -0
- package/dist/helpers/suiteManager.js.map +1 -0
- package/dist/helpers/testManager.d.ts +45 -0
- package/dist/helpers/testManager.js +143 -0
- package/dist/helpers/testManager.js.map +1 -0
- package/dist/helpers/utils.d.ts +83 -0
- package/dist/helpers/utils.js +442 -0
- package/dist/helpers/utils.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +796 -0
- package/dist/index.js.map +1 -0
- package/dist/reporter.d.ts +44 -0
- package/dist/reporter.js +185 -0
- package/dist/reporter.js.map +1 -0
- package/dist/session.d.ts +78 -0
- package/dist/session.js +643 -0
- package/dist/session.js.map +1 -0
- package/dist/types.d.ts +190 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as net from 'node:net';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { parse as parseStackTrace } from 'stacktrace-parser';
|
|
5
|
+
import logger from '@wdio/logger';
|
|
6
|
+
import { ANSI_REGEX, LOG_LEVEL_PATTERNS, TEST_PATH_PATTERN, TEST_FILE_PATTERN, CONFIG_FILENAMES } from '../constants.js';
|
|
7
|
+
export function determineTestState(testcase) {
|
|
8
|
+
if (testcase.passed === 0 && testcase.failed === 0) {
|
|
9
|
+
return 'skipped';
|
|
10
|
+
}
|
|
11
|
+
return testcase.passed > 0 && testcase.failed === 0 ? 'passed' : 'failed';
|
|
12
|
+
}
|
|
13
|
+
// Track test occurrences to generate stable UIDs
|
|
14
|
+
const signatureCounters = new Map();
|
|
15
|
+
/**
|
|
16
|
+
* Generate stable UID for test/suite.
|
|
17
|
+
* Accepts either (item: SuiteStats | TestStats) or (file: string, name: string).
|
|
18
|
+
*/
|
|
19
|
+
export function generateStableUid(itemOrFile, name) {
|
|
20
|
+
let file, testName;
|
|
21
|
+
if (typeof itemOrFile === 'object' &&
|
|
22
|
+
itemOrFile !== null &&
|
|
23
|
+
name === undefined) {
|
|
24
|
+
file = itemOrFile.file || '';
|
|
25
|
+
testName = String(itemOrFile.fullTitle || itemOrFile.title);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
file = itemOrFile || '';
|
|
29
|
+
testName = String(name || '');
|
|
30
|
+
}
|
|
31
|
+
const signature = `${file}::${testName}`;
|
|
32
|
+
const count = signatureCounters.get(signature) || 0;
|
|
33
|
+
signatureCounters.set(signature, count + 1);
|
|
34
|
+
const hashInput = count > 0 ? `${signature}::${count}` : signature;
|
|
35
|
+
const hash = hashInput
|
|
36
|
+
.split('')
|
|
37
|
+
.reduce((acc, char) => ((acc << 5) - acc + char.charCodeAt(0)) | 0, 0);
|
|
38
|
+
return `stable-${Math.abs(hash).toString(36)}`;
|
|
39
|
+
}
|
|
40
|
+
/** Reset counters at the start of each test run. */
|
|
41
|
+
export function resetSignatureCounters() {
|
|
42
|
+
signatureCounters.clear();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compute a purely deterministic UID from arbitrary string parts.
|
|
46
|
+
* Unlike generateStableUid this NEVER uses the signature counter, so calling
|
|
47
|
+
* it multiple times with the same inputs always returns the same value.
|
|
48
|
+
* Use this wherever the same entity (e.g. a Cucumber scenario) must map to
|
|
49
|
+
* the same UID across retries.
|
|
50
|
+
*/
|
|
51
|
+
export function deterministicUid(...parts) {
|
|
52
|
+
const hash = parts
|
|
53
|
+
.join('::')
|
|
54
|
+
.split('')
|
|
55
|
+
.reduce((acc, char) => ((acc << 5) - acc + char.charCodeAt(0)) | 0, 0);
|
|
56
|
+
return `stable-${Math.abs(hash).toString(36)}`;
|
|
57
|
+
}
|
|
58
|
+
/** Returns true if a stack frame belongs to user code (not dependencies, internals, or build output). */
|
|
59
|
+
function isUserCodeFrame(frame) {
|
|
60
|
+
const { file } = frame;
|
|
61
|
+
return !!(file &&
|
|
62
|
+
!file.includes('/node_modules/') &&
|
|
63
|
+
!file.includes('<anonymous>') &&
|
|
64
|
+
!file.includes('node:internal') &&
|
|
65
|
+
!file.includes('/dist/') &&
|
|
66
|
+
!file.includes('/index.js'));
|
|
67
|
+
}
|
|
68
|
+
/** Strips the file:// protocol and any trailing :line:col suffix from a file path. */
|
|
69
|
+
function normalizeFilePath(filePath) {
|
|
70
|
+
return filePath.replace(/^file:\/\//, '').split(':')[0];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Find test file from stack trace.
|
|
74
|
+
* Parses call stack to find the first frame that looks like a test file.
|
|
75
|
+
*/
|
|
76
|
+
export function findTestFileFromStack() {
|
|
77
|
+
const stack = new Error().stack;
|
|
78
|
+
if (!stack) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const frame = parseStackTrace(stack).find((f) => isUserCodeFrame(f) &&
|
|
82
|
+
(TEST_PATH_PATTERN.test(f.file) || TEST_FILE_PATTERN.test(f.file)));
|
|
83
|
+
if (!frame?.file) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const filePath = normalizeFilePath(frame.file);
|
|
87
|
+
return fs.existsSync(filePath) ? filePath : undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Extract suite and test names — and their line numbers — from a test file.
|
|
91
|
+
* Returns a TestFileMetadata object used to build `callSource` strings for
|
|
92
|
+
* the TestLens eye-icon navigation.
|
|
93
|
+
*/
|
|
94
|
+
export function extractTestMetadata(filePath) {
|
|
95
|
+
const result = {
|
|
96
|
+
suiteTitle: null,
|
|
97
|
+
suiteLine: null,
|
|
98
|
+
testNames: [],
|
|
99
|
+
testLines: []
|
|
100
|
+
};
|
|
101
|
+
if (!fs.existsSync(filePath)) {
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const lines = fs.readFileSync(filePath, 'utf-8').split('\n');
|
|
106
|
+
for (let i = 0; i < lines.length; i++) {
|
|
107
|
+
const line = lines[i];
|
|
108
|
+
const lineNum = i + 1;
|
|
109
|
+
if (result.suiteTitle === null) {
|
|
110
|
+
const m = line.match(/(?:describe|suite|context)\s*\(\s*['"`]([^'"`]+)['"`]/);
|
|
111
|
+
if (m) {
|
|
112
|
+
result.suiteTitle = m[1];
|
|
113
|
+
result.suiteLine = lineNum;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// describe/it style: it('name', ...) / test('name', ...) / specify('name', ...)
|
|
117
|
+
const itMatch = line.match(/(?:it|test|specify)\s*\(\s*['"`]([^'"`]+)['"`]/);
|
|
118
|
+
if (itMatch) {
|
|
119
|
+
result.testNames.push(itMatch[1]);
|
|
120
|
+
result.testLines.push(lineNum);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
// Object-export style (NightwatchTests): 'Test name': () => { / 'Test name': function() {
|
|
124
|
+
// This is the default format generated by `npx nightwatch --yes`
|
|
125
|
+
const objMatch = line.match(/^\s*['"`]([^'"`]+)['"`]\s*:\s*(?:async\s+)?(?:\([^)]*\)\s*=>|function\s*\()/);
|
|
126
|
+
if (objMatch) {
|
|
127
|
+
result.testNames.push(objMatch[1]);
|
|
128
|
+
result.testLines.push(lineNum);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// skip unparseable files
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get call source info from stack trace.
|
|
139
|
+
* Returns { filePath, callSource } where callSource has the filename:line format.
|
|
140
|
+
*/
|
|
141
|
+
export function getCallSourceFromStack() {
|
|
142
|
+
const stack = new Error().stack;
|
|
143
|
+
if (!stack) {
|
|
144
|
+
return { filePath: undefined, callSource: 'unknown:0' };
|
|
145
|
+
}
|
|
146
|
+
const frame = parseStackTrace(stack).find(isUserCodeFrame);
|
|
147
|
+
if (!frame?.file) {
|
|
148
|
+
return { filePath: undefined, callSource: 'unknown:0' };
|
|
149
|
+
}
|
|
150
|
+
const filePath = normalizeFilePath(frame.file);
|
|
151
|
+
return { filePath, callSource: `${filePath}:${frame.lineNumber ?? 0}` };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Find test file by searching the workspace for a matching filename.
|
|
155
|
+
* Used when the stack trace doesn't have the file yet (e.g. in beforeEach).
|
|
156
|
+
*/
|
|
157
|
+
export function findTestFileByName(filename, workspaceRoot) {
|
|
158
|
+
if (!filename || !workspaceRoot) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
const baseFilename = filename.replace(/\.[cm]?[jt]sx?$/, '');
|
|
162
|
+
function searchDir(dir, depth = 0) {
|
|
163
|
+
if (depth > 5) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
168
|
+
const fullPath = path.join(dir, entry.name);
|
|
169
|
+
if (entry.isDirectory()) {
|
|
170
|
+
const found = searchDir(fullPath, depth + 1);
|
|
171
|
+
if (found) {
|
|
172
|
+
return found;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else if (TEST_FILE_PATTERN.test(entry.name) &&
|
|
176
|
+
entry.name.replace(TEST_FILE_PATTERN, '') === baseFilename) {
|
|
177
|
+
return fullPath;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Permission denied or other error — skip
|
|
183
|
+
}
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
return searchDir(workspaceRoot);
|
|
187
|
+
}
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
// Console / log helpers (used by SessionCapturer)
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
/**
|
|
192
|
+
* Strip ANSI escape codes from a string.
|
|
193
|
+
*/
|
|
194
|
+
export const stripAnsiCodes = (text) => text.replace(ANSI_REGEX, '');
|
|
195
|
+
/** Infer a log level from the text content of a line. */
|
|
196
|
+
export function detectLogLevel(text) {
|
|
197
|
+
const normalised = stripAnsiCodes(text).toLowerCase();
|
|
198
|
+
for (const { level, pattern } of LOG_LEVEL_PATTERNS) {
|
|
199
|
+
if (pattern.test(normalised)) {
|
|
200
|
+
return level;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return 'log';
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Build a ConsoleLog entry.
|
|
207
|
+
*/
|
|
208
|
+
export function createConsoleLogEntry(type, args, source) {
|
|
209
|
+
return { timestamp: Date.now(), type, args, source };
|
|
210
|
+
}
|
|
211
|
+
/** Map a Chrome DevTools log level string to our LogLevel union. */
|
|
212
|
+
export function chromeLogLevelToLogLevel(level) {
|
|
213
|
+
const levelName = (typeof level === 'object' ? (level?.name ?? '') : (level ?? '')).toUpperCase();
|
|
214
|
+
switch (levelName) {
|
|
215
|
+
case 'SEVERE':
|
|
216
|
+
return 'error';
|
|
217
|
+
case 'WARNING':
|
|
218
|
+
return 'warn';
|
|
219
|
+
case 'INFO':
|
|
220
|
+
return 'info';
|
|
221
|
+
case 'DEBUG':
|
|
222
|
+
return 'debug';
|
|
223
|
+
default:
|
|
224
|
+
return 'log';
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** Derive a human-readable request type from URL and MIME type. */
|
|
228
|
+
export function getRequestType(url, mimeType) {
|
|
229
|
+
const contentType = mimeType?.toLowerCase() ?? '';
|
|
230
|
+
const urlLower = url.toLowerCase();
|
|
231
|
+
if (contentType.includes('text/html')) {
|
|
232
|
+
return 'document';
|
|
233
|
+
}
|
|
234
|
+
if (contentType.includes('text/css')) {
|
|
235
|
+
return 'stylesheet';
|
|
236
|
+
}
|
|
237
|
+
if (contentType.includes('javascript') ||
|
|
238
|
+
contentType.includes('ecmascript')) {
|
|
239
|
+
return 'script';
|
|
240
|
+
}
|
|
241
|
+
if (contentType.includes('image/')) {
|
|
242
|
+
return 'image';
|
|
243
|
+
}
|
|
244
|
+
if (contentType.includes('font/') || contentType.includes('woff')) {
|
|
245
|
+
return 'font';
|
|
246
|
+
}
|
|
247
|
+
if (contentType.includes('application/json')) {
|
|
248
|
+
return 'fetch';
|
|
249
|
+
}
|
|
250
|
+
if (urlLower.endsWith('.html') || urlLower.endsWith('.htm')) {
|
|
251
|
+
return 'document';
|
|
252
|
+
}
|
|
253
|
+
if (urlLower.endsWith('.css')) {
|
|
254
|
+
return 'stylesheet';
|
|
255
|
+
}
|
|
256
|
+
if (urlLower.endsWith('.js') || urlLower.endsWith('.mjs')) {
|
|
257
|
+
return 'script';
|
|
258
|
+
}
|
|
259
|
+
if (/\.(png|jpg|jpeg|gif|svg|webp|ico)$/.test(urlLower)) {
|
|
260
|
+
return 'image';
|
|
261
|
+
}
|
|
262
|
+
if (/\.(woff|woff2|ttf|eot|otf)$/.test(urlLower)) {
|
|
263
|
+
return 'font';
|
|
264
|
+
}
|
|
265
|
+
return 'xhr';
|
|
266
|
+
}
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
// Cucumber helpers
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
/**
|
|
271
|
+
* Parse a feature file for a given scenario in a single pass, returning:
|
|
272
|
+
* - `featureLine` — 1-based line of the `Feature:` declaration
|
|
273
|
+
* - `scenarioLine` — 1-based line of the matching `Scenario:` block
|
|
274
|
+
* - `stepLines` — 1-based line numbers for each step (for TestLens navigation)
|
|
275
|
+
* - `stepKeywords` — BDD keyword (Given/When/Then/And/But) for each step (for labels)
|
|
276
|
+
*/
|
|
277
|
+
export function parseCucumberScenario(featureContent, scenarioName, stepTexts) {
|
|
278
|
+
const stepCount = stepTexts.length;
|
|
279
|
+
if (!featureContent) {
|
|
280
|
+
return {
|
|
281
|
+
featureLine: 1,
|
|
282
|
+
scenarioLine: 1,
|
|
283
|
+
stepLines: [],
|
|
284
|
+
stepKeywords: Array(stepCount).fill('')
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
const lines = featureContent.split('\n');
|
|
288
|
+
const stepRe = /^\s*(Given|When|Then|And|But)\s+/i;
|
|
289
|
+
let featureLine = 1;
|
|
290
|
+
let scenarioLine = 1;
|
|
291
|
+
const stepLines = [];
|
|
292
|
+
const stepKeywords = [];
|
|
293
|
+
for (let i = 0; i < lines.length; i++) {
|
|
294
|
+
const line = lines[i];
|
|
295
|
+
const lineNum = i + 1;
|
|
296
|
+
if (featureLine === 1 && /^\s*Feature:/i.test(line)) {
|
|
297
|
+
featureLine = lineNum;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (/^\s*Scenario:/i.test(line) && line.includes(scenarioName)) {
|
|
301
|
+
scenarioLine = lineNum;
|
|
302
|
+
for (let j = i + 1; j < lines.length && stepLines.length < stepCount; j++) {
|
|
303
|
+
if (/^\s*(?:Scenario:|Feature:)/i.test(lines[j])) {
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
const m = stepRe.exec(lines[j]);
|
|
307
|
+
if (m) {
|
|
308
|
+
stepLines.push(j + 1);
|
|
309
|
+
stepKeywords.push(m[1]);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
while (stepKeywords.length < stepCount) {
|
|
316
|
+
stepKeywords.push('');
|
|
317
|
+
}
|
|
318
|
+
return { featureLine, scenarioLine, stepLines, stepKeywords };
|
|
319
|
+
}
|
|
320
|
+
/** Maps Cucumber parameter type placeholder names to their regex equivalents. */
|
|
321
|
+
const CUCUMBER_TYPE_PATTERNS = {
|
|
322
|
+
int: '-?\\d+',
|
|
323
|
+
float: '-?\\d+(?:\\.\\d+)?',
|
|
324
|
+
string: '(?:"[^"]*"|\'[^\']*\')',
|
|
325
|
+
word: '\\S+'
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Convert a Cucumber expression pattern to a regular expression and test it
|
|
329
|
+
* against the given step text. Handles {int}, {float}, {string}, {word}, and
|
|
330
|
+
* arbitrary {type} placeholders.
|
|
331
|
+
*/
|
|
332
|
+
function matchesCucumberExpression(pattern, text) {
|
|
333
|
+
if (pattern === text) {
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
const regexSource = pattern
|
|
337
|
+
.split(/(\{[^}]*\})/)
|
|
338
|
+
.map((part, idx) => {
|
|
339
|
+
if (idx % 2 === 1) {
|
|
340
|
+
const type = part.slice(1, -1);
|
|
341
|
+
return CUCUMBER_TYPE_PATTERNS[type] ?? '[\\s\\S]+';
|
|
342
|
+
}
|
|
343
|
+
return part.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
|
|
344
|
+
})
|
|
345
|
+
.join('');
|
|
346
|
+
try {
|
|
347
|
+
return new RegExp(`^${regexSource}$`).test(text);
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Find the file and 1-based line number of the step definition that matches
|
|
355
|
+
* the given step text. Searches the provided step definition files in order.
|
|
356
|
+
* Handles both string/Cucumber-expression patterns and regex literals.
|
|
357
|
+
*/
|
|
358
|
+
export function findStepDefinitionLine(stepDefFiles, stepText) {
|
|
359
|
+
const stepDefRe = /(?:Given|When|Then|And|But)\s*\(/i;
|
|
360
|
+
for (const { filePath, content } of stepDefFiles) {
|
|
361
|
+
const lines = content.split('\n');
|
|
362
|
+
for (let i = 0; i < lines.length; i++) {
|
|
363
|
+
const line = lines[i];
|
|
364
|
+
if (!stepDefRe.test(line)) {
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
// String / Cucumber-expression: Given('pattern', ...) or Given("pattern", ...)
|
|
368
|
+
const literalMatch = line.match(/(?:Given|When|Then|And|But)\s*\(\s*(['"`])(.*?)\1/i);
|
|
369
|
+
if (literalMatch) {
|
|
370
|
+
if (matchesCucumberExpression(literalMatch[2], stepText)) {
|
|
371
|
+
return { filePath, line: i + 1 };
|
|
372
|
+
}
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
// Regex literal: Given(/pattern/flags, ...)
|
|
376
|
+
const regexMatch = line.match(/(?:Given|When|Then|And|But)\s*\(\s*\/(.+?)\/([gimy]*)/i);
|
|
377
|
+
if (regexMatch) {
|
|
378
|
+
try {
|
|
379
|
+
if (new RegExp(regexMatch[1], regexMatch[2]).test(stepText)) {
|
|
380
|
+
return { filePath, line: i + 1 };
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
// invalid regex — skip
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
// ---------------------------------------------------------------------------
|
|
392
|
+
// Port / network helpers (used by the plugin startup)
|
|
393
|
+
// ---------------------------------------------------------------------------
|
|
394
|
+
const log = logger('@wdio/nightwatch-devtools');
|
|
395
|
+
export function isPortInUse(port, hostname) {
|
|
396
|
+
return new Promise((resolve) => {
|
|
397
|
+
const server = net.createServer();
|
|
398
|
+
server.once('error', () => resolve(true));
|
|
399
|
+
server.once('listening', () => server.close(() => resolve(false)));
|
|
400
|
+
server.listen(port, hostname);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
export async function findFreePort(startPort, hostname) {
|
|
404
|
+
let port = startPort;
|
|
405
|
+
while (await isPortInUse(port, hostname)) {
|
|
406
|
+
log.warn(`Port ${port} is in use, trying ${port + 1}...`);
|
|
407
|
+
port++;
|
|
408
|
+
}
|
|
409
|
+
return port;
|
|
410
|
+
}
|
|
411
|
+
export function resolveNightwatchConfig() {
|
|
412
|
+
// Prefer the config explicitly passed via -c / --config to avoid picking up
|
|
413
|
+
// an unrelated config file that happens to sit higher in the directory tree.
|
|
414
|
+
const configFlagIdx = process.argv.findIndex((arg) => arg === '--config' || arg === '-c');
|
|
415
|
+
if (configFlagIdx !== -1 && process.argv[configFlagIdx + 1]) {
|
|
416
|
+
const argvConfig = process.argv[configFlagIdx + 1];
|
|
417
|
+
const resolved = path.isAbsolute(argvConfig)
|
|
418
|
+
? argvConfig
|
|
419
|
+
: path.resolve(process.cwd(), argvConfig);
|
|
420
|
+
if (fs.existsSync(resolved)) {
|
|
421
|
+
return resolved;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// Fallback: walk up the directory tree
|
|
425
|
+
let dir = process.cwd();
|
|
426
|
+
const root = path.parse(dir).root;
|
|
427
|
+
while (dir && dir !== root) {
|
|
428
|
+
for (const file of CONFIG_FILENAMES) {
|
|
429
|
+
const candidate = path.join(dir, file);
|
|
430
|
+
if (fs.existsSync(candidate)) {
|
|
431
|
+
return candidate;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const parent = path.dirname(dir);
|
|
435
|
+
if (parent === dir) {
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
dir = parent;
|
|
439
|
+
}
|
|
440
|
+
return undefined;
|
|
441
|
+
}
|
|
442
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/helpers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,S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ED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nightwatch DevTools Plugin
|
|
3
|
+
*
|
|
4
|
+
* Integrates Nightwatch with WebdriverIO DevTools following the WDIO service pattern.
|
|
5
|
+
* Captures commands, network requests, and console logs during test execution in real-time.
|
|
6
|
+
*/
|
|
7
|
+
import { type DevToolsOptions, type NightwatchBrowser } from './types.js';
|
|
8
|
+
declare class NightwatchDevToolsPlugin {
|
|
9
|
+
#private;
|
|
10
|
+
private options;
|
|
11
|
+
private sessionCapturer;
|
|
12
|
+
private testReporter;
|
|
13
|
+
private testManager;
|
|
14
|
+
private suiteManager;
|
|
15
|
+
private browserProxy;
|
|
16
|
+
private isScriptInjected;
|
|
17
|
+
constructor(options?: DevToolsOptions);
|
|
18
|
+
before(): Promise<void>;
|
|
19
|
+
cucumberBefore(browser: NightwatchBrowser, pickle: any): Promise<void>;
|
|
20
|
+
cucumberAfter(browser: NightwatchBrowser, result: any, pickle: any): Promise<void>;
|
|
21
|
+
/** Called from Cucumber BeforeStep hook — marks the step as running. */
|
|
22
|
+
cucumberBeforeStep(browser: NightwatchBrowser, pickleStep: any, _pickle: any): Promise<void>;
|
|
23
|
+
/** Called from Cucumber AfterStep hook — records the step result. */
|
|
24
|
+
cucumberAfterStep(_browser: NightwatchBrowser, result: any, pickleStep: any, _pickle: any): Promise<void>;
|
|
25
|
+
beforeEach(browser: NightwatchBrowser): Promise<void>;
|
|
26
|
+
afterEach(browser: NightwatchBrowser): Promise<void>;
|
|
27
|
+
after(browser?: NightwatchBrowser): Promise<void>;
|
|
28
|
+
registerEventHandlers(eventHub: any): void;
|
|
29
|
+
}
|
|
30
|
+
export declare const cucumberHooksPath: string;
|
|
31
|
+
export default function createNightwatchDevTools(options?: DevToolsOptions): {
|
|
32
|
+
asyncHookTimeout: number;
|
|
33
|
+
before: (this: any) => Promise<void>;
|
|
34
|
+
beforeEach: (this: any, browser: NightwatchBrowser) => Promise<void>;
|
|
35
|
+
afterEach: (this: any, browser: NightwatchBrowser) => Promise<void>;
|
|
36
|
+
after: (this: any) => Promise<void>;
|
|
37
|
+
registerEventHandlers: (eventHub: any) => void;
|
|
38
|
+
};
|
|
39
|
+
export { NightwatchDevToolsPlugin };
|