@react-native-harness/runtime 1.2.0-rc.1 → 1.3.0
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/client/factory.d.ts +2 -1
- package/dist/client/factory.d.ts.map +1 -1
- package/dist/client/factory.js +53 -59
- package/dist/client/store.d.ts +3 -3
- package/dist/client/store.d.ts.map +1 -1
- package/dist/client/store.js +7 -7
- package/dist/collector/functions.d.ts +3 -3
- package/dist/collector/functions.d.ts.map +1 -1
- package/dist/collector/types.d.ts +3 -2
- package/dist/collector/types.d.ts.map +1 -1
- package/dist/collector/validation.d.ts +2 -2
- package/dist/collector/validation.d.ts.map +1 -1
- package/dist/device/index.d.ts +12 -0
- package/dist/device/index.d.ts.map +1 -0
- package/dist/device/index.js +62 -0
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts +1 -1
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts.map +1 -1
- package/dist/expect/matchers/toMatchImageSnapshot.js +4 -12
- package/dist/hmr.d.ts +2 -0
- package/dist/hmr.d.ts.map +1 -0
- package/dist/hmr.js +5 -0
- package/dist/initialize.js +14 -5
- package/dist/jsx/jsx-dev-runtime.d.ts +2 -1
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +16 -7
- package/dist/logbox.d.ts +4 -0
- package/dist/logbox.d.ts.map +1 -0
- package/dist/logbox.js +18 -0
- package/dist/runner/hooks.d.ts +2 -1
- package/dist/runner/hooks.d.ts.map +1 -1
- package/dist/runner/hooks.js +27 -17
- package/dist/runner/runSuite.d.ts.map +1 -1
- package/dist/runner/runSuite.js +56 -6
- package/dist/runner/test-context.d.ts +16 -0
- package/dist/runner/test-context.d.ts.map +1 -0
- package/dist/runner/test-context.js +57 -0
- package/dist/runner/types.d.ts +2 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/test-utils/react-native-url-polyfill.d.ts +9 -0
- package/dist/test-utils/react-native-url-polyfill.d.ts.map +1 -0
- package/dist/test-utils/react-native-url-polyfill.js +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waitFor.d.ts.map +1 -1
- package/dist/waitFor.js +5 -3
- package/out-tsc/vitest/src/__tests__/device.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/device.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/__tests__/logbox.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/logbox.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/__tests__/runner-context.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/runner-context.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/client/factory.d.ts +2 -1
- package/out-tsc/vitest/src/client/factory.d.ts.map +1 -1
- package/out-tsc/vitest/src/client/store.d.ts +3 -3
- package/out-tsc/vitest/src/client/store.d.ts.map +1 -1
- package/out-tsc/vitest/src/collector/functions.d.ts +3 -3
- package/out-tsc/vitest/src/collector/functions.d.ts.map +1 -1
- package/out-tsc/vitest/src/collector/types.d.ts +3 -2
- package/out-tsc/vitest/src/collector/types.d.ts.map +1 -1
- package/out-tsc/vitest/src/collector/validation.d.ts +2 -2
- package/out-tsc/vitest/src/collector/validation.d.ts.map +1 -1
- package/out-tsc/vitest/src/device/index.d.ts +12 -0
- package/out-tsc/vitest/src/device/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts +1 -1
- package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts.map +1 -1
- package/out-tsc/vitest/src/hmr.d.ts +2 -0
- package/out-tsc/vitest/src/hmr.d.ts.map +1 -0
- package/out-tsc/vitest/src/jsx/jsx-dev-runtime.d.ts +2 -1
- package/out-tsc/vitest/src/jsx/jsx-dev-runtime.d.ts.map +1 -1
- package/out-tsc/vitest/src/logbox.d.ts +4 -0
- package/out-tsc/vitest/src/logbox.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/hooks.d.ts +2 -1
- package/out-tsc/vitest/src/runner/hooks.d.ts.map +1 -1
- package/out-tsc/vitest/src/runner/runSuite.d.ts.map +1 -1
- package/out-tsc/vitest/src/runner/test-context.d.ts +16 -0
- package/out-tsc/vitest/src/runner/test-context.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/types.d.ts +2 -1
- package/out-tsc/vitest/src/runner/types.d.ts.map +1 -1
- package/out-tsc/vitest/src/test-utils/react-native-url-polyfill.d.ts +9 -0
- package/out-tsc/vitest/src/test-utils/react-native-url-polyfill.d.ts.map +1 -0
- package/out-tsc/vitest/src/waitFor.d.ts.map +1 -1
- package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +1 -1
- package/out-tsc/vitest/vite.config.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/runner-context.test.ts +483 -0
- package/src/client/factory.ts +63 -74
- package/src/client/store.ts +8 -8
- package/src/collector/functions.ts +5 -4
- package/src/collector/types.ts +4 -1
- package/src/collector/validation.ts +2 -2
- package/src/expect/matchers/toMatchImageSnapshot.ts +9 -23
- package/src/initialize.ts +14 -5
- package/src/jsx/jsx-dev-runtime.ts +34 -15
- package/src/runner/hooks.ts +43 -19
- package/src/runner/runSuite.ts +75 -9
- package/src/runner/test-context.ts +84 -0
- package/src/runner/types.ts +3 -0
- package/src/test-utils/react-native-url-polyfill.ts +1 -0
- package/src/waitFor.ts +8 -6
- package/vite.config.ts +4 -0
package/dist/client/factory.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { type HarnessHandle } from '@react-native-harness/bridge/client';
|
|
2
|
+
export declare const getClient: () => Promise<HarnessHandle>;
|
|
2
3
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/client/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/client/factory.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAY3F,eAAO,MAAM,SAAS,QAAa,OAAO,CAAC,aAAa,CA2EvD,CAAC"}
|
package/dist/client/factory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { connectToHarness } from '@react-native-harness/bridge/client';
|
|
2
2
|
import { store } from '../ui/state.js';
|
|
3
3
|
import { getTestRunner } from '../runner/index.js';
|
|
4
4
|
import { getTestCollector } from '../collector/index.js';
|
|
@@ -8,68 +8,62 @@ import { getBundler, evaluateModule } from '../bundler/index.js';
|
|
|
8
8
|
import { markTestsAsSkippedByName } from '../filtering/index.js';
|
|
9
9
|
import { setup } from '../render/setup.js';
|
|
10
10
|
import { runSetupFiles } from './setup-files.js';
|
|
11
|
-
import {
|
|
11
|
+
import { setHandle } from './store.js';
|
|
12
12
|
export const getClient = async () => {
|
|
13
|
-
const
|
|
14
|
-
runTests: async () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
bundler = getBundler();
|
|
32
|
-
events = combineEventEmitters(collector.events, runner.events, bundler.events);
|
|
33
|
-
events.addListener((event) => {
|
|
34
|
-
client.rpc.emitEvent(event.type, event);
|
|
35
|
-
});
|
|
36
|
-
await runSetupFiles({
|
|
37
|
-
setupFiles: options.setupFiles ?? [],
|
|
38
|
-
setupFilesAfterEnv: [],
|
|
39
|
-
events: events,
|
|
40
|
-
bundler: bundler,
|
|
41
|
-
evaluateModule,
|
|
42
|
-
});
|
|
43
|
-
const moduleJs = await bundler.getModule(path);
|
|
44
|
-
const collectionResult = await collector.collect(async () => {
|
|
13
|
+
const handle = await connectToHarness(getWSServer(), {
|
|
14
|
+
runTests: async (path, options) => {
|
|
15
|
+
if (store.getState().status === 'running') {
|
|
16
|
+
throw new Error('Already running tests');
|
|
17
|
+
}
|
|
18
|
+
store.getState().setStatus('running');
|
|
19
|
+
let collector = null;
|
|
20
|
+
let runner = null;
|
|
21
|
+
let events = null;
|
|
22
|
+
let bundler = null;
|
|
23
|
+
try {
|
|
24
|
+
collector = getTestCollector();
|
|
25
|
+
runner = getTestRunner();
|
|
26
|
+
bundler = getBundler();
|
|
27
|
+
events = combineEventEmitters(collector.events, runner.events, bundler.events);
|
|
28
|
+
events.addListener((event) => {
|
|
29
|
+
handle.emitEvent(event);
|
|
30
|
+
});
|
|
45
31
|
await runSetupFiles({
|
|
46
|
-
setupFiles: [],
|
|
47
|
-
setupFilesAfterEnv:
|
|
32
|
+
setupFiles: options.setupFiles ?? [],
|
|
33
|
+
setupFilesAfterEnv: [],
|
|
48
34
|
events: events,
|
|
49
35
|
bundler: bundler,
|
|
50
36
|
evaluateModule,
|
|
51
37
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
38
|
+
const moduleJs = await bundler.getModule(path);
|
|
39
|
+
const collectionResult = await collector.collect(async () => {
|
|
40
|
+
await runSetupFiles({
|
|
41
|
+
setupFiles: [],
|
|
42
|
+
setupFilesAfterEnv: options.setupFilesAfterEnv ?? [],
|
|
43
|
+
events: events,
|
|
44
|
+
bundler: bundler,
|
|
45
|
+
evaluateModule,
|
|
46
|
+
});
|
|
47
|
+
setup();
|
|
48
|
+
evaluateModule(moduleJs, path);
|
|
49
|
+
}, path);
|
|
50
|
+
const processedTestSuite = options.testNamePattern
|
|
51
|
+
? markTestsAsSkippedByName(collectionResult.testSuite, options.testNamePattern)
|
|
52
|
+
: collectionResult.testSuite;
|
|
53
|
+
return await runner.run({
|
|
54
|
+
testSuite: processedTestSuite,
|
|
55
|
+
testFilePath: path,
|
|
56
|
+
runner: options.runner,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
collector?.dispose();
|
|
61
|
+
runner?.dispose();
|
|
62
|
+
events?.clearAllListeners();
|
|
63
|
+
store.getState().setStatus('idle');
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
setHandle(handle);
|
|
68
|
+
return handle;
|
|
75
69
|
};
|
package/dist/client/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
import type { HarnessHandle } from '@react-native-harness/bridge/client';
|
|
2
|
+
export declare const setHandle: (h: HarnessHandle) => void;
|
|
3
|
+
export declare const getHandle: () => HarnessHandle;
|
|
4
4
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/client/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/client/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAIzE,eAAO,MAAM,SAAS,GAAI,GAAG,aAAa,KAAG,IAE5C,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,aAO5B,CAAC"}
|
package/dist/client/store.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
let
|
|
2
|
-
export const
|
|
3
|
-
|
|
1
|
+
let handle = null;
|
|
2
|
+
export const setHandle = (h) => {
|
|
3
|
+
handle = h;
|
|
4
4
|
};
|
|
5
|
-
export const
|
|
6
|
-
if (!
|
|
7
|
-
throw new Error('
|
|
5
|
+
export const getHandle = () => {
|
|
6
|
+
if (!handle) {
|
|
7
|
+
throw new Error('Harness not connected. This should not happen in normal operation.');
|
|
8
8
|
}
|
|
9
|
-
return
|
|
9
|
+
return handle;
|
|
10
10
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionResult } from '@react-native-harness/bridge';
|
|
1
|
+
import type { CollectionResult, SuiteHookFn } from '@react-native-harness/bridge';
|
|
2
2
|
import type { TestFn } from './types.js';
|
|
3
3
|
export declare const describe: ((name: string, fn: () => void) => void) & {
|
|
4
4
|
skip: (name: string, fn: () => void) => void;
|
|
@@ -14,8 +14,8 @@ export declare const it: ((name: string, fn: TestFn) => void) & {
|
|
|
14
14
|
only: (name: string, fn: TestFn) => void;
|
|
15
15
|
todo: (name: string) => void;
|
|
16
16
|
};
|
|
17
|
-
export declare function beforeAll(fn:
|
|
18
|
-
export declare function afterAll(fn:
|
|
17
|
+
export declare function beforeAll(fn: SuiteHookFn): void;
|
|
18
|
+
export declare function afterAll(fn: SuiteHookFn): void;
|
|
19
19
|
export declare function beforeEach(fn: TestFn): void;
|
|
20
20
|
export declare function afterEach(fn: TestFn): void;
|
|
21
21
|
export declare const collectTests: (fn: () => void | Promise<void>) => Promise<CollectionResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/collector/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/collector/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA4LzC,eAAO,MAAM,QAAQ,UACZ,MAAM,MAAM,MAAM,IAAI;iBAsBd,MAAM,MAAM,MAAM,IAAI;iBAqBtB,MAAM,MAAM,MAAM,IAAI;CAsBtC,CAAC;AAEF,eAAO,MAAM,IAAI,UACR,MAAM,MAAM,MAAM;iBAaV,MAAM,MAAM,MAAM;iBAWlB,MAAM,MAAM,MAAM;iBAWlB,MAAM;CAiBtB,CAAC;AAEF,eAAO,MAAM,EAAE,UAtDN,MAAM,MAAM,MAAM;iBAaV,MAAM,MAAM,MAAM;iBAWlB,MAAM,MAAM,MAAM;iBAWlB,MAAM;CAmBD,CAAC;AAEvB,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,QAQxC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,QAQvC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,QAQpC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAQnC;AAgBD,eAAO,MAAM,YAAY,GACvB,IAAI,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAC7B,OAAO,CAAC,gBAAgB,CAiB1B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from '../utils/emitter.js';
|
|
2
|
-
import { TestCollectorEvents, CollectionResult } from '@react-native-harness/bridge';
|
|
3
|
-
export type TestFn = () => void | Promise<void>;
|
|
2
|
+
import { TestCollectorEvents, CollectionResult, type HarnessTestContext } from '@react-native-harness/bridge';
|
|
3
|
+
export type TestFn = (context: HarnessTestContext) => void | Promise<void>;
|
|
4
|
+
export type SuiteHookFn = () => void | Promise<void>;
|
|
4
5
|
export type TestCollectorEventsEmitter = EventEmitter<TestCollectorEvents>;
|
|
5
6
|
export type TestCollector = {
|
|
6
7
|
events: TestCollectorEventsEmitter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/collector/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/collector/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,kBAAkB,EACxB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErD,MAAM,MAAM,0BAA0B,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EAAE,CACP,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC9B,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TestFn } from './types.js';
|
|
1
|
+
import { TestFn, SuiteHookFn } from './types.js';
|
|
2
2
|
export declare const validateTestName: (name: string, functionName: string) => void;
|
|
3
|
-
export declare const validateTestFunction: (fn: TestFn, functionName: string) => void;
|
|
3
|
+
export declare const validateTestFunction: (fn: TestFn | SuiteHookFn, functionName: string) => void;
|
|
4
4
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/collector/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/collector/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,KAAG,IAMrE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,IAAI,MAAM,GAAG,WAAW,EACxB,cAAc,MAAM,KACnB,IAMF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DeviceStateMutation, PermissionName } from '@react-native-harness/platforms';
|
|
2
|
+
export declare const device: {
|
|
3
|
+
permissions: {
|
|
4
|
+
grant: (permission: PermissionName) => Promise<DeviceStateMutation | null>;
|
|
5
|
+
revoke: (permission: PermissionName) => Promise<DeviceStateMutation | null>;
|
|
6
|
+
reset: (permission: PermissionName) => Promise<DeviceStateMutation | null>;
|
|
7
|
+
grantAll: () => Promise<DeviceStateMutation | null>;
|
|
8
|
+
denyAll: () => Promise<DeviceStateMutation | null>;
|
|
9
|
+
resetAll: () => Promise<DeviceStateMutation | null>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/device/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,cAAc,EACf,MAAM,iCAAiC,CAAC;AA2BzC,eAAO,MAAM,MAAM;;4BAEW,cAAc,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;6BAOnD,cAAc,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;4BAOrD,cAAc,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;wBAO1D,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;uBAMpC,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;wBAMlC,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;;CAO1D,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getHandle } from '../client/store.js';
|
|
2
|
+
const warnIfNeeded = (warning) => {
|
|
3
|
+
if (warning) {
|
|
4
|
+
console.warn(warning);
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
const applyPermissionCommand = async (command) => {
|
|
8
|
+
const result = await getHandle().applyDevicePermission(command);
|
|
9
|
+
warnIfNeeded(result.warning);
|
|
10
|
+
if (!result.mutationId) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
id: result.mutationId,
|
|
15
|
+
revert: async () => {
|
|
16
|
+
await getHandle().revertDevicePermission(result.mutationId);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export const device = {
|
|
21
|
+
permissions: {
|
|
22
|
+
grant: async (permission) => {
|
|
23
|
+
return await applyPermissionCommand({
|
|
24
|
+
kind: 'permission',
|
|
25
|
+
permission,
|
|
26
|
+
decision: 'grant',
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
revoke: async (permission) => {
|
|
30
|
+
return await applyPermissionCommand({
|
|
31
|
+
kind: 'permission',
|
|
32
|
+
permission,
|
|
33
|
+
decision: 'deny',
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
reset: async (permission) => {
|
|
37
|
+
return await applyPermissionCommand({
|
|
38
|
+
kind: 'permission',
|
|
39
|
+
permission,
|
|
40
|
+
decision: 'reset',
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
grantAll: async () => {
|
|
44
|
+
return await applyPermissionCommand({
|
|
45
|
+
kind: 'permission-all',
|
|
46
|
+
decision: 'grant',
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
denyAll: async () => {
|
|
50
|
+
return await applyPermissionCommand({
|
|
51
|
+
kind: 'permission-all',
|
|
52
|
+
decision: 'deny',
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
resetAll: async () => {
|
|
56
|
+
return await applyPermissionCommand({
|
|
57
|
+
kind: 'permission-all',
|
|
58
|
+
decision: 'reset',
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toMatchImageSnapshot.d.ts","sourceRoot":"","sources":["../../../src/expect/matchers/toMatchImageSnapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"toMatchImageSnapshot.d.ts","sourceRoot":"","sources":["../../../src/expect/matchers/toMatchImageSnapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,MAAM,CAAA;CAAE,CAAC,CAoBnD"}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { generateTransferId, } from '@react-native-harness/bridge';
|
|
1
|
+
import { getHandle } from '../../client/store.js';
|
|
3
2
|
import { getHarnessContext } from '../../runner/index.js';
|
|
4
3
|
export async function toMatchImageSnapshot(received, options) {
|
|
5
|
-
const
|
|
4
|
+
const handle = getHandle();
|
|
6
5
|
const context = getHarnessContext();
|
|
7
|
-
const
|
|
8
|
-
client.sendBinary(transferId, received.data);
|
|
9
|
-
const screenshotFile = await client.rpc['device.screenshot.receive']({
|
|
10
|
-
type: 'binary',
|
|
11
|
-
transferId,
|
|
12
|
-
size: received.data.length,
|
|
13
|
-
mimeType: 'image/png',
|
|
14
|
-
}, {
|
|
6
|
+
const screenshotFile = await handle.transferScreenshot(received.data, {
|
|
15
7
|
width: received.width,
|
|
16
8
|
height: received.height,
|
|
17
9
|
});
|
|
18
|
-
const result = await
|
|
10
|
+
const result = await handle.matchImageSnapshot(screenshotFile, context.testFilePath, options, context.runner);
|
|
19
11
|
return {
|
|
20
12
|
pass: result.pass,
|
|
21
13
|
message: () => result.message,
|
package/dist/hmr.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,QAAO,IAM7B,CAAC"}
|
package/dist/hmr.js
ADDED
package/dist/initialize.js
CHANGED
|
@@ -2,10 +2,19 @@ import { getDeviceDescriptor } from './client/getDeviceDescriptor.js';
|
|
|
2
2
|
import { getClient } from './client/index.js';
|
|
3
3
|
import { disableHMRWhenReady } from './disableHMRWhenReady.js';
|
|
4
4
|
import { setupJestMock } from './jest-mock.js';
|
|
5
|
-
// Polyfill for EventTarget
|
|
5
|
+
// Polyfill for EventTarget on runtimes that don't ship one (RN's JSC).
|
|
6
|
+
// Do NOT overwrite when a native ctor already exists (RN Web / browsers):
|
|
7
|
+
// Safari's EventTarget.dispatchEvent() does an internal brand check and
|
|
8
|
+
// rejects polyfill instances with a TypeError, which breaks any
|
|
9
|
+
// DOM-event-driven flow in the page — most visibly DRM (FairPlay) via
|
|
10
|
+
// libraries that re-dispatch synthetic `encrypted` events.
|
|
6
11
|
const Shim = require('event-target-shim');
|
|
7
|
-
globalThis.Event
|
|
8
|
-
globalThis.
|
|
12
|
+
if (typeof globalThis.Event !== 'function') {
|
|
13
|
+
globalThis.Event = Shim.Event;
|
|
14
|
+
}
|
|
15
|
+
if (typeof globalThis.EventTarget !== 'function') {
|
|
16
|
+
globalThis.EventTarget = Shim.EventTarget;
|
|
17
|
+
}
|
|
9
18
|
// Setup jest mock to warn users about using Jest APIs
|
|
10
19
|
setupJestMock();
|
|
11
20
|
// Turn off LogBox
|
|
@@ -19,9 +28,9 @@ setTimeout(() => {
|
|
|
19
28
|
void (async () => {
|
|
20
29
|
try {
|
|
21
30
|
await disableHMRWhenReady(() => HMRClient.disable(), 50);
|
|
22
|
-
const
|
|
31
|
+
const handle = await getClient();
|
|
23
32
|
const deviceDescriptor = getDeviceDescriptor();
|
|
24
|
-
|
|
33
|
+
handle.reportReady(deviceDescriptor);
|
|
25
34
|
}
|
|
26
35
|
catch (error) {
|
|
27
36
|
console.error('Failed to initialize React Native Harness', error);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as ReactJSXRuntimeDev from 'react/jsx-dev-runtime';
|
|
1
2
|
export declare const Fragment: import("react").ExoticComponent<import("react").FragmentProps>;
|
|
2
|
-
export declare function jsxDEV(
|
|
3
|
+
export declare function jsxDEV(...args: Parameters<typeof ReactJSXRuntimeDev.jsxDEV>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
3
4
|
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx/jsx-dev-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAe5D,eAAO,MAAM,QAAQ,gEAA8B,CAAC;AAEpD,wBAAgB,MAAM,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,MAAM,CAAC,8FA8B3E"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import * as ReactJSXRuntimeDev from 'react/jsx-dev-runtime';
|
|
2
|
+
const isNamedElementType = (value) => (typeof value === 'function' ||
|
|
3
|
+
(typeof value === 'object' && value !== null)) &&
|
|
4
|
+
('displayName' in value || 'name' in value);
|
|
5
|
+
const isPropsObject = (value) => typeof value === 'object' && value !== null;
|
|
2
6
|
export const Fragment = ReactJSXRuntimeDev.Fragment;
|
|
3
|
-
export function jsxDEV(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
props
|
|
7
|
+
export function jsxDEV(...args) {
|
|
8
|
+
const [type, props, key, isStaticChildren, source, self] = args;
|
|
9
|
+
const isViewType = isNamedElementType(type) &&
|
|
10
|
+
(type.displayName === 'View' || type.name === 'View');
|
|
11
|
+
const nextProps = isViewType &&
|
|
12
|
+
isPropsObject(props) &&
|
|
13
|
+
props.collapsable === undefined
|
|
14
|
+
? { ...props, collapsable: true }
|
|
15
|
+
: props;
|
|
16
|
+
if (isViewType && isPropsObject(props) && props.collapsable === undefined) {
|
|
17
|
+
return ReactJSXRuntimeDev.jsxDEV(type, nextProps, key, isStaticChildren, source, self);
|
|
9
18
|
}
|
|
10
|
-
return ReactJSXRuntimeDev.jsxDEV(type,
|
|
19
|
+
return ReactJSXRuntimeDev.jsxDEV(type, nextProps, key, isStaticChildren, source, self);
|
|
11
20
|
}
|
package/dist/logbox.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logbox.d.ts","sourceRoot":"","sources":["../src/logbox.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,kBAAkB,QAAO,OAA2B,CAAC;AAElE,qEAAqE;AACrE,eAAO,MAAM,eAAe,QAAO,IAelC,CAAC"}
|
package/dist/logbox.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LogBox, TurboModuleRegistry, } from 'react-native';
|
|
2
|
+
let logBoxSuppressed = false;
|
|
3
|
+
const noop = () => undefined;
|
|
4
|
+
export const isLogBoxSuppressed = () => logBoxSuppressed;
|
|
5
|
+
/** Hide LogBox UI while keeping console.error → Metro forwarding. */
|
|
6
|
+
export const disableLogBoxUI = () => {
|
|
7
|
+
const harnessLogBox = LogBox;
|
|
8
|
+
harnessLogBox.ignoreAllLogs(true);
|
|
9
|
+
harnessLogBox.addException = noop;
|
|
10
|
+
harnessLogBox.addLog = noop;
|
|
11
|
+
harnessLogBox.addConsoleLog = noop;
|
|
12
|
+
const nativeLogBox = TurboModuleRegistry?.get('LogBox');
|
|
13
|
+
if (nativeLogBox != null) {
|
|
14
|
+
nativeLogBox.show = noop;
|
|
15
|
+
nativeLogBox.hide = noop;
|
|
16
|
+
}
|
|
17
|
+
logBoxSuppressed = true;
|
|
18
|
+
};
|
package/dist/runner/hooks.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TestSuite } from '@react-native-harness/bridge';
|
|
2
|
+
import type { ActiveTestContext } from './types.js';
|
|
2
3
|
export type HookType = 'beforeEach' | 'afterEach' | 'beforeAll' | 'afterAll';
|
|
3
|
-
export declare const runHooks: (suite: TestSuite, hookType: HookType) => Promise<void>;
|
|
4
|
+
export declare const runHooks: (suite: TestSuite, hookType: HookType, context?: ActiveTestContext) => Promise<void>;
|
|
4
5
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/runner/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/runner/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC;AAmD7E,eAAO,MAAM,QAAQ,GACnB,OAAO,SAAS,EAChB,UAAU,QAAQ,EAClB,UAAU,iBAAiB,KAC1B,OAAO,CAAC,IAAI,CAgBd,CAAC"}
|
package/dist/runner/hooks.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
const collectInheritedHooks = (suite, hookType) => {
|
|
2
|
+
const hooks = [];
|
|
3
|
+
const suiteChain = [];
|
|
4
|
+
let current = suite;
|
|
5
|
+
while (current) {
|
|
6
|
+
suiteChain.unshift(current);
|
|
7
|
+
current = current.parent;
|
|
8
|
+
}
|
|
9
|
+
for (const currentSuite of suiteChain) {
|
|
10
|
+
hooks.push(...currentSuite[hookType]);
|
|
11
|
+
}
|
|
12
|
+
return hooks;
|
|
13
|
+
};
|
|
14
|
+
const collectSuiteHooks = (suite, hookType) => {
|
|
2
15
|
const hooks = [];
|
|
3
16
|
const suiteChain = [];
|
|
4
17
|
// Collect all suites from current to root
|
|
@@ -7,33 +20,30 @@ const collectInheritedHooks = (suite, hookType) => {
|
|
|
7
20
|
suiteChain.push(currentSuite);
|
|
8
21
|
currentSuite = currentSuite.parent;
|
|
9
22
|
}
|
|
10
|
-
if (hookType === '
|
|
11
|
-
//
|
|
23
|
+
if (hookType === 'beforeAll') {
|
|
24
|
+
// Run parent suite hooks before child suite hooks.
|
|
12
25
|
for (let i = suiteChain.length - 1; i >= 0; i--) {
|
|
13
|
-
|
|
14
|
-
hooks.push(...suiteChain[i].beforeEach);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
hooks.push(...suiteChain[i].beforeAll);
|
|
18
|
-
}
|
|
26
|
+
hooks.push(...suiteChain[i].beforeAll);
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
else {
|
|
22
|
-
//
|
|
30
|
+
// Run child suite hooks before parent suite hooks.
|
|
23
31
|
for (const suiteInChain of suiteChain) {
|
|
24
|
-
|
|
25
|
-
hooks.push(...suiteInChain.afterEach);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
hooks.push(...suiteInChain.afterAll);
|
|
29
|
-
}
|
|
32
|
+
hooks.push(...suiteInChain.afterAll);
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
return hooks;
|
|
33
36
|
};
|
|
34
|
-
export const runHooks = async (suite, hookType) => {
|
|
37
|
+
export const runHooks = async (suite, hookType, context) => {
|
|
38
|
+
if (hookType === 'beforeAll' || hookType === 'afterAll') {
|
|
39
|
+
const hooks = collectSuiteHooks(suite, hookType);
|
|
40
|
+
for (const hook of hooks) {
|
|
41
|
+
await hook();
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
35
45
|
const hooks = collectInheritedHooks(suite, hookType);
|
|
36
46
|
for (const hook of hooks) {
|
|
37
|
-
await hook();
|
|
47
|
+
await hook(context);
|
|
38
48
|
}
|
|
39
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runSuite.d.ts","sourceRoot":"","sources":["../../src/runner/runSuite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"runSuite.d.ts","sourceRoot":"","sources":["../../src/runner/runSuite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,SAAS,EACT,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AASlE,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,iBAAiB,EAAE,MAAM,CAAC;CAC/B;AAyLD,eAAO,MAAM,QAAQ,GACnB,OAAO,SAAS,EAChB,SAAS,iBAAiB,KACzB,OAAO,CAAC,eAAe,CAoIzB,CAAC"}
|