-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathlogs.ts
More file actions
44 lines (35 loc) · 1.38 KB
/
logs.ts
File metadata and controls
44 lines (35 loc) · 1.38 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { HarnessPlatform } from '@react-native-harness/platforms';
import { HarnessError } from '@react-native-harness/tools';
import chalk from 'chalk';
const TAG = chalk.supportsColor
? chalk.reset.inverse.bold.magenta(` HARNESS `)
: 'HARNESS';
const ERROR_TAG = chalk.supportsColor
? chalk.reset.inverse.bold.red(` HARNESS `)
: 'HARNESS';
// @see https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/BaseReporter.ts#L25
export const log = (message: string): void => {
process.stderr.write(`${message}\n`);
};
export const logTestRunHeader = (runner: HarnessPlatform): void => {
log(
`${TAG} Preparing to run tests using ${chalk.bold(runner.name)} runner\n`
);
};
export const logTestEnvironmentReady = (runner: HarnessPlatform): void => {
log(`${TAG} Runner ${chalk.bold(runner.name)} ready\n`);
};
export const logMetroPrewarmCompleted = (runner: HarnessPlatform): void => {
log(
`${TAG} Metro pre-warm for ${chalk.bold(runner.name)} completed\n`
);
};
export const logMetroCacheReused = (runner: HarnessPlatform): void => {
log(`${TAG} Reusing Metro cache for ${chalk.bold(runner.name)}\n`);
};
export const logNativeCoverageCollected = (lcovPath: string): void => {
log(`${TAG} Native coverage written to ${chalk.bold(lcovPath)}\n`);
};
export const getErrorMessage = (error: HarnessError): string => {
return `${ERROR_TAG} ${error.message}\n`;
};