@react-native-harness/runtime 1.0.0-alpha.21 → 1.0.0-alpha.23
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/NativeHarness.d.ts +41 -0
- package/dist/NativeHarness.d.ts.map +1 -0
- package/dist/NativeHarness.js +2 -0
- package/dist/client/factory.d.ts.map +1 -1
- package/dist/client/factory.js +8 -2
- package/dist/client/store.d.ts +4 -0
- package/dist/client/store.d.ts.map +1 -0
- package/dist/client/store.js +10 -0
- package/dist/expect/expect.d.ts +9 -0
- package/dist/expect/expect.d.ts.map +1 -0
- package/dist/expect/expect.js +77 -0
- package/dist/expect/index.d.ts +1 -8
- package/dist/expect/index.d.ts.map +1 -1
- package/dist/expect/index.js +1 -73
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts +13 -0
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts.map +1 -0
- package/dist/expect/matchers/toMatchImageSnapshot.js +23 -0
- package/dist/globals.d.ts +10 -0
- package/dist/globals.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/render/TestComponentOverlay.d.ts.map +1 -1
- package/dist/render/TestComponentOverlay.js +21 -2
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +8 -6
- package/dist/render/queries.d.ts +7 -0
- package/dist/render/queries.d.ts.map +1 -0
- package/dist/render/queries.js +99 -0
- package/dist/runHarnessTestsInModule.d.ts +9 -0
- package/dist/runHarnessTestsInModule.d.ts.map +1 -0
- package/dist/runHarnessTestsInModule.js +57 -0
- package/dist/runner/context.d.ts +10 -0
- package/dist/runner/context.d.ts.map +1 -0
- package/dist/runner/context.js +6 -0
- package/dist/runner/factory.d.ts.map +1 -1
- package/dist/runner/factory.js +6 -1
- package/dist/runner/index.d.ts +1 -0
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +1 -0
- package/dist/runner/runSuite.d.ts +3 -0
- package/dist/runner/runSuite.d.ts.map +1 -1
- package/dist/runner/types.d.ts +6 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/screen/index.d.ts +50 -0
- package/dist/screen/index.d.ts.map +1 -0
- package/dist/screen/index.js +46 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/ui/ReadyScreen.d.ts.map +1 -1
- package/dist/ui/ReadyScreen.js +1 -1
- package/dist/userEvent/index.d.ts +16 -0
- package/dist/userEvent/index.d.ts.map +1 -0
- package/dist/userEvent/index.js +31 -0
- package/out-tsc/vitest/src/__tests__/collector.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/collector.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/__tests__/expect.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/expect.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/__tests__/initialize.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/initialize.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/__tests__/spy.test.d.ts +2 -0
- package/out-tsc/vitest/src/__tests__/spy.test.d.ts.map +1 -0
- package/out-tsc/vitest/src/bundler/bundle.d.ts +2 -0
- package/out-tsc/vitest/src/bundler/bundle.d.ts.map +1 -0
- package/out-tsc/vitest/src/bundler/errors.d.ts +15 -0
- package/out-tsc/vitest/src/bundler/errors.d.ts.map +1 -0
- package/out-tsc/vitest/src/bundler/evaluate.d.ts +2 -0
- package/out-tsc/vitest/src/bundler/evaluate.d.ts.map +1 -0
- package/out-tsc/vitest/src/bundler/factory.d.ts +3 -0
- package/out-tsc/vitest/src/bundler/factory.d.ts.map +1 -0
- package/out-tsc/vitest/src/bundler/index.d.ts +4 -0
- package/out-tsc/vitest/src/bundler/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/bundler/types.d.ts +7 -0
- package/out-tsc/vitest/src/bundler/types.d.ts.map +1 -0
- package/out-tsc/vitest/src/client/factory.d.ts +2 -0
- package/out-tsc/vitest/src/client/factory.d.ts.map +1 -0
- package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts +8 -0
- package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts.map +1 -0
- package/out-tsc/vitest/src/client/getWSServer.d.ts +2 -0
- package/out-tsc/vitest/src/client/getWSServer.d.ts.map +1 -0
- package/out-tsc/vitest/src/client/index.d.ts +2 -0
- package/out-tsc/vitest/src/client/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/client/setup-files.d.ts +12 -0
- package/out-tsc/vitest/src/client/setup-files.d.ts.map +1 -0
- package/out-tsc/vitest/src/client/store.d.ts +4 -0
- package/out-tsc/vitest/src/client/store.d.ts.map +1 -0
- package/out-tsc/vitest/src/collector/errors.d.ts +8 -0
- package/out-tsc/vitest/src/collector/errors.d.ts.map +1 -0
- package/out-tsc/vitest/src/collector/factory.d.ts +3 -0
- package/out-tsc/vitest/src/collector/factory.d.ts.map +1 -0
- package/out-tsc/vitest/src/collector/functions.d.ts +22 -0
- package/out-tsc/vitest/src/collector/functions.d.ts.map +1 -0
- package/out-tsc/vitest/src/collector/index.d.ts +5 -0
- package/out-tsc/vitest/src/collector/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/collector/types.d.ts +10 -0
- package/out-tsc/vitest/src/collector/types.d.ts.map +1 -0
- package/out-tsc/vitest/src/collector/validation.d.ts +4 -0
- package/out-tsc/vitest/src/collector/validation.d.ts.map +1 -0
- package/out-tsc/vitest/src/constants.d.ts +2 -0
- package/out-tsc/vitest/src/constants.d.ts.map +1 -0
- package/out-tsc/vitest/src/disableHMRWhenReady.d.ts +2 -0
- package/out-tsc/vitest/src/disableHMRWhenReady.d.ts.map +1 -0
- package/out-tsc/vitest/src/entry-point.d.ts +2 -0
- package/out-tsc/vitest/src/entry-point.d.ts.map +1 -0
- package/out-tsc/vitest/src/errors.d.ts +6 -0
- package/out-tsc/vitest/src/errors.d.ts.map +1 -0
- package/out-tsc/vitest/src/expect/expect.d.ts +9 -0
- package/out-tsc/vitest/src/expect/expect.d.ts.map +1 -0
- package/out-tsc/vitest/src/expect/index.d.ts +2 -0
- package/out-tsc/vitest/src/expect/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts +18 -0
- package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts.map +1 -0
- package/out-tsc/vitest/src/expect/setup.d.ts +2 -0
- package/out-tsc/vitest/src/expect/setup.d.ts.map +1 -0
- package/out-tsc/vitest/src/filtering/index.d.ts +2 -0
- package/out-tsc/vitest/src/filtering/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/filtering/testNameFilter.d.ts +12 -0
- package/out-tsc/vitest/src/filtering/testNameFilter.d.ts.map +1 -0
- package/out-tsc/vitest/src/globals.d.ts +9 -0
- package/out-tsc/vitest/src/globals.d.ts.map +1 -0
- package/out-tsc/vitest/src/index.d.ts +11 -0
- package/out-tsc/vitest/src/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/initialize.d.ts +2 -0
- package/out-tsc/vitest/src/initialize.d.ts.map +1 -0
- package/out-tsc/vitest/src/jest-mock.d.ts +2 -0
- package/out-tsc/vitest/src/jest-mock.d.ts.map +1 -0
- package/out-tsc/vitest/src/mocker/index.d.ts +2 -0
- package/out-tsc/vitest/src/mocker/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/mocker/registry.d.ts +6 -0
- package/out-tsc/vitest/src/mocker/registry.d.ts.map +1 -0
- package/out-tsc/vitest/src/mocker/types.d.ts +6 -0
- package/out-tsc/vitest/src/mocker/types.d.ts.map +1 -0
- package/out-tsc/vitest/src/namespace.d.ts +18 -0
- package/out-tsc/vitest/src/namespace.d.ts.map +1 -0
- package/out-tsc/vitest/src/polyfills.d.ts +11 -0
- package/out-tsc/vitest/src/polyfills.d.ts.map +1 -0
- package/out-tsc/vitest/src/render/ErrorBoundary.d.ts +17 -0
- package/out-tsc/vitest/src/render/ErrorBoundary.d.ts.map +1 -0
- package/out-tsc/vitest/src/render/TestComponentOverlay.d.ts +3 -0
- package/out-tsc/vitest/src/render/TestComponentOverlay.d.ts.map +1 -0
- package/out-tsc/vitest/src/render/cleanup.d.ts +2 -0
- package/out-tsc/vitest/src/render/cleanup.d.ts.map +1 -0
- package/out-tsc/vitest/src/render/index.d.ts +6 -0
- package/out-tsc/vitest/src/render/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/render/setup.d.ts +2 -0
- package/out-tsc/vitest/src/render/setup.d.ts.map +1 -0
- package/out-tsc/vitest/src/render/types.d.ts +12 -0
- package/out-tsc/vitest/src/render/types.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/context.d.ts +10 -0
- package/out-tsc/vitest/src/runner/context.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/errors.d.ts +11 -0
- package/out-tsc/vitest/src/runner/errors.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/factory.d.ts +3 -0
- package/out-tsc/vitest/src/runner/factory.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/hooks.d.ts +4 -0
- package/out-tsc/vitest/src/runner/hooks.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/index.d.ts +5 -0
- package/out-tsc/vitest/src/runner/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/runSuite.d.ts +7 -0
- package/out-tsc/vitest/src/runner/runSuite.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/types.d.ts +18 -0
- package/out-tsc/vitest/src/runner/types.d.ts.map +1 -0
- package/out-tsc/vitest/src/screen/index.d.ts +8 -0
- package/out-tsc/vitest/src/screen/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/spy/index.d.ts +2 -0
- package/out-tsc/vitest/src/spy/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/symbolicate.d.ts +3 -0
- package/out-tsc/vitest/src/symbolicate.d.ts.map +1 -0
- package/out-tsc/vitest/src/ui/ReadyScreen.d.ts +2 -0
- package/out-tsc/vitest/src/ui/ReadyScreen.d.ts.map +1 -0
- package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts +2 -0
- package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts.map +1 -0
- package/out-tsc/vitest/src/ui/index.d.ts +2 -0
- package/out-tsc/vitest/src/ui/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/ui/state.d.ts +20 -0
- package/out-tsc/vitest/src/ui/state.d.ts.map +1 -0
- package/out-tsc/vitest/src/userEvent/index.d.ts +6 -0
- package/out-tsc/vitest/src/userEvent/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/utils/dev-server.d.ts +2 -0
- package/out-tsc/vitest/src/utils/dev-server.d.ts.map +1 -0
- package/out-tsc/vitest/src/utils/emitter.d.ts +16 -0
- package/out-tsc/vitest/src/utils/emitter.d.ts.map +1 -0
- package/out-tsc/vitest/src/waitFor.d.ts +21 -0
- package/out-tsc/vitest/src/waitFor.d.ts.map +1 -0
- package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +1 -0
- package/out-tsc/vitest/vite.config.d.ts +3 -0
- package/out-tsc/vitest/vite.config.d.ts.map +1 -0
- package/package.json +12 -2
- package/src/client/factory.ts +9 -2
- package/src/client/store.ts +16 -0
- package/src/expect/expect.ts +127 -0
- package/src/expect/index.ts +1 -123
- package/src/expect/matchers/toMatchImageSnapshot.ts +50 -0
- package/src/globals.ts +12 -0
- package/src/index.ts +1 -1
- package/src/render/TestComponentOverlay.tsx +22 -2
- package/src/render/index.ts +8 -6
- package/src/runner/context.ts +16 -0
- package/src/runner/factory.ts +7 -1
- package/src/runner/index.ts +5 -0
- package/src/runner/runSuite.ts +4 -0
- package/src/runner/types.ts +7 -1
- package/src/ui/ReadyScreen.tsx +1 -0
- package/src/__tests__/expect.test.ts +0 -627
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the position and dimensions of a view in screen coordinates (points/dp).
|
|
4
|
+
*/
|
|
5
|
+
export interface ViewInfo {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
interface Spec extends TurboModule {
|
|
12
|
+
/**
|
|
13
|
+
* Simulates a native tap at the specified screen coordinates.
|
|
14
|
+
* Returns a promise that resolves when the tap action is complete.
|
|
15
|
+
*/
|
|
16
|
+
simulateTap(x: number, y: number): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Finds a view by its testID (accessibilityIdentifier on iOS, tag on Android).
|
|
19
|
+
* Returns null if no view is found.
|
|
20
|
+
*/
|
|
21
|
+
queryByTestId(testId: string): ViewInfo | null;
|
|
22
|
+
/**
|
|
23
|
+
* Finds all views by testID (accessibilityIdentifier on iOS, tag on Android).
|
|
24
|
+
* Returns an empty array if no views are found.
|
|
25
|
+
*/
|
|
26
|
+
queryAllByTestId(testId: string): ViewInfo[];
|
|
27
|
+
/**
|
|
28
|
+
* Finds a view by its accessibility label.
|
|
29
|
+
* Returns null if no view is found.
|
|
30
|
+
*/
|
|
31
|
+
queryByAccessibilityLabel(label: string): ViewInfo | null;
|
|
32
|
+
/**
|
|
33
|
+
* Finds all views by accessibility label.
|
|
34
|
+
* Returns an empty array if no views are found.
|
|
35
|
+
*/
|
|
36
|
+
queryAllByAccessibilityLabel(label: string): ViewInfo[];
|
|
37
|
+
}
|
|
38
|
+
export type HarnessModule = Spec;
|
|
39
|
+
declare const _default: Spec;
|
|
40
|
+
export default _default;
|
|
41
|
+
//# sourceMappingURL=NativeHarness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeHarness.d.ts","sourceRoot":"","sources":["../src/NativeHarness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,IAAK,SAAQ,WAAW;IAChC;;;OAGG;IACH,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IAE/C;;;OAGG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAC;IAE7C;;;OAGG;IACH,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IAE1D;;;OAGG;IACH,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAC;CACzD;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC;;AAEjC,wBAAiE"}
|
|
@@ -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":"AAkBA,eAAO,MAAM,SAAS,2EAsFrB,CAAC"}
|
package/dist/client/factory.js
CHANGED
|
@@ -8,13 +8,15 @@ 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 { setClient } from './store.js';
|
|
11
12
|
export const getClient = async () => {
|
|
12
13
|
const client = await getBridgeClient(getWSServer(), {
|
|
13
14
|
runTests: async () => {
|
|
14
15
|
throw new Error('Not implemented');
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
|
-
client
|
|
18
|
+
setClient(client);
|
|
19
|
+
client.rpc.$functions.runTests = async (path, options) => {
|
|
18
20
|
if (store.getState().status === 'running') {
|
|
19
21
|
throw new Error('Already running tests');
|
|
20
22
|
}
|
|
@@ -55,7 +57,11 @@ export const getClient = async () => {
|
|
|
55
57
|
const processedTestSuite = options.testNamePattern
|
|
56
58
|
? markTestsAsSkippedByName(collectionResult.testSuite, options.testNamePattern)
|
|
57
59
|
: collectionResult.testSuite;
|
|
58
|
-
const result = await runner.run(
|
|
60
|
+
const result = await runner.run({
|
|
61
|
+
testSuite: processedTestSuite,
|
|
62
|
+
testFilePath: path,
|
|
63
|
+
runner: options.runner,
|
|
64
|
+
});
|
|
59
65
|
return result;
|
|
60
66
|
}
|
|
61
67
|
finally {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/client/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAIxE,eAAO,MAAM,SAAS,GAAI,QAAQ,YAAY,KAAG,IAEhD,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAO,YAOpC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
let clientInstance = null;
|
|
2
|
+
export const setClient = (client) => {
|
|
3
|
+
clientInstance = client;
|
|
4
|
+
};
|
|
5
|
+
export const getClientInstance = () => {
|
|
6
|
+
if (!clientInstance) {
|
|
7
|
+
throw new Error('Bridge client not initialized. This should not happen in normal operation.');
|
|
8
|
+
}
|
|
9
|
+
return clientInstance;
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExpectStatic } from '@vitest/expect';
|
|
2
|
+
import * as chai from 'chai';
|
|
3
|
+
import './setup.js';
|
|
4
|
+
export declare function createExpect(): ExpectStatic;
|
|
5
|
+
declare const globalExpect: ExpectStatic;
|
|
6
|
+
export { assert, should } from 'chai';
|
|
7
|
+
export { chai, globalExpect as expect };
|
|
8
|
+
export type { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectStatic, JestAssertion, Matchers, } from '@vitest/expect';
|
|
9
|
+
//# sourceMappingURL=expect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/expect/expect.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAa,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAS5E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,YAAY,CAAC;AAGpB,wBAAgB,YAAY,IAAI,YAAY,CAwF3C;AAED,QAAA,MAAM,YAAY,EAAE,YAA6B,CAAC;AAQlD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,YAAY,IAAI,MAAM,EAAE,CAAC;AAExC,YAAY,EACV,SAAS,EACT,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,GACT,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// This is adapted version of https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/integrations/chai/index.ts
|
|
2
|
+
// Credits to Vitest team for the original implementation.
|
|
3
|
+
import { addCustomEqualityTesters, ASYMMETRIC_MATCHERS_OBJECT, customMatchers, getState, GLOBAL_EXPECT, setState, } from '@vitest/expect';
|
|
4
|
+
import * as chai from 'chai';
|
|
5
|
+
// Setup additional matchers
|
|
6
|
+
import './setup.js';
|
|
7
|
+
import { toMatchImageSnapshot } from './matchers/toMatchImageSnapshot.js';
|
|
8
|
+
export function createExpect() {
|
|
9
|
+
const expect = ((value, message) => {
|
|
10
|
+
const { assertionCalls } = getState(expect);
|
|
11
|
+
setState({ assertionCalls: assertionCalls + 1 }, expect);
|
|
12
|
+
return chai.expect(value, message);
|
|
13
|
+
});
|
|
14
|
+
Object.assign(expect, chai.expect);
|
|
15
|
+
Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
|
16
|
+
expect.getState = () => getState(expect);
|
|
17
|
+
expect.setState = (state) => setState(state, expect);
|
|
18
|
+
// @ts-expect-error global is not typed
|
|
19
|
+
const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
|
|
20
|
+
setState({
|
|
21
|
+
// this should also add "snapshotState" that is added conditionally
|
|
22
|
+
...globalState,
|
|
23
|
+
assertionCalls: 0,
|
|
24
|
+
isExpectingAssertions: false,
|
|
25
|
+
isExpectingAssertionsError: null,
|
|
26
|
+
expectedAssertionsNumber: null,
|
|
27
|
+
expectedAssertionsNumberErrorGen: null,
|
|
28
|
+
}, expect);
|
|
29
|
+
// @ts-expect-error untyped
|
|
30
|
+
expect.extend = (matchers) => chai.expect.extend(expect, matchers);
|
|
31
|
+
// @ts-expect-error untyped
|
|
32
|
+
expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
|
33
|
+
// @ts-expect-error untyped
|
|
34
|
+
expect.soft = (...args) => {
|
|
35
|
+
// @ts-expect-error private soft access
|
|
36
|
+
return expect(...args).withContext({ soft: true });
|
|
37
|
+
};
|
|
38
|
+
// @ts-expect-error untyped
|
|
39
|
+
expect.unreachable = (message) => {
|
|
40
|
+
chai.assert.fail(`expected${message ? ` "${message}" ` : ' '}not to be reached`);
|
|
41
|
+
};
|
|
42
|
+
function assertions(expected) {
|
|
43
|
+
const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
|
|
44
|
+
if (Error.captureStackTrace) {
|
|
45
|
+
Error.captureStackTrace(errorGen(), assertions);
|
|
46
|
+
}
|
|
47
|
+
expect.setState({
|
|
48
|
+
expectedAssertionsNumber: expected,
|
|
49
|
+
expectedAssertionsNumberErrorGen: errorGen,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function hasAssertions() {
|
|
53
|
+
const error = new Error('expected any number of assertion, but got none');
|
|
54
|
+
if (Error.captureStackTrace) {
|
|
55
|
+
Error.captureStackTrace(error, hasAssertions);
|
|
56
|
+
}
|
|
57
|
+
expect.setState({
|
|
58
|
+
isExpectingAssertions: true,
|
|
59
|
+
isExpectingAssertionsError: error,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
chai.util.addMethod(expect, 'assertions', assertions);
|
|
63
|
+
chai.util.addMethod(expect, 'hasAssertions', hasAssertions);
|
|
64
|
+
expect.extend(customMatchers);
|
|
65
|
+
expect.extend({
|
|
66
|
+
toMatchImageSnapshot,
|
|
67
|
+
});
|
|
68
|
+
return expect;
|
|
69
|
+
}
|
|
70
|
+
const globalExpect = createExpect();
|
|
71
|
+
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
72
|
+
value: globalExpect,
|
|
73
|
+
writable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
});
|
|
76
|
+
export { assert, should } from 'chai';
|
|
77
|
+
export { chai, globalExpect as expect };
|
package/dist/expect/index.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import * as chai from 'chai';
|
|
3
|
-
import './setup.js';
|
|
4
|
-
export declare function createExpect(): ExpectStatic;
|
|
5
|
-
declare const globalExpect: ExpectStatic;
|
|
6
|
-
export { assert, should } from 'chai';
|
|
7
|
-
export { chai, globalExpect as expect };
|
|
8
|
-
export type { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectStatic, JestAssertion, Matchers, } from '@vitest/expect';
|
|
1
|
+
export * from './expect.js';
|
|
9
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expect/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expect/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/expect/index.js
CHANGED
|
@@ -1,73 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// Credits to Vitest team for the original implementation.
|
|
3
|
-
import { addCustomEqualityTesters, ASYMMETRIC_MATCHERS_OBJECT, customMatchers, getState, GLOBAL_EXPECT, setState, } from '@vitest/expect';
|
|
4
|
-
import * as chai from 'chai';
|
|
5
|
-
// Setup additional matchers
|
|
6
|
-
import './setup.js';
|
|
7
|
-
export function createExpect() {
|
|
8
|
-
const expect = ((value, message) => {
|
|
9
|
-
const { assertionCalls } = getState(expect);
|
|
10
|
-
setState({ assertionCalls: assertionCalls + 1 }, expect);
|
|
11
|
-
return chai.expect(value, message);
|
|
12
|
-
});
|
|
13
|
-
Object.assign(expect, chai.expect);
|
|
14
|
-
Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
|
15
|
-
expect.getState = () => getState(expect);
|
|
16
|
-
expect.setState = (state) => setState(state, expect);
|
|
17
|
-
// @ts-expect-error global is not typed
|
|
18
|
-
const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
|
|
19
|
-
setState({
|
|
20
|
-
// this should also add "snapshotState" that is added conditionally
|
|
21
|
-
...globalState,
|
|
22
|
-
assertionCalls: 0,
|
|
23
|
-
isExpectingAssertions: false,
|
|
24
|
-
isExpectingAssertionsError: null,
|
|
25
|
-
expectedAssertionsNumber: null,
|
|
26
|
-
expectedAssertionsNumberErrorGen: null,
|
|
27
|
-
}, expect);
|
|
28
|
-
// @ts-expect-error untyped
|
|
29
|
-
expect.extend = (matchers) => chai.expect.extend(expect, matchers);
|
|
30
|
-
// @ts-expect-error untyped
|
|
31
|
-
expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
|
32
|
-
// @ts-expect-error untyped
|
|
33
|
-
expect.soft = (...args) => {
|
|
34
|
-
// @ts-expect-error private soft access
|
|
35
|
-
return expect(...args).withContext({ soft: true });
|
|
36
|
-
};
|
|
37
|
-
// @ts-expect-error untyped
|
|
38
|
-
expect.unreachable = (message) => {
|
|
39
|
-
chai.assert.fail(`expected${message ? ` "${message}" ` : ' '}not to be reached`);
|
|
40
|
-
};
|
|
41
|
-
function assertions(expected) {
|
|
42
|
-
const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
|
|
43
|
-
if (Error.captureStackTrace) {
|
|
44
|
-
Error.captureStackTrace(errorGen(), assertions);
|
|
45
|
-
}
|
|
46
|
-
expect.setState({
|
|
47
|
-
expectedAssertionsNumber: expected,
|
|
48
|
-
expectedAssertionsNumberErrorGen: errorGen,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function hasAssertions() {
|
|
52
|
-
const error = new Error('expected any number of assertion, but got none');
|
|
53
|
-
if (Error.captureStackTrace) {
|
|
54
|
-
Error.captureStackTrace(error, hasAssertions);
|
|
55
|
-
}
|
|
56
|
-
expect.setState({
|
|
57
|
-
isExpectingAssertions: true,
|
|
58
|
-
isExpectingAssertionsError: error,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
chai.util.addMethod(expect, 'assertions', assertions);
|
|
62
|
-
chai.util.addMethod(expect, 'hasAssertions', hasAssertions);
|
|
63
|
-
expect.extend(customMatchers);
|
|
64
|
-
return expect;
|
|
65
|
-
}
|
|
66
|
-
const globalExpect = createExpect();
|
|
67
|
-
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
68
|
-
value: globalExpect,
|
|
69
|
-
writable: true,
|
|
70
|
-
configurable: true,
|
|
71
|
-
});
|
|
72
|
-
export { assert, should } from 'chai';
|
|
73
|
-
export { chai, globalExpect as expect };
|
|
1
|
+
export * from './expect.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MatcherState } from '@vitest/expect';
|
|
2
|
+
import { type ImageSnapshotOptions } from '@react-native-harness/bridge';
|
|
3
|
+
type ScreenshotResult = {
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function toMatchImageSnapshot(this: MatcherState, received: ScreenshotResult, options: ImageSnapshotOptions): Promise<{
|
|
9
|
+
pass: boolean;
|
|
10
|
+
message: () => string;
|
|
11
|
+
}>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=toMatchImageSnapshot.d.ts.map
|
|
@@ -0,0 +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,EACL,KAAK,oBAAoB,EAE1B,MAAM,8BAA8B,CAAC;AAGtC,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,CA+BnD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getClientInstance } from '../../client/store.js';
|
|
2
|
+
import { generateTransferId, } from '@react-native-harness/bridge';
|
|
3
|
+
import { getHarnessContext } from '../../runner/index.js';
|
|
4
|
+
export async function toMatchImageSnapshot(received, options) {
|
|
5
|
+
const client = getClientInstance();
|
|
6
|
+
const context = getHarnessContext();
|
|
7
|
+
const transferId = generateTransferId();
|
|
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
|
+
}, {
|
|
15
|
+
width: received.width,
|
|
16
|
+
height: received.height,
|
|
17
|
+
});
|
|
18
|
+
const result = await client.rpc['test.matchImageSnapshot'](screenshotFile, context.testFilePath, options, context.runner);
|
|
19
|
+
return {
|
|
20
|
+
pass: result.pass,
|
|
21
|
+
message: () => result.message,
|
|
22
|
+
};
|
|
23
|
+
}
|
package/dist/globals.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ImageSnapshotOptions } from '@react-native-harness/bridge';
|
|
1
2
|
export type HarnessGlobal = {
|
|
2
3
|
appRegistryComponentName: string;
|
|
3
4
|
webSocketPort?: number;
|
|
@@ -5,5 +6,14 @@ export type HarnessGlobal = {
|
|
|
5
6
|
declare global {
|
|
6
7
|
var RN_HARNESS: HarnessGlobal | undefined;
|
|
7
8
|
}
|
|
9
|
+
declare module '@vitest/expect' {
|
|
10
|
+
interface Matchers {
|
|
11
|
+
/**
|
|
12
|
+
* Match the received screenshot against a stored snapshot.
|
|
13
|
+
* Creates a new snapshot if one doesn't exist.
|
|
14
|
+
*/
|
|
15
|
+
toMatchImageSnapshot(options: ImageSnapshotOptions): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
export declare const getHarnessGlobal: () => HarnessGlobal;
|
|
9
19
|
//# sourceMappingURL=globals.d.ts.map
|
package/dist/globals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,wBAAwB,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,UAAU,EAAE,aAAa,GAAG,SAAS,CAAC;CAC3C;AAED,eAAO,MAAM,gBAAgB,QAAO,aAQnC,CAAC"}
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,MAAM,MAAM,aAAa,GAAG;IAC1B,wBAAwB,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,UAAU,EAAE,aAAa,GAAG,SAAS,CAAC;CAC3C;AAED,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,QAAQ;QAChB;;;WAGG;QACH,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACpE;CACF;AAED,eAAO,MAAM,gBAAgB,QAAO,aAQnC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AACxB,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,EAAE,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACzD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestComponentOverlay.d.ts","sourceRoot":"","sources":["../../src/render/TestComponentOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TestComponentOverlay.d.ts","sourceRoot":"","sources":["../../src/render/TestComponentOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAqBzC,eAAO,MAAM,oBAAoB,QAAO,KAAK,CAAC,YAAY,GAAG,IAqC5D,CAAC"}
|
|
@@ -4,14 +4,33 @@ import { View, StyleSheet } from 'react-native';
|
|
|
4
4
|
import { useRenderedElement } from '../ui/state.js';
|
|
5
5
|
import { store } from '../ui/state.js';
|
|
6
6
|
import { ErrorBoundary } from './ErrorBoundary.js';
|
|
7
|
+
/**
|
|
8
|
+
* Waits for the native view hierarchy to be fully updated.
|
|
9
|
+
* Uses double requestAnimationFrame to ensure native has processed
|
|
10
|
+
* all view creation commands after React's commit phase.
|
|
11
|
+
*/
|
|
12
|
+
const waitForNativeViewHierarchy = () => {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
requestAnimationFrame(() => {
|
|
15
|
+
requestAnimationFrame(() => {
|
|
16
|
+
resolve();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
};
|
|
7
21
|
export const TestComponentOverlay = () => {
|
|
8
22
|
const { element, key } = useRenderedElement();
|
|
9
23
|
useEffect(() => {
|
|
10
24
|
// Call onRenderCallback when element changes
|
|
11
25
|
const callback = store.getState().onRenderCallback;
|
|
12
26
|
if (callback) {
|
|
13
|
-
callback
|
|
14
|
-
|
|
27
|
+
// Wait for native view hierarchy to be fully updated before calling callback.
|
|
28
|
+
// useEffect fires after React commits, but native processes commands async.
|
|
29
|
+
// Double rAF ensures native has finished processing all view creation.
|
|
30
|
+
waitForNativeViewHierarchy().then(() => {
|
|
31
|
+
callback();
|
|
32
|
+
store.getState().setOnRenderCallback(null);
|
|
33
|
+
});
|
|
15
34
|
}
|
|
16
35
|
}, [element]);
|
|
17
36
|
if (!element) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAY9D,eAAO,MAAM,MAAM,GACjB,SAAS,KAAK,CAAC,YAAY,EAC3B,UAAS,aAAkB,KAC1B,OAAO,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAY9D,eAAO,MAAM,MAAM,GACjB,SAAS,KAAK,CAAC,YAAY,EAC3B,UAAS,aAAkB,KAC1B,OAAO,CAAC,YAAY,CA6EtB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/render/index.js
CHANGED
|
@@ -14,13 +14,15 @@ export const render = async (element, options = {}) => {
|
|
|
14
14
|
store.getState().setOnLayoutCallback(null);
|
|
15
15
|
store.getState().setOnRenderCallback(null);
|
|
16
16
|
}
|
|
17
|
-
// Create a promise that resolves when the element is
|
|
18
|
-
|
|
17
|
+
// Create a promise that resolves when the element is rendered.
|
|
18
|
+
// We use onRenderCallback which fires in useEffect, guaranteeing that
|
|
19
|
+
// React has committed all children to the native view hierarchy.
|
|
20
|
+
const renderPromise = new Promise((resolve, reject) => {
|
|
19
21
|
const timeoutId = setTimeout(() => {
|
|
20
|
-
store.getState().
|
|
22
|
+
store.getState().setOnRenderCallback(null);
|
|
21
23
|
reject(new Error(`Render timeout: Element did not mount within ${timeout}ms`));
|
|
22
24
|
}, timeout);
|
|
23
|
-
store.getState().
|
|
25
|
+
store.getState().setOnRenderCallback(() => {
|
|
24
26
|
clearTimeout(timeoutId);
|
|
25
27
|
resolve();
|
|
26
28
|
});
|
|
@@ -28,8 +30,8 @@ export const render = async (element, options = {}) => {
|
|
|
28
30
|
// Wrap and set the element in state (key is generated automatically)
|
|
29
31
|
const wrappedElement = wrapElement(element, wrapper);
|
|
30
32
|
store.getState().setRenderedElement(wrappedElement);
|
|
31
|
-
// Wait for
|
|
32
|
-
await
|
|
33
|
+
// Wait for useEffect to fire, ensuring all children are committed
|
|
34
|
+
await renderPromise;
|
|
33
35
|
const rerender = async (newElement) => {
|
|
34
36
|
if (store.getState().renderedElement === null) {
|
|
35
37
|
throw new Error('No element is currently rendered. Call render() first.');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HostInstance } from 'react-native';
|
|
2
|
+
export declare const setRoot: (rootInstance: HostInstance) => void;
|
|
3
|
+
declare const queryByTestId: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default | null, queryAllByTestId: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default[], getByTestId: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default | null, getAllByTestId: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default[], findByTestId: (params: string) => Promise<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>, findAllByTestId: (params: string) => Promise<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default[]>;
|
|
4
|
+
declare const queryById: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default | null, queryAllById: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default[], getId: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default | null, getAllById: (params: string) => import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default[], findById: (params: string) => Promise<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>, findAllById: (params: string) => Promise<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default[]>;
|
|
5
|
+
export { queryByTestId, queryAllByTestId, getByTestId, getAllByTestId, findByTestId, findAllByTestId, };
|
|
6
|
+
export { queryById, queryAllById, getId, getAllById, findById, findAllById };
|
|
7
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/render/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAM5C,eAAO,MAAM,OAAO,GAAI,cAAc,YAAY,SAEjD,CAAC;AA6IF,QAAA,MACW,aAAa,8HACV,gBAAgB,yHACrB,WAAW,8HACR,cAAc,yHAChB,YAAY,gIACT,eAAe,gIAG3B,CAAC;AACF,QAAA,MACW,SAAS,8HACN,YAAY,yHACjB,KAAK,8HACF,UAAU,yHACZ,QAAQ,gIACL,WAAW,gIAC+B,CAAC;AAExD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// import { store } from '../ui/state.js';
|
|
2
|
+
import { waitUntil } from '../waitFor.js';
|
|
3
|
+
let root = null;
|
|
4
|
+
export const setRoot = (rootInstance) => {
|
|
5
|
+
root = rootInstance;
|
|
6
|
+
};
|
|
7
|
+
const getRoot = () => {
|
|
8
|
+
const container = root;
|
|
9
|
+
if (!container) {
|
|
10
|
+
throw new Error('You need to render a component first!');
|
|
11
|
+
}
|
|
12
|
+
const ownerDocument = container.ownerDocument;
|
|
13
|
+
if (!ownerDocument) {
|
|
14
|
+
throw new Error('This feature is supported in React Native 0.82 and later!');
|
|
15
|
+
}
|
|
16
|
+
return ownerDocument.getRootNode();
|
|
17
|
+
};
|
|
18
|
+
const findNodeByPredicate = (predicate) => {
|
|
19
|
+
const queue = [getRoot()];
|
|
20
|
+
while (queue.length > 0) {
|
|
21
|
+
const node = queue.shift();
|
|
22
|
+
if (predicate(node)) {
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
for (const child of node.children) {
|
|
26
|
+
queue.push(child);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
const findNodesByPredicate = (predicate) => {
|
|
32
|
+
const nodes = [];
|
|
33
|
+
const queue = [getRoot()];
|
|
34
|
+
while (queue.length > 0) {
|
|
35
|
+
const node = queue.shift();
|
|
36
|
+
if (predicate(node)) {
|
|
37
|
+
nodes.push(node);
|
|
38
|
+
}
|
|
39
|
+
for (const child of node.children) {
|
|
40
|
+
queue.push(child);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return nodes;
|
|
44
|
+
};
|
|
45
|
+
const getFiberOfHostInstance = (hostInstance) => {
|
|
46
|
+
// This should be considered as 'reaching into the implementation details' of React Native.
|
|
47
|
+
// Not perfect, but it's the only way to get the props of the host instance.
|
|
48
|
+
return (hostInstance
|
|
49
|
+
.__internalInstanceHandle || null);
|
|
50
|
+
};
|
|
51
|
+
const getPropsOfHostInstance = (hostInstance) => {
|
|
52
|
+
return getFiberOfHostInstance(hostInstance)?.memoizedProps || {};
|
|
53
|
+
};
|
|
54
|
+
const findBy = (predicate, options) => {
|
|
55
|
+
return waitUntil(() => findNodeByPredicate(predicate), options);
|
|
56
|
+
};
|
|
57
|
+
const findAllBy = (predicate, options) => {
|
|
58
|
+
return waitUntil(() => {
|
|
59
|
+
const nodes = findNodesByPredicate(predicate);
|
|
60
|
+
if (nodes.length === 0) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return nodes;
|
|
64
|
+
}, options);
|
|
65
|
+
};
|
|
66
|
+
const queryBy = (predicate) => {
|
|
67
|
+
return findNodeByPredicate(predicate);
|
|
68
|
+
};
|
|
69
|
+
const queryAllBy = (predicate) => {
|
|
70
|
+
return findNodesByPredicate(predicate);
|
|
71
|
+
};
|
|
72
|
+
const getBy = (predicate) => {
|
|
73
|
+
const node = queryBy(predicate);
|
|
74
|
+
if (!node) {
|
|
75
|
+
throw new Error(`No node found with predicate ${predicate}`);
|
|
76
|
+
}
|
|
77
|
+
return node;
|
|
78
|
+
};
|
|
79
|
+
const getAllBy = (predicate) => {
|
|
80
|
+
const nodes = queryAllBy(predicate);
|
|
81
|
+
if (nodes.length === 0) {
|
|
82
|
+
throw new Error(`No nodes found with predicate ${predicate}`);
|
|
83
|
+
}
|
|
84
|
+
return nodes;
|
|
85
|
+
};
|
|
86
|
+
const createQueries = (predicate) => {
|
|
87
|
+
return {
|
|
88
|
+
findBy: (params) => findBy((node) => predicate(node, params)),
|
|
89
|
+
findAllBy: (params) => findAllBy((node) => predicate(node, params)),
|
|
90
|
+
queryBy: (params) => queryBy((node) => predicate(node, params)),
|
|
91
|
+
queryAllBy: (params) => queryAllBy((node) => predicate(node, params)),
|
|
92
|
+
getBy: (params) => getBy((node) => predicate(node, params)),
|
|
93
|
+
getAllBy: (params) => getAllBy((node) => predicate(node, params)),
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const { queryBy: queryByTestId, queryAllBy: queryAllByTestId, getBy: getByTestId, getAllBy: getAllByTestId, findBy: findByTestId, findAllBy: findAllByTestId, } = createQueries((node, testId) => getPropsOfHostInstance(node).testID === testId);
|
|
97
|
+
const { queryBy: queryById, queryAllBy: queryAllById, getBy: getId, getAllBy: getAllById, findBy: findById, findAllBy: findAllById, } = createQueries((node, id) => node.id === id);
|
|
98
|
+
export { queryByTestId, queryAllByTestId, getByTestId, getAllByTestId, findByTestId, findAllByTestId, };
|
|
99
|
+
export { queryById, queryAllById, getId, getAllById, findById, findAllById };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TestSuiteResult } from '@react-native-harness/bridge';
|
|
2
|
+
/**
|
|
3
|
+
* Runs tests from a specific module programmatically and returns the results.
|
|
4
|
+
*
|
|
5
|
+
* @param moduleId The require.resolveWeak call to the module, returning the module ID
|
|
6
|
+
* @returns The result of the test suite execution
|
|
7
|
+
*/
|
|
8
|
+
export declare const runHarnessTestsInModule: (loader: () => unknown) => Promise<TestSuiteResult>;
|
|
9
|
+
//# sourceMappingURL=runHarnessTestsInModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runHarnessTestsInModule.d.ts","sourceRoot":"","sources":["../src/runHarnessTestsInModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,8BAA8B,CAAC;AAoCtC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,OAAO,KACpB,OAAO,CAAC,eAAe,CAuBzB,CAAC"}
|