Skip to content

Commit 892b167

Browse files
committed
PRO-20047 fix: show global error on duplicate test file paths
1 parent 1b7ec18 commit 892b167

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

src/utils/generalLog/successfulTestRuns.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {join} from 'node:path';
33

44
import {READ_FILE_OPTIONS, TMP_DIRECTORY_PATH} from '../../constants/internal';
55

6-
import {assertValueIsFalse} from '../asserts';
6+
// eslint-disable-next-line import/no-internal-modules
7+
import {writeGlobalError} from '../fs/writeGlobalError';
78
import {isUiMode} from '../uiMode';
89

910
import type {FilePathFromRoot, TestFilePath} from '../../types/internal';
@@ -41,11 +42,11 @@ export const addSuccessfulTestRun = async (testFilePath: TestFilePath): Promise<
4142
return;
4243
}
4344

44-
assertValueIsFalse(
45-
successfulTestFilePaths.includes(testFilePath),
46-
'There is no duplicate test file path in successful test runs',
47-
{successfulTestFilePaths, testFilePath},
48-
);
49-
50-
await appendFile(SUCCESSFUL_TESTS_PATH, `${testFilePath}\n`);
45+
if (successfulTestFilePaths.includes(testFilePath)) {
46+
await writeGlobalError(
47+
`There is duplicate test file path in successful test runs: ${testFilePath}`,
48+
);
49+
} else {
50+
await appendFile(SUCCESSFUL_TESTS_PATH, `${testFilePath}\n`);
51+
}
5152
};

src/utils/report/assertThatTestNamesAndFilePathsAreUniqueInOneRetry.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {TestRunStatus} from '../../constants/internal';
22

33
import {assertValueIsFalse} from '../asserts';
44
import {cloneWithoutLogEvents} from '../clone';
5+
import {writeGlobalError} from '../fs';
56

67
import type {FullTestRun, TestFilePath} from '../../types/internal';
78

@@ -20,14 +21,22 @@ export const assertThatTestNamesAndFilePathsAreUniqueInOneRetry = (
2021
for (const fullTestRun of unbrokenTestRuns) {
2122
const {filePath, name} = fullTestRun;
2223

23-
assertValueIsFalse(
24-
filePath in filePathsHash,
25-
'filePath is unique: each test should be in a separate file',
26-
{
27-
firstFullTestRun: cloneWithoutLogEvents(filePathsHash[filePath] as FullTestRun),
28-
secondFullTestRun: cloneWithoutLogEvents(fullTestRun),
29-
},
30-
);
24+
if (filePath in filePathsHash) {
25+
const firstTestString = JSON.stringify({
26+
name: (filePathsHash[filePath] as FullTestRun).name,
27+
options: filePathsHash[filePath]?.options,
28+
});
29+
30+
const secondTestString = JSON.stringify({
31+
name: fullTestRun.name,
32+
options: fullTestRun.options,
33+
});
34+
35+
void writeGlobalError(
36+
`There are duplicate tests in one filePath (${filePath}): ${firstTestString}, ${secondTestString}`,
37+
);
38+
}
39+
3140
assertValueIsFalse(name in namesHash, 'name is unique: each test must have a unique name', {
3241
firstFullTestRun: cloneWithoutLogEvents(namesHash[name] as FullTestRun),
3342
secondFullTestRun: cloneWithoutLogEvents(fullTestRun),

0 commit comments

Comments
 (0)