-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathafterErrorInTest.ts
More file actions
27 lines (21 loc) · 954 Bytes
/
afterErrorInTest.ts
File metadata and controls
27 lines (21 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// eslint-disable-next-line import/no-internal-modules
import {getBrowserConsoleMessages} from '../../actions/getBrowserConsoleMessages';
// eslint-disable-next-line import/no-internal-modules
import {getBrowserJsErrors} from '../../actions/getBrowserJsErrors';
import {AFTER_ERROR_IN_TEST_TIMEOUT_IN_MS} from '../../constants/internal';
import {addTimeoutToPromise} from '../promise';
import {takeScreenshotsOnErrorIfNeeded} from './takeScreenshotsOnErrorIfNeeded';
import type {TestStaticOptions} from '../../types/internal';
/**
* Internal "after error in test" hook.
* @internal
*/
export const afterErrorInTest = (testStaticOptions: TestStaticOptions): Promise<void> =>
addTimeoutToPromise(
(async () => {
getBrowserConsoleMessages({showMessagesInLog: true});
getBrowserJsErrors({showErrorsInLog: true});
await takeScreenshotsOnErrorIfNeeded(testStaticOptions);
})(),
AFTER_ERROR_IN_TEST_TIMEOUT_IN_MS,
);