Skip to content

Commit

Permalink
Merge pull request #81 from joomcode/fix/use-one-start-e2ed-function
Browse files Browse the repository at this point in the history
fix: use one function for starting e2ed
  • Loading branch information
uid11 authored Jul 29, 2024
2 parents c87ebae + 37a63ce commit a366f22
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 210 deletions.
96 changes: 48 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"devDependencies": {
"@playwright/browser-chromium": "1.45.3",
"@types/node": "22.0.0",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"assert-modules-support-case-insensitive-fs": "1.0.1",
"assert-package-lock-is-consistent": "1.0.0",
"eslint": "8.57.0",
Expand All @@ -43,7 +43,7 @@
"eslint-plugin-import": "2.29.1",
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-typescript-sort-keys": "3.2.0",
"husky": "9.1.3",
"husky": "9.1.4",
"prettier": "3.3.3",
"typescript": "5.5.4"
},
Expand Down
2 changes: 1 addition & 1 deletion src/constants/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export {
} from './inspect';
export {LogEventStatus, LogEventType} from './log';
/** @internal */
export {MESSAGE_BACKGROUND_COLOR_BY_STATUS, TESTCAFE_WARNINGS_KEY} from './log';
export {MESSAGE_BACKGROUND_COLOR_BY_STATUS} from './log';
export {CREATE_PAGE_TOKEN} from './pages';
/** @internal */
export {
Expand Down
6 changes: 0 additions & 6 deletions src/constants/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ export const MESSAGE_BACKGROUND_COLOR_BY_STATUS: Readonly<
[TestRunStatus.Manual]: ConsoleBackgroundColor.YellowGreen,
[TestRunStatus.Broken]: ConsoleBackgroundColor.Yellow,
};

/**
* The symbolic key under which the global object can contain warnings from TestCafe.
* @internal
*/
export const TESTCAFE_WARNINGS_KEY = Symbol.for('testcafe-reporter-for-e2ed:testcafe-warnings');
1 change: 0 additions & 1 deletion src/types/retries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export type RetriesState = Readonly<{
* @internal
*/
export type RunRetryOptions = Readonly<{
concurrency: number;
runLabel: RunLabel;
successfulTestRunNamesHash: VisitedTestNamesHash;
visitedTestNamesHash: VisitedTestNamesHash;
Expand Down
3 changes: 1 addition & 2 deletions src/types/runLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type RunLabel = Brand<string, 'RunLabel'>;
*/
export type RunLabelObject = Readonly<{
concurrency: number;
disconnectedBrowsersCount: number;
maxRetriesCount: number;
retryIndex: number;
}>;
Expand All @@ -22,5 +21,5 @@ export type RunLabelObject = Readonly<{
* @internal
*/
export type RawRunLabelObject = {
[K in keyof RunLabelObject]: string;
[Key in keyof RunLabelObject]: string;
};
2 changes: 1 addition & 1 deletion src/utils/events/registerEndTestRunEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const registerEndTestRunEvent = async (endTestRunEvent: EndTestRunEvent):

const fullTestRun: FullTestRun = {mainParams, runHash, ...testRun};

logEndTestRunEvent(fullTestRun);
await logEndTestRunEvent(fullTestRun);

await writeTestRunToJsonFile(fullTestRun);
await writeLogsToFile();
Expand Down
20 changes: 14 additions & 6 deletions src/utils/fs/readEventsFromFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const readEventsFromFiles = async (
fileIndex < newEventFiles.length;
fileIndex += AMOUNT_OF_PARALLEL_OPEN_FILES
) {
const readPromises: Promise<string>[] = [];
const readPromises: Promise<Readonly<{fileName: string; text: string}>>[] = [];

for (
let index = fileIndex;
Expand All @@ -57,17 +57,25 @@ export const readEventsFromFiles = async (
});

const filePath = join(EVENTS_DIRECTORY_PATH, fileName);
const promise = readFile(filePath, READ_FILE_OPTIONS);
const promise = readFile(filePath, READ_FILE_OPTIONS).then((text) => ({fileName, text}));

readPromises.push(promise);
}

const files = await Promise.all(readPromises);
const filesWithNames = await Promise.all(readPromises);

for (const file of files) {
const fullTestRun = JSON.parse(file) as FullTestRun;
for (const {fileName, text} of filesWithNames) {
try {
const fullTestRun = JSON.parse(text) as FullTestRun;

fullTestRuns.push(fullTestRun);
fullTestRuns.push(fullTestRun);
} catch (error) {
generalLog('Caught an error on parsing JSON of test run', {
error,
fileName,
textLenght: text.length,
});
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/utils/generalLog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export {failMessage, okMessage} from './messages';
export {writeLogsToFile} from './logFile';
/** @internal */
export {logStartE2edError} from './logStartE2edError';
/** @internal */
export {readTestCafeWarnings} from './readTestCafeWarnings';
export {removeStyleFromString} from './removeStyleFromString';
/** @internal */
export {truncateArrayForLogs} from './truncateArrayForLogs';
/** @internal */
export {setSuccessfulTotalInPreviousRetries} from './successfulTestRunCount';
6 changes: 3 additions & 3 deletions src/utils/generalLog/logEndTestRunEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ import type {FullTestRun} from '../../types/internal';
* Logs an end of test run event.
* @internal
*/
export const logEndTestRunEvent = (fullTestRun: FullTestRun): void => {
export const logEndTestRunEvent = async (fullTestRun: FullTestRun): Promise<void> => {
const {filePath, mainParams, name, options, runError, runId, status} = fullTestRun;

if (FAILED_TEST_RUN_STATUSES.includes(status) === false) {
addSuccessfulInCurrentRetry();
await addSuccessfulInCurrentRetry(filePath);
}

const messageBackgroundColor = MESSAGE_BACKGROUND_COLOR_BY_STATUS[status];
const messageSymbol = TEST_RUN_STATUS_SYMBOLS[status];
const messageText = `${messageSymbol} ${status} ${mainParams} ${name}`;

const message = getMessageWithBackgroundColor(messageText, messageBackgroundColor);
const successful = getSuccessfulTestRunCount();
const successful = await getSuccessfulTestRunCount();

generalLog(message, {filePath, options, runError, runId, successful});
};
20 changes: 0 additions & 20 deletions src/utils/generalLog/readTestCafeWarnings.ts

This file was deleted.

Loading

0 comments on commit a366f22

Please sign in to comment.