Skip to content

Commit 2c158a9

Browse files
committed
TestLens - Nightwatch devtools
1 parent 0987af0 commit 2c158a9

5 files changed

Lines changed: 312 additions & 243 deletions

File tree

packages/nightwatch-devtools/src/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ export const NAVIGATION_COMMANDS = ['url', 'navigate', 'navigateTo'] as const
8686

8787
/** Spinner progress frames — suppress from UI Console output. */
8888
export const SPINNER_RE = /^[]/u
89+
90+
/** Matches a path segment that indicates a test/spec directory (e.g. /tests/ or /spec/). */
91+
export const TEST_PATH_PATTERN = /\/(test|spec|tests)\//i
92+
93+
/** Matches file names that follow the *.test.ts / *.spec.js naming convention. */
94+
export const TEST_FILE_PATTERN = /\.(?:test|spec)\.[cm]?[jt]sx?$/i

packages/nightwatch-devtools/src/helpers/suiteManager.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class SuiteManager {
2020
testFile: string,
2121
suiteTitle: string,
2222
fullPath: string | null,
23-
testNames: string[]
23+
testNames: string[],
24+
suiteLine?: number | null,
25+
testLines?: number[]
2426
): SuiteStats {
2527
if (!this.currentSuiteByFile.has(testFile)) {
2628
const suiteStats: SuiteStats = {
@@ -36,16 +38,19 @@ export class SuiteManager {
3638
tests: [],
3739
suites: [],
3840
hooks: [],
39-
_duration: DEFAULTS.DURATION
41+
_duration: DEFAULTS.DURATION,
42+
callSource:
43+
suiteLine && fullPath ? `${fullPath}:${suiteLine}` : undefined
4044
}
4145

4246
suiteStats.uid = generateStableUid(suiteStats.file, suiteStats.title)
4347

4448
// Create test entries with pending state
4549
if (testNames.length > 0) {
46-
for (const testName of testNames) {
50+
for (let idx = 0; idx < testNames.length; idx++) {
51+
const testName = testNames[idx]
52+
const testLine = testLines?.[idx]
4753
const fullTitle = `${suiteTitle} ${testName}`
48-
// Generate stable UID using same method as onTestStart
4954
const testUid = generateStableUid(fullPath || testFile, fullTitle)
5055
const testEntry: TestStats = {
5156
uid: testUid,
@@ -60,7 +65,9 @@ export class SuiteManager {
6065
file: fullPath || testFile,
6166
retries: DEFAULTS.RETRIES,
6267
_duration: DEFAULTS.DURATION,
63-
hooks: []
68+
hooks: [],
69+
callSource:
70+
testLine && fullPath ? `${fullPath}:${testLine}` : undefined
6471
}
6572
suiteStats.tests.push(testEntry)
6673
}

0 commit comments

Comments
 (0)