@react-native-harness/jest 1.0.0-alpha.22 → 1.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/client-log-handler.test.d.ts +2 -0
- package/dist/__tests__/client-log-handler.test.d.ts.map +1 -0
- package/dist/__tests__/client-log-handler.test.js +262 -0
- package/dist/client-log-handler.d.ts +23 -0
- package/dist/client-log-handler.d.ts.map +1 -0
- package/dist/client-log-handler.js +84 -0
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +9 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +3 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/eslint.config.mjs +5 -2
- package/package.json +6 -6
- package/src/__tests__/client-log-handler.test.ts +328 -0
- package/src/client-log-handler.ts +101 -0
- package/src/harness.ts +11 -0
- package/src/setup.ts +4 -0
- package/vite.config.ts +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-log-handler.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/client-log-handler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { formatClientLogMessage, formatClientLogLine, handleClientLogEvent, createClientLogListener, } from '../client-log-handler.js';
|
|
3
|
+
// Mock the log function
|
|
4
|
+
vi.mock('../logs.js', () => ({
|
|
5
|
+
log: vi.fn(),
|
|
6
|
+
}));
|
|
7
|
+
import { log } from '../logs.js';
|
|
8
|
+
describe('client-log-handler', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
vi.clearAllMocks();
|
|
11
|
+
});
|
|
12
|
+
describe('formatClientLogMessage', () => {
|
|
13
|
+
it('should format a single string', () => {
|
|
14
|
+
const result = formatClientLogMessage(['Hello, world!']);
|
|
15
|
+
expect(result).toBe('Hello, world!');
|
|
16
|
+
});
|
|
17
|
+
it('should join multiple strings with spaces', () => {
|
|
18
|
+
const result = formatClientLogMessage(['Hello', 'world', '!']);
|
|
19
|
+
expect(result).toBe('Hello world !');
|
|
20
|
+
});
|
|
21
|
+
it('should format objects', () => {
|
|
22
|
+
const result = formatClientLogMessage([{ key: 'value' }]);
|
|
23
|
+
// util.format uses inspect-style output for objects
|
|
24
|
+
expect(result).toContain('key');
|
|
25
|
+
expect(result).toContain('value');
|
|
26
|
+
});
|
|
27
|
+
it('should format arrays', () => {
|
|
28
|
+
const result = formatClientLogMessage([[1, 2, 3]]);
|
|
29
|
+
expect(result).toContain('1');
|
|
30
|
+
expect(result).toContain('2');
|
|
31
|
+
expect(result).toContain('3');
|
|
32
|
+
});
|
|
33
|
+
it('should handle mixed types', () => {
|
|
34
|
+
const result = formatClientLogMessage([
|
|
35
|
+
'Message:',
|
|
36
|
+
{ count: 42 },
|
|
37
|
+
'items',
|
|
38
|
+
]);
|
|
39
|
+
expect(result).toContain('Message:');
|
|
40
|
+
expect(result).toContain('count');
|
|
41
|
+
expect(result).toContain('42');
|
|
42
|
+
expect(result).toContain('items');
|
|
43
|
+
});
|
|
44
|
+
it('should format numbers', () => {
|
|
45
|
+
const result = formatClientLogMessage([123, 456]);
|
|
46
|
+
expect(result).toBe('123 456');
|
|
47
|
+
});
|
|
48
|
+
it('should format booleans', () => {
|
|
49
|
+
const result = formatClientLogMessage([true, false]);
|
|
50
|
+
expect(result).toBe('true false');
|
|
51
|
+
});
|
|
52
|
+
it('should format null and undefined', () => {
|
|
53
|
+
const result = formatClientLogMessage([null, undefined]);
|
|
54
|
+
expect(result).toBe('null undefined');
|
|
55
|
+
});
|
|
56
|
+
it('should handle empty array', () => {
|
|
57
|
+
const result = formatClientLogMessage([]);
|
|
58
|
+
expect(result).toBe('');
|
|
59
|
+
});
|
|
60
|
+
describe('printf-style format specifiers', () => {
|
|
61
|
+
it('should handle %s string substitution', () => {
|
|
62
|
+
const result = formatClientLogMessage(['%s world', 'hello']);
|
|
63
|
+
expect(result).toBe('hello world');
|
|
64
|
+
});
|
|
65
|
+
it('should handle %d integer substitution', () => {
|
|
66
|
+
const result = formatClientLogMessage(['Count: %d', 42]);
|
|
67
|
+
expect(result).toBe('Count: 42');
|
|
68
|
+
});
|
|
69
|
+
it('should handle %i integer substitution', () => {
|
|
70
|
+
const result = formatClientLogMessage(['Value: %i', 123]);
|
|
71
|
+
expect(result).toBe('Value: 123');
|
|
72
|
+
});
|
|
73
|
+
it('should handle %f float substitution', () => {
|
|
74
|
+
const result = formatClientLogMessage(['Pi: %f', 3.14159]);
|
|
75
|
+
expect(result).toContain('3.14159');
|
|
76
|
+
});
|
|
77
|
+
it('should handle multiple substitutions', () => {
|
|
78
|
+
const result = formatClientLogMessage(['Hello %s, you have %d messages', 'Alice', 5]);
|
|
79
|
+
expect(result).toBe('Hello Alice, you have 5 messages');
|
|
80
|
+
});
|
|
81
|
+
it('should handle %j JSON substitution', () => {
|
|
82
|
+
const result = formatClientLogMessage(['Data: %j', { key: 'value' }]);
|
|
83
|
+
expect(result).toBe('Data: {"key":"value"}');
|
|
84
|
+
});
|
|
85
|
+
it('should handle %o object substitution', () => {
|
|
86
|
+
const result = formatClientLogMessage(['Object: %o', { a: 1 }]);
|
|
87
|
+
// %o produces inspect-style output, just check it contains the key
|
|
88
|
+
expect(result).toContain('a');
|
|
89
|
+
});
|
|
90
|
+
it('should handle %% as literal percent when substituting', () => {
|
|
91
|
+
// %% is only converted to % when there are substitutions
|
|
92
|
+
const result = formatClientLogMessage(['%s is 100%% complete', 'Task']);
|
|
93
|
+
expect(result).toBe('Task is 100% complete');
|
|
94
|
+
});
|
|
95
|
+
it('should append extra arguments after substitution', () => {
|
|
96
|
+
const result = formatClientLogMessage(['Hello %s', 'world', 'extra', 'args']);
|
|
97
|
+
expect(result).toBe('Hello world extra args');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('formatClientLogLine', () => {
|
|
102
|
+
it('should format log level event', () => {
|
|
103
|
+
const event = {
|
|
104
|
+
type: 'client_log',
|
|
105
|
+
level: 'log',
|
|
106
|
+
data: ['Test message'],
|
|
107
|
+
};
|
|
108
|
+
const result = formatClientLogLine(event);
|
|
109
|
+
// The result will contain ANSI codes for styling, so we check it contains the message
|
|
110
|
+
expect(result).toContain('Test message');
|
|
111
|
+
});
|
|
112
|
+
it('should format error level event', () => {
|
|
113
|
+
const event = {
|
|
114
|
+
type: 'client_log',
|
|
115
|
+
level: 'error',
|
|
116
|
+
data: ['Error occurred'],
|
|
117
|
+
};
|
|
118
|
+
const result = formatClientLogLine(event);
|
|
119
|
+
expect(result).toContain('Error occurred');
|
|
120
|
+
});
|
|
121
|
+
it('should format warn level event', () => {
|
|
122
|
+
const event = {
|
|
123
|
+
type: 'client_log',
|
|
124
|
+
level: 'warn',
|
|
125
|
+
data: ['Warning message'],
|
|
126
|
+
};
|
|
127
|
+
const result = formatClientLogLine(event);
|
|
128
|
+
expect(result).toContain('Warning message');
|
|
129
|
+
});
|
|
130
|
+
it('should format info level event', () => {
|
|
131
|
+
const event = {
|
|
132
|
+
type: 'client_log',
|
|
133
|
+
level: 'info',
|
|
134
|
+
data: ['Info message'],
|
|
135
|
+
};
|
|
136
|
+
const result = formatClientLogLine(event);
|
|
137
|
+
expect(result).toContain('Info message');
|
|
138
|
+
});
|
|
139
|
+
it('should format debug level event', () => {
|
|
140
|
+
const event = {
|
|
141
|
+
type: 'client_log',
|
|
142
|
+
level: 'debug',
|
|
143
|
+
data: ['Debug message'],
|
|
144
|
+
};
|
|
145
|
+
const result = formatClientLogLine(event);
|
|
146
|
+
expect(result).toContain('Debug message');
|
|
147
|
+
});
|
|
148
|
+
it('should format trace level event', () => {
|
|
149
|
+
const event = {
|
|
150
|
+
type: 'client_log',
|
|
151
|
+
level: 'trace',
|
|
152
|
+
data: ['Trace message'],
|
|
153
|
+
};
|
|
154
|
+
const result = formatClientLogLine(event);
|
|
155
|
+
expect(result).toContain('Trace message');
|
|
156
|
+
});
|
|
157
|
+
it('should handle multiple data items', () => {
|
|
158
|
+
const event = {
|
|
159
|
+
type: 'client_log',
|
|
160
|
+
level: 'log',
|
|
161
|
+
data: ['User:', { id: 1, name: 'Test' }],
|
|
162
|
+
};
|
|
163
|
+
const result = formatClientLogLine(event);
|
|
164
|
+
expect(result).toContain('User:');
|
|
165
|
+
expect(result).toContain('id');
|
|
166
|
+
expect(result).toContain('Test');
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe('handleClientLogEvent', () => {
|
|
170
|
+
it('should handle client_log events and call log', () => {
|
|
171
|
+
const event = {
|
|
172
|
+
type: 'client_log',
|
|
173
|
+
level: 'log',
|
|
174
|
+
data: ['Test message'],
|
|
175
|
+
};
|
|
176
|
+
const result = handleClientLogEvent(event);
|
|
177
|
+
expect(result).toBe(true);
|
|
178
|
+
expect(log).toHaveBeenCalledTimes(1);
|
|
179
|
+
expect(log).toHaveBeenCalledWith(expect.stringContaining('Test message'));
|
|
180
|
+
});
|
|
181
|
+
it('should return false for non-client_log events', () => {
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
const event = { type: 'bundle_build_started' };
|
|
184
|
+
const result = handleClientLogEvent(event);
|
|
185
|
+
expect(result).toBe(false);
|
|
186
|
+
expect(log).not.toHaveBeenCalled();
|
|
187
|
+
});
|
|
188
|
+
it('should handle error level logs', () => {
|
|
189
|
+
const event = {
|
|
190
|
+
type: 'client_log',
|
|
191
|
+
level: 'error',
|
|
192
|
+
data: ['Something went wrong'],
|
|
193
|
+
};
|
|
194
|
+
handleClientLogEvent(event);
|
|
195
|
+
expect(log).toHaveBeenCalledWith(expect.stringContaining('Something went wrong'));
|
|
196
|
+
});
|
|
197
|
+
it('should handle warn level logs', () => {
|
|
198
|
+
const event = {
|
|
199
|
+
type: 'client_log',
|
|
200
|
+
level: 'warn',
|
|
201
|
+
data: ['Deprecation warning'],
|
|
202
|
+
};
|
|
203
|
+
handleClientLogEvent(event);
|
|
204
|
+
expect(log).toHaveBeenCalledWith(expect.stringContaining('Deprecation warning'));
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
describe('createClientLogListener', () => {
|
|
208
|
+
it('should create a listener function', () => {
|
|
209
|
+
const listener = createClientLogListener();
|
|
210
|
+
expect(typeof listener).toBe('function');
|
|
211
|
+
});
|
|
212
|
+
it('should handle client_log events when called', () => {
|
|
213
|
+
const listener = createClientLogListener();
|
|
214
|
+
const event = {
|
|
215
|
+
type: 'client_log',
|
|
216
|
+
level: 'info',
|
|
217
|
+
data: ['Listener test'],
|
|
218
|
+
};
|
|
219
|
+
listener(event);
|
|
220
|
+
expect(log).toHaveBeenCalledWith(expect.stringContaining('Listener test'));
|
|
221
|
+
});
|
|
222
|
+
it('should ignore non-client_log events', () => {
|
|
223
|
+
const listener = createClientLogListener();
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
+
const event = { type: 'initialize_done' };
|
|
226
|
+
listener(event);
|
|
227
|
+
expect(log).not.toHaveBeenCalled();
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
describe('group events', () => {
|
|
231
|
+
it('should handle group events without logging', () => {
|
|
232
|
+
const event = {
|
|
233
|
+
type: 'client_log',
|
|
234
|
+
level: 'group',
|
|
235
|
+
data: ['Group label'],
|
|
236
|
+
};
|
|
237
|
+
const result = handleClientLogEvent(event);
|
|
238
|
+
expect(result).toBe(true);
|
|
239
|
+
expect(log).not.toHaveBeenCalled();
|
|
240
|
+
});
|
|
241
|
+
it('should handle groupCollapsed events without logging', () => {
|
|
242
|
+
const event = {
|
|
243
|
+
type: 'client_log',
|
|
244
|
+
level: 'groupCollapsed',
|
|
245
|
+
data: ['Collapsed'],
|
|
246
|
+
};
|
|
247
|
+
const result = handleClientLogEvent(event);
|
|
248
|
+
expect(result).toBe(true);
|
|
249
|
+
expect(log).not.toHaveBeenCalled();
|
|
250
|
+
});
|
|
251
|
+
it('should handle groupEnd events without logging', () => {
|
|
252
|
+
const event = {
|
|
253
|
+
type: 'client_log',
|
|
254
|
+
level: 'groupEnd',
|
|
255
|
+
data: [],
|
|
256
|
+
};
|
|
257
|
+
const result = handleClientLogEvent(event);
|
|
258
|
+
expect(result).toBe(true);
|
|
259
|
+
expect(log).not.toHaveBeenCalled();
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReportableEvent } from '@react-native-harness/bundler-metro';
|
|
2
|
+
export type ClientLogEvent = Extract<ReportableEvent, {
|
|
3
|
+
type: 'client_log';
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Formats a client log event data array into a string message.
|
|
7
|
+
* Uses util.format for printf-style format specifier support (%s, %d, %j, etc.)
|
|
8
|
+
*/
|
|
9
|
+
export declare const formatClientLogMessage: (data: unknown[]) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Formats a client log event into a log line with styled level prefix.
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatClientLogLine: (event: ClientLogEvent) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Handles a client_log event by formatting and logging it.
|
|
16
|
+
* Returns true if the event was handled, false otherwise.
|
|
17
|
+
*/
|
|
18
|
+
export declare const handleClientLogEvent: (event: ReportableEvent) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a client log event listener that can be added to the Metro reporter.
|
|
21
|
+
*/
|
|
22
|
+
export declare const createClientLogListener: () => ((event: ReportableEvent) => void);
|
|
23
|
+
//# sourceMappingURL=client-log-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-log-handler.d.ts","sourceRoot":"","sources":["../src/client-log-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAK3E,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC;AA6C9E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,OAAO,EAAE,KAAG,MAKxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,cAAc,KAAG,MAI3D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,eAAe,KAAG,OAiB7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAO,CAAC,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAI3E,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import util from 'node:util';
|
|
3
|
+
import { log } from './logs.js';
|
|
4
|
+
/**
|
|
5
|
+
* Gets the display level for a log level.
|
|
6
|
+
* Note: Metro treats 'trace' as 'log' because Hermes doesn't include stack traces.
|
|
7
|
+
*/
|
|
8
|
+
const getDisplayLevel = (level) => {
|
|
9
|
+
// Metro converts trace to log for display (Hermes doesn't provide stack traces)
|
|
10
|
+
if (level === 'trace') {
|
|
11
|
+
return 'LOG';
|
|
12
|
+
}
|
|
13
|
+
return level.toUpperCase();
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Creates a styled tag for a log level with colored box appearance.
|
|
17
|
+
*/
|
|
18
|
+
const createLevelTag = (level) => {
|
|
19
|
+
const displayLevel = getDisplayLevel(level);
|
|
20
|
+
const label = ` ${displayLevel} `;
|
|
21
|
+
if (!chalk.supportsColor) {
|
|
22
|
+
return `[${displayLevel}]`;
|
|
23
|
+
}
|
|
24
|
+
switch (level) {
|
|
25
|
+
case 'error':
|
|
26
|
+
return chalk.reset.inverse.bold.red(label);
|
|
27
|
+
case 'warn':
|
|
28
|
+
return chalk.reset.inverse.bold.yellow(label);
|
|
29
|
+
case 'info':
|
|
30
|
+
return chalk.reset.inverse.bold.cyan(label);
|
|
31
|
+
case 'debug':
|
|
32
|
+
return chalk.reset.inverse.bold.blue(label);
|
|
33
|
+
case 'trace':
|
|
34
|
+
// Trace displays as LOG but with a distinct color
|
|
35
|
+
return chalk.reset.inverse.bold.magenta(label);
|
|
36
|
+
case 'log':
|
|
37
|
+
default:
|
|
38
|
+
return chalk.reset.inverse.bold.white(label);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Formats a client log event data array into a string message.
|
|
43
|
+
* Uses util.format for printf-style format specifier support (%s, %d, %j, etc.)
|
|
44
|
+
*/
|
|
45
|
+
export const formatClientLogMessage = (data) => {
|
|
46
|
+
if (data.length === 0) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
return util.format(...data);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Formats a client log event into a log line with styled level prefix.
|
|
53
|
+
*/
|
|
54
|
+
export const formatClientLogLine = (event) => {
|
|
55
|
+
const tag = createLevelTag(event.level);
|
|
56
|
+
const message = formatClientLogMessage(event.data);
|
|
57
|
+
return `${tag} ${message}`;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Handles a client_log event by formatting and logging it.
|
|
61
|
+
* Returns true if the event was handled, false otherwise.
|
|
62
|
+
*/
|
|
63
|
+
export const handleClientLogEvent = (event) => {
|
|
64
|
+
if (event.type !== 'client_log') {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Skip group events - they don't produce output
|
|
68
|
+
if (event.level === 'group' ||
|
|
69
|
+
event.level === 'groupCollapsed' ||
|
|
70
|
+
event.level === 'groupEnd') {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
const logLine = formatClientLogLine(event);
|
|
74
|
+
log(logLine);
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Creates a client log event listener that can be added to the Metro reporter.
|
|
79
|
+
*/
|
|
80
|
+
export const createClientLogListener = () => {
|
|
81
|
+
return (event) => {
|
|
82
|
+
handleClientLogEvent(event);
|
|
83
|
+
};
|
|
84
|
+
};
|
package/dist/harness.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../src/harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACb,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,eAAe,EACf,qBAAqB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,QAAQ,EAET,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAsB,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../src/harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACb,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,eAAe,EACf,qBAAqB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,QAAQ,EAET,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAsB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGtE,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;AAE/E,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,SAAS;IAC7C,WAAW,EAAE,QAAQ,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;CACrB,KAAG,OAAO,CAAC,IAAI,CAgFf,CAAC;AAkGF,eAAO,MAAM,UAAU,GACrB,QAAQ,aAAa,EACrB,UAAU,eAAe,EACzB,aAAa,MAAM,KAClB,OAAO,CAAC,OAAO,CAkBjB,CAAC"}
|
package/dist/harness.js
CHANGED
|
@@ -2,6 +2,7 @@ import { getBridgeServer, } from '@react-native-harness/bridge/server';
|
|
|
2
2
|
import { getMetroInstance, } from '@react-native-harness/bundler-metro';
|
|
3
3
|
import { InitializationTimeoutError, MaxAppRestartsError } from './errors.js';
|
|
4
4
|
import { createCrashMonitor } from './crash-monitor.js';
|
|
5
|
+
import { createClientLogListener } from './client-log-handler.js';
|
|
5
6
|
export const waitForAppReady = async (options) => {
|
|
6
7
|
const { metroEvents, serverBridge, platformInstance, bundleStartTimeout, maxRestarts, signal, } = options;
|
|
7
8
|
let restartCount = 0;
|
|
@@ -78,7 +79,15 @@ const getHarnessInternal = async (config, platform, projectRoot, signal) => {
|
|
|
78
79
|
context,
|
|
79
80
|
}),
|
|
80
81
|
]);
|
|
82
|
+
// Forward client logs to console if enabled
|
|
83
|
+
const clientLogListener = createClientLogListener();
|
|
84
|
+
if (config.forwardClientLogs) {
|
|
85
|
+
metroInstance.events.addListener(clientLogListener);
|
|
86
|
+
}
|
|
81
87
|
const dispose = async () => {
|
|
88
|
+
if (config.forwardClientLogs) {
|
|
89
|
+
metroInstance.events.removeListener(clientLogListener);
|
|
90
|
+
}
|
|
82
91
|
await Promise.all([
|
|
83
92
|
serverBridge.dispose(),
|
|
84
93
|
platformInstance.dispose(),
|
package/dist/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAqCxD,eAAO,MAAM,KAAK,GAAU,cAAc,UAAU,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAqCxD,eAAO,MAAM,KAAK,GAAU,cAAc,UAAU,CAAC,YAAY,kBA6ChE,CAAC"}
|
package/dist/setup.js
CHANGED
|
@@ -42,6 +42,9 @@ export const setup = async (globalConfig) => {
|
|
|
42
42
|
// This is going to be used by @react-native-harness/babel-preset
|
|
43
43
|
// to enable instrumentation of test files.
|
|
44
44
|
process.env.RN_HARNESS_COLLECT_COVERAGE = 'true';
|
|
45
|
+
if (harnessConfig.coverage?.root) {
|
|
46
|
+
process.env.RN_HARNESS_COVERAGE_ROOT = harnessConfig.coverage.root;
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
logTestRunHeader(selectedRunner);
|
|
47
50
|
const harness = await getHarness(harnessConfig, selectedRunner, globalConfig.rootDir);
|