Skip to content

Commit b83f01b

Browse files
feat(config): add server.forwardClientLogs option (#63)
Added `forwardClientLogs` option to forward React Native logs to terminal during tests.
1 parent 159484a commit b83f01b

File tree

12 files changed

+552
-14
lines changed

12 files changed

+552
-14
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
__default__: prerelease
3+
---
4+
5+
Added `forwardClientLogs` option to forward React Native logs to terminal during tests

actions/shared/index.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,7 +3995,7 @@ ZodNaN.create = (params) => {
39953995
...processCreateParams(params)
39963996
});
39973997
};
3998-
var BRAND = Symbol("zod_brand");
3998+
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
39993999
var ZodBranded = class extends ZodType {
40004000
_parse(input) {
40014001
const { ctx } = this._processInputParams(input);
@@ -4231,6 +4231,7 @@ var ConfigSchema = external_exports.object({
42314231
coverage: external_exports.object({
42324232
root: external_exports.string().optional().describe(`Root directory for coverage instrumentation in monorepo setups. Specifies the directory from which coverage data should be collected. Use ".." for create-react-native-library projects where tests run from example/ but source files are in parent directory. Passed to babel-plugin-istanbul's cwd option.`)
42334233
}).optional(),
4234+
forwardClientLogs: external_exports.boolean().optional().default(false).describe("Enable forwarding of console.log, console.warn, console.error, and other console method calls from the React Native app to the terminal. When enabled, all console output from your app will be displayed in the test runner terminal with styled level indicators (log, warn, error)."),
42344235
// Deprecated property - used for migration detection
42354236
include: external_exports.array(external_exports.string()).optional()
42364237
}).refine((config) => {
@@ -4262,7 +4263,6 @@ var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
42624263
var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
42634264
var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true };
42644265
var bt = globalThis.process.platform.startsWith("win");
4265-
var z = Symbol("clack:cancel");
42664266

42674267
// ../../node_modules/@clack/prompts/dist/index.mjs
42684268
var import_picocolors = __toESM(require_picocolors(), 1);
@@ -4289,7 +4289,7 @@ var Y = w("\u25CF", ">");
42894289
var K = w("\u25CB", " ");
42904290
var te = w("\u25FB", "[\u2022]");
42914291
var k2 = w("\u25FC", "[+]");
4292-
var z2 = w("\u25FB", "[ ]");
4292+
var z = w("\u25FB", "[ ]");
42934293
var Pe = w("\u25AA", "\u2022");
42944294
var se = w("\u2500", "-");
42954295
var he = w("\u256E", "+");

apps/playground/rn-harness.config.mjs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,34 @@ export default {
2424

2525
runners: [
2626
androidPlatform({
27-
name: 'pixel_8_api_33',
28-
device: androidEmulator('Pixel_8_API_33'),
29-
bundleId: 'com.example',
27+
name: 'android',
28+
device: androidEmulator('Pixel_8_API_35', {
29+
apiLevel: 35,
30+
profile: 'pixel_6',
31+
diskSize: '1G',
32+
heapSize: '1G',
33+
}),
34+
bundleId: 'com.harnessplayground',
35+
}),
36+
androidPlatform({
37+
name: 'moto-g72',
38+
device: physicalAndroidDevice('Motorola', 'Moto G72'),
39+
bundleId: 'com.harnessplayground',
40+
}),
41+
applePlatform({
42+
name: 'iphone-16-pro',
43+
device: applePhysicalDevice('iPhone (Szymon) (2)'),
44+
bundleId: 'react-native-harness',
3045
}),
3146
applePlatform({
32-
name: 'iphone-16-pro-max',
33-
device: appleSimulator('iPhone 16 Pro Max', '26.0'),
34-
bundleId: 'com.example',
47+
name: 'ios',
48+
device: appleSimulator('iPhone 16 Pro', '18.6'),
49+
bundleId: 'com.harnessplayground',
50+
}),
51+
vegaPlatform({
52+
name: 'vega',
53+
device: vegaEmulator('VegaTV_1'),
54+
bundleId: 'com.playground',
3555
}),
3656
webPlatform({
3757
name: 'web',
@@ -42,5 +62,11 @@ export default {
4262
browser: chromium('http://localhost:8081/index.html', { headless: true }),
4363
}),
4464
],
45-
defaultRunner: 'pixel_8_api_33',
65+
defaultRunner: 'android',
66+
bridgeTimeout: 120000,
67+
webSocketPort: 3002,
68+
69+
resetEnvironmentBetweenTestFiles: true,
70+
unstable__skipAlreadyIncludedModules: false,
71+
forwardClientLogs: true,
4672
};

packages/bundler-metro/src/reporter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export type ReportableEvent =
77
| MetroReportableEvent
88
| {
99
type: 'initialize_done';
10+
}
11+
| {
12+
type: 'client_log';
13+
level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug' | 'error';
14+
data: unknown[];
1015
};
1116

1217
export type Reporter = EventEmitter<ReportableEvent>;

packages/config/src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ export const ConfigSchema = z
6060
})
6161
.optional(),
6262

63+
forwardClientLogs: z
64+
.boolean()
65+
.optional()
66+
.default(false)
67+
.describe(
68+
'Enable forwarding of console.log, console.warn, console.error, and other console method calls from the React Native app to the terminal. ' +
69+
'When enabled, all console output from your app will be displayed in the test runner terminal with styled level indicators (log, warn, error).'
70+
),
71+
6372
// Deprecated property - used for migration detection
6473
include: z.array(z.string()).optional(),
6574
})

packages/jest/eslint.config.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ export default [
88
'@nx/dependency-checks': [
99
'error',
1010
{
11-
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}'],
11+
ignoredFiles: [
12+
'{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
13+
'{projectRoot}/vite.config.{js,cjs,mjs,ts,cts,mts}',
14+
],
1215
// jest-runner: we only ingest types
13-
ignoredDependencies: ['@react-native-harness/cli', 'jest-runner'],
16+
ignoredDependencies: ['@react-native-harness/cli', 'jest-runner', 'vitest'],
1417
},
1518
],
1619
},

0 commit comments

Comments
 (0)