@react-native-harness/runtime 1.0.0-canary.1764675030942 → 1.0.0-canary.1766225407244
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/collection.d.ts +39 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +224 -0
- package/dist/getEntryComponent.d.ts +6 -0
- package/dist/getEntryComponent.d.ts.map +1 -0
- package/dist/getEntryComponent.js +6 -0
- package/dist/module.d.ts +3 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +26 -0
- package/dist/module.web.d.ts +2 -0
- package/dist/module.web.d.ts.map +1 -0
- package/dist/module.web.js +12 -0
- package/dist/package.json +37 -0
- package/dist/rntl/client.d.ts +3 -0
- package/dist/rntl/client.d.ts.map +1 -0
- package/dist/rntl/client.js +8 -0
- package/{out-tsc/vitest/src/collector/functions.d.ts → dist/rntl/describe.d.ts} +21 -4
- package/dist/rntl/describe.d.ts.map +1 -0
- package/dist/rntl/describe.js +216 -0
- package/dist/rntl/expect.d.ts +11 -0
- package/dist/rntl/expect.d.ts.map +1 -0
- package/dist/rntl/expect.js +19 -0
- package/dist/rntl/fn.d.ts +2 -0
- package/dist/rntl/fn.d.ts.map +1 -0
- package/dist/rntl/fn.js +1 -0
- package/dist/rntl/render.d.ts +4 -0
- package/dist/rntl/render.d.ts.map +1 -0
- package/dist/rntl/render.js +11 -0
- package/dist/rntl/screen.d.ts +45 -0
- package/dist/rntl/screen.d.ts.map +1 -0
- package/dist/rntl/screen.js +31 -0
- package/dist/rntl/userEvent.d.ts +22 -0
- package/dist/rntl/userEvent.d.ts.map +1 -0
- package/dist/rntl/userEvent.js +19 -0
- package/dist/runner.d.ts +4 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +115 -0
- package/{out-tsc/vitest/src/client/factory.d.ts → dist/runtime.d.ts} +1 -1
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +39 -0
- package/dist/state.d.ts +25 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +37 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/ui/UI.d.ts +13 -0
- package/dist/ui/UI.d.ts.map +1 -0
- package/dist/ui/UI.js +121 -0
- package/package.json +2 -6
- package/dist/client/store.d.ts +0 -4
- package/dist/client/store.d.ts.map +0 -1
- package/dist/client/store.js +0 -10
- package/dist/expect/expect.d.ts +0 -9
- package/dist/expect/expect.d.ts.map +0 -1
- package/dist/expect/expect.js +0 -77
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts +0 -12
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts.map +0 -1
- package/dist/expect/matchers/toMatchImageSnapshot.js +0 -11
- package/dist/render/queries.d.ts +0 -7
- package/dist/render/queries.d.ts.map +0 -1
- package/dist/render/queries.js +0 -99
- package/dist/runner/context.d.ts +0 -10
- package/dist/runner/context.d.ts.map +0 -1
- package/dist/runner/context.js +0 -6
- package/dist/screen/index.d.ts +0 -8
- package/dist/screen/index.d.ts.map +0 -1
- package/dist/screen/index.js +0 -18
- package/dist/userEvent/index.d.ts +0 -6
- package/dist/userEvent/index.d.ts.map +0 -1
- package/dist/userEvent/index.js +0 -10
- package/out-tsc/vitest/src/__tests__/collector.test.d.ts +0 -2
- package/out-tsc/vitest/src/__tests__/collector.test.d.ts.map +0 -1
- package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts +0 -2
- package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts.map +0 -1
- package/out-tsc/vitest/src/__tests__/expect.test.d.ts +0 -2
- package/out-tsc/vitest/src/__tests__/expect.test.d.ts.map +0 -1
- package/out-tsc/vitest/src/__tests__/spy.test.d.ts +0 -2
- package/out-tsc/vitest/src/__tests__/spy.test.d.ts.map +0 -1
- package/out-tsc/vitest/src/bundler/bundle.d.ts +0 -2
- package/out-tsc/vitest/src/bundler/bundle.d.ts.map +0 -1
- package/out-tsc/vitest/src/bundler/errors.d.ts +0 -15
- package/out-tsc/vitest/src/bundler/errors.d.ts.map +0 -1
- package/out-tsc/vitest/src/bundler/evaluate.d.ts +0 -2
- package/out-tsc/vitest/src/bundler/evaluate.d.ts.map +0 -1
- package/out-tsc/vitest/src/bundler/factory.d.ts +0 -3
- package/out-tsc/vitest/src/bundler/factory.d.ts.map +0 -1
- package/out-tsc/vitest/src/bundler/index.d.ts +0 -4
- package/out-tsc/vitest/src/bundler/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/bundler/types.d.ts +0 -7
- package/out-tsc/vitest/src/bundler/types.d.ts.map +0 -1
- package/out-tsc/vitest/src/client/factory.d.ts.map +0 -1
- package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts +0 -8
- package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts.map +0 -1
- package/out-tsc/vitest/src/client/getWSServer.d.ts +0 -2
- package/out-tsc/vitest/src/client/getWSServer.d.ts.map +0 -1
- package/out-tsc/vitest/src/client/index.d.ts +0 -2
- package/out-tsc/vitest/src/client/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/client/setup-files.d.ts +0 -12
- package/out-tsc/vitest/src/client/setup-files.d.ts.map +0 -1
- package/out-tsc/vitest/src/client/store.d.ts +0 -4
- package/out-tsc/vitest/src/client/store.d.ts.map +0 -1
- package/out-tsc/vitest/src/collector/errors.d.ts +0 -8
- package/out-tsc/vitest/src/collector/errors.d.ts.map +0 -1
- package/out-tsc/vitest/src/collector/factory.d.ts +0 -3
- package/out-tsc/vitest/src/collector/factory.d.ts.map +0 -1
- package/out-tsc/vitest/src/collector/functions.d.ts.map +0 -1
- package/out-tsc/vitest/src/collector/index.d.ts +0 -5
- package/out-tsc/vitest/src/collector/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/collector/types.d.ts +0 -10
- package/out-tsc/vitest/src/collector/types.d.ts.map +0 -1
- package/out-tsc/vitest/src/collector/validation.d.ts +0 -4
- package/out-tsc/vitest/src/collector/validation.d.ts.map +0 -1
- package/out-tsc/vitest/src/constants.d.ts +0 -2
- package/out-tsc/vitest/src/constants.d.ts.map +0 -1
- package/out-tsc/vitest/src/entry-point.d.ts +0 -2
- package/out-tsc/vitest/src/entry-point.d.ts.map +0 -1
- package/out-tsc/vitest/src/errors.d.ts +0 -6
- package/out-tsc/vitest/src/errors.d.ts.map +0 -1
- package/out-tsc/vitest/src/expect/index.d.ts +0 -14
- package/out-tsc/vitest/src/expect/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts +0 -7
- package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts.map +0 -1
- package/out-tsc/vitest/src/expect/setup.d.ts +0 -2
- package/out-tsc/vitest/src/expect/setup.d.ts.map +0 -1
- package/out-tsc/vitest/src/filtering/index.d.ts +0 -2
- package/out-tsc/vitest/src/filtering/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/filtering/testNameFilter.d.ts +0 -12
- package/out-tsc/vitest/src/filtering/testNameFilter.d.ts.map +0 -1
- package/out-tsc/vitest/src/globals.d.ts +0 -8
- package/out-tsc/vitest/src/globals.d.ts.map +0 -1
- package/out-tsc/vitest/src/index.d.ts +0 -13
- package/out-tsc/vitest/src/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/initialize.d.ts +0 -2
- package/out-tsc/vitest/src/initialize.d.ts.map +0 -1
- package/out-tsc/vitest/src/jest-mock.d.ts +0 -2
- package/out-tsc/vitest/src/jest-mock.d.ts.map +0 -1
- package/out-tsc/vitest/src/mocker/index.d.ts +0 -2
- package/out-tsc/vitest/src/mocker/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/mocker/registry.d.ts +0 -7
- package/out-tsc/vitest/src/mocker/registry.d.ts.map +0 -1
- package/out-tsc/vitest/src/mocker/types.d.ts +0 -6
- package/out-tsc/vitest/src/mocker/types.d.ts.map +0 -1
- package/out-tsc/vitest/src/namespace.d.ts +0 -18
- package/out-tsc/vitest/src/namespace.d.ts.map +0 -1
- package/out-tsc/vitest/src/render/ErrorBoundary.d.ts +0 -17
- package/out-tsc/vitest/src/render/ErrorBoundary.d.ts.map +0 -1
- package/out-tsc/vitest/src/render/TestComponentOverlay.d.ts +0 -3
- package/out-tsc/vitest/src/render/TestComponentOverlay.d.ts.map +0 -1
- package/out-tsc/vitest/src/render/cleanup.d.ts +0 -2
- package/out-tsc/vitest/src/render/cleanup.d.ts.map +0 -1
- package/out-tsc/vitest/src/render/index.d.ts +0 -6
- package/out-tsc/vitest/src/render/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/render/setup.d.ts +0 -2
- package/out-tsc/vitest/src/render/setup.d.ts.map +0 -1
- package/out-tsc/vitest/src/render/types.d.ts +0 -12
- package/out-tsc/vitest/src/render/types.d.ts.map +0 -1
- package/out-tsc/vitest/src/runner/errors.d.ts +0 -11
- package/out-tsc/vitest/src/runner/errors.d.ts.map +0 -1
- package/out-tsc/vitest/src/runner/factory.d.ts +0 -3
- package/out-tsc/vitest/src/runner/factory.d.ts.map +0 -1
- package/out-tsc/vitest/src/runner/hooks.d.ts +0 -4
- package/out-tsc/vitest/src/runner/hooks.d.ts.map +0 -1
- package/out-tsc/vitest/src/runner/index.d.ts +0 -4
- package/out-tsc/vitest/src/runner/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/runner/runSuite.d.ts +0 -4
- package/out-tsc/vitest/src/runner/runSuite.d.ts.map +0 -1
- package/out-tsc/vitest/src/runner/types.d.ts +0 -13
- package/out-tsc/vitest/src/runner/types.d.ts.map +0 -1
- package/out-tsc/vitest/src/screen/index.d.ts +0 -8
- package/out-tsc/vitest/src/screen/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/spy/index.d.ts +0 -2
- package/out-tsc/vitest/src/spy/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/symbolicate.d.ts +0 -3
- package/out-tsc/vitest/src/symbolicate.d.ts.map +0 -1
- package/out-tsc/vitest/src/ui/ReadyScreen.d.ts +0 -2
- package/out-tsc/vitest/src/ui/ReadyScreen.d.ts.map +0 -1
- package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts +0 -2
- package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts.map +0 -1
- package/out-tsc/vitest/src/ui/index.d.ts +0 -2
- package/out-tsc/vitest/src/ui/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/ui/state.d.ts +0 -20
- package/out-tsc/vitest/src/ui/state.d.ts.map +0 -1
- package/out-tsc/vitest/src/userEvent/index.d.ts +0 -6
- package/out-tsc/vitest/src/userEvent/index.d.ts.map +0 -1
- package/out-tsc/vitest/src/utils/dev-server.d.ts +0 -2
- package/out-tsc/vitest/src/utils/dev-server.d.ts.map +0 -1
- package/out-tsc/vitest/src/utils/emitter.d.ts +0 -16
- package/out-tsc/vitest/src/utils/emitter.d.ts.map +0 -1
- package/out-tsc/vitest/src/waitFor.d.ts +0 -21
- package/out-tsc/vitest/src/waitFor.d.ts.map +0 -1
- package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +0 -1
- package/out-tsc/vitest/vite.config.d.ts +0 -3
- package/out-tsc/vitest/vite.config.d.ts.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { use, Assertion } from 'chai';
|
|
2
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
3
|
+
import sinonChai from 'sinon-chai';
|
|
4
|
+
import { getClient } from './client.js';
|
|
5
|
+
use(chaiAsPromised);
|
|
6
|
+
use(sinonChai);
|
|
7
|
+
export { expect } from 'chai';
|
|
8
|
+
Assertion.addMethod('toBeDisplayed', async function () {
|
|
9
|
+
const result = await getClient().rpc.executeMatcher(this._obj, 'displayed');
|
|
10
|
+
this.assert(result, 'expected element to be displayed', 'expected element not to be displayed', true, result);
|
|
11
|
+
});
|
|
12
|
+
Assertion.addMethod('toBeDisabled', async function () {
|
|
13
|
+
const result = await getClient().rpc.executeMatcher(this._obj, 'disabled');
|
|
14
|
+
this.assert(result, 'expected element to be disabled', 'expected element not to be disabled', true, result);
|
|
15
|
+
});
|
|
16
|
+
Assertion.addMethod('toBeEnabled', async function () {
|
|
17
|
+
const result = await getClient().rpc.executeMatcher(this._obj, 'enabled');
|
|
18
|
+
this.assert(result, 'expected element to be enabled', 'expected element not to be enabled', true, result);
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../src/rntl/fn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC"}
|
package/dist/rntl/fn.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fake } from 'sinon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/rntl/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,eAAO,MAAM,MAAM,GACjB,MAAM,SAAS,EACf,UAAU,OAAO,KAChB,OAAO,CAAC,IAAI,CAId,CAAC;AAEF,eAAO,MAAM,OAAO,QAAa,OAAO,CAAC,IAAI,CAG5C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { state } from '../state.js';
|
|
2
|
+
import { toggleScreenAccessibility } from './screen.js';
|
|
3
|
+
export const render = async (node, options) => {
|
|
4
|
+
const renderResult = await state.getState().render(node, options ?? {});
|
|
5
|
+
toggleScreenAccessibility(true);
|
|
6
|
+
return renderResult;
|
|
7
|
+
};
|
|
8
|
+
export const cleanup = async () => {
|
|
9
|
+
await state.getState().cleanup();
|
|
10
|
+
toggleScreenAccessibility(false);
|
|
11
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ElementRef, QueryOptions } from '@react-native-harness/interaction-engine';
|
|
2
|
+
declare const readyScreen: {
|
|
3
|
+
readonly findByTestId: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
4
|
+
strict: true;
|
|
5
|
+
} ? ElementRef : ElementRef | null>;
|
|
6
|
+
readonly findAllByTestId: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
7
|
+
strict: true;
|
|
8
|
+
} ? [ElementRef, ...ElementRef[]] : ElementRef[]>;
|
|
9
|
+
readonly findByLabel: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
10
|
+
strict: true;
|
|
11
|
+
} ? ElementRef : ElementRef | null>;
|
|
12
|
+
readonly findAllByLabel: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
13
|
+
strict: true;
|
|
14
|
+
} ? [ElementRef, ...ElementRef[]] : ElementRef[]>;
|
|
15
|
+
readonly findByText: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
16
|
+
strict: true;
|
|
17
|
+
} ? ElementRef : ElementRef | null>;
|
|
18
|
+
readonly findAllByText: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
19
|
+
strict: true;
|
|
20
|
+
} ? [ElementRef, ...ElementRef[]] : ElementRef[]>;
|
|
21
|
+
};
|
|
22
|
+
export type Screen = typeof readyScreen;
|
|
23
|
+
export declare let screen: {
|
|
24
|
+
readonly findByTestId: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
25
|
+
strict: true;
|
|
26
|
+
} ? ElementRef : ElementRef | null>;
|
|
27
|
+
readonly findAllByTestId: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
28
|
+
strict: true;
|
|
29
|
+
} ? [ElementRef, ...ElementRef[]] : ElementRef[]>;
|
|
30
|
+
readonly findByLabel: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
31
|
+
strict: true;
|
|
32
|
+
} ? ElementRef : ElementRef | null>;
|
|
33
|
+
readonly findAllByLabel: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
34
|
+
strict: true;
|
|
35
|
+
} ? [ElementRef, ...ElementRef[]] : ElementRef[]>;
|
|
36
|
+
readonly findByText: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
37
|
+
strict: true;
|
|
38
|
+
} ? ElementRef : ElementRef | null>;
|
|
39
|
+
readonly findAllByText: <TOptions extends QueryOptions>(query: string, options?: TOptions | undefined) => Promise<TOptions extends {
|
|
40
|
+
strict: true;
|
|
41
|
+
} ? [ElementRef, ...ElementRef[]] : ElementRef[]>;
|
|
42
|
+
};
|
|
43
|
+
export declare const toggleScreenAccessibility: (accessible: boolean) => void;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/rntl/screen.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EAEb,MAAM,0CAA0C,CAAC;AA4BlD,QAAA,MAAM,WAAW;4BArBP,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAOkB,IAAI;;+BAR7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAIkB,IAAI;;2BAL7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAOkB,IAAI;;8BAR7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAIkB,IAAI;;0BAL7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAOkB,IAAI;;6BAR7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAIkB,IAAI;;CAuB7B,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,OAAO,WAAW,CAAC;AAiBxC,eAAO,IAAI,MAAM;4BA/CP,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAOkB,IAAI;;+BAR7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAIkB,IAAI;;2BAL7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAOkB,IAAI;;8BAR7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAIkB,IAAI;;0BAL7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAOkB,IAAI;;6BAR7B,QAAQ,SAAS,YAAY,SAC5B,MAAM;gBAIkB,IAAI;;CA0CN,CAAC;AAElC,eAAO,MAAM,yBAAyB,GAAI,YAAY,OAAO,KAAG,IAE/D,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getClient } from './client.js';
|
|
2
|
+
const getFindByQuery = (locationStrategy, multiple) => {
|
|
3
|
+
return (query, options) => {
|
|
4
|
+
// TODO: Fix this
|
|
5
|
+
// @ts-expect-error Fix this
|
|
6
|
+
return getClient().rpc.executeQuery({ locationStrategy, value: query }, { ...options, multiple });
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const readyScreen = {
|
|
10
|
+
findByTestId: getFindByQuery('id', false),
|
|
11
|
+
findAllByTestId: getFindByQuery('id', true),
|
|
12
|
+
findByLabel: getFindByQuery('accessibility id', false),
|
|
13
|
+
findAllByLabel: getFindByQuery('accessibility id', true),
|
|
14
|
+
findByText: getFindByQuery('text', false),
|
|
15
|
+
findAllByText: getFindByQuery('text', true),
|
|
16
|
+
};
|
|
17
|
+
const notImplemented = () => {
|
|
18
|
+
throw new Error("The 'render' method must be called before accessing screen methods. Please ensure you've initialized the component under test.");
|
|
19
|
+
};
|
|
20
|
+
const defaultScreen = {
|
|
21
|
+
findByTestId: notImplemented,
|
|
22
|
+
findAllByTestId: notImplemented,
|
|
23
|
+
findByLabel: notImplemented,
|
|
24
|
+
findAllByLabel: notImplemented,
|
|
25
|
+
findByText: notImplemented,
|
|
26
|
+
findAllByText: notImplemented,
|
|
27
|
+
};
|
|
28
|
+
export let screen = defaultScreen;
|
|
29
|
+
export const toggleScreenAccessibility = (accessible) => {
|
|
30
|
+
screen = accessible ? readyScreen : defaultScreen;
|
|
31
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ElementRef } from '@react-native-harness/interaction-engine';
|
|
2
|
+
export declare const userEvent: {
|
|
3
|
+
press: (elementRef: ElementRef, options?: Omit<{
|
|
4
|
+
elementRef: ElementRef;
|
|
5
|
+
}, "elementRef"> | undefined) => Promise<void>;
|
|
6
|
+
longPress: (elementRef: ElementRef, options?: Omit<{
|
|
7
|
+
elementRef: ElementRef;
|
|
8
|
+
}, "elementRef"> | undefined) => Promise<void>;
|
|
9
|
+
type: (elementRef: ElementRef, options?: Omit<{
|
|
10
|
+
elementRef: ElementRef;
|
|
11
|
+
text: string;
|
|
12
|
+
}, "elementRef"> | undefined) => Promise<void>;
|
|
13
|
+
clear: (elementRef: ElementRef, options?: Omit<{
|
|
14
|
+
elementRef: ElementRef;
|
|
15
|
+
}, "elementRef"> | undefined) => Promise<void>;
|
|
16
|
+
scroll: (elementRef: ElementRef, options?: Omit<{
|
|
17
|
+
elementRef: ElementRef;
|
|
18
|
+
direction: "up" | "down" | "left" | "right";
|
|
19
|
+
distance: number;
|
|
20
|
+
}, "elementRef"> | undefined) => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=userEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userEvent.d.ts","sourceRoot":"","sources":["../../src/rntl/userEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACX,MAAM,0CAA0C,CAAC;AAkBlD,eAAO,MAAM,SAAS;wBAbN,UAAU;;;4BAAV,UAAU;;;uBAAV,UAAU;;;;wBAAV,UAAU;;;yBAAV,UAAU;;;;;CAmBzB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getClient } from './client.js';
|
|
2
|
+
const getUserEventAction = (actionType) => {
|
|
3
|
+
return (elementRef, options) => {
|
|
4
|
+
return getClient().rpc.executeAction({
|
|
5
|
+
type: actionType,
|
|
6
|
+
payload: {
|
|
7
|
+
elementRef,
|
|
8
|
+
...(options || {}),
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const userEvent = {
|
|
14
|
+
press: getUserEventAction('press'),
|
|
15
|
+
longPress: getUserEventAction('longPress'),
|
|
16
|
+
type: getUserEventAction('type'),
|
|
17
|
+
clear: getUserEventAction('clear'),
|
|
18
|
+
scroll: getUserEventAction('scroll'),
|
|
19
|
+
};
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA0E5E,wBAAsB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAmErE"}
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
async function runHooks(hooks) {
|
|
2
|
+
for (const hook of hooks) {
|
|
3
|
+
await hook();
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
async function runTest(test, suite) {
|
|
7
|
+
const startTime = Date.now();
|
|
8
|
+
try {
|
|
9
|
+
if (test.status === 'skipped') {
|
|
10
|
+
console.log(`- ${test.name} (skipped)`);
|
|
11
|
+
return {
|
|
12
|
+
name: test.name,
|
|
13
|
+
status: 'skipped',
|
|
14
|
+
duration: 0,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (test.status === 'todo') {
|
|
18
|
+
console.log(`- ${test.name} (todo)`);
|
|
19
|
+
return {
|
|
20
|
+
name: test.name,
|
|
21
|
+
status: 'todo',
|
|
22
|
+
duration: 0,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Run all beforeEach hooks from the current suite and its parents
|
|
26
|
+
await runHooks(suite.beforeEach);
|
|
27
|
+
// Run the actual test
|
|
28
|
+
await test.fn();
|
|
29
|
+
// Run all afterEach hooks from the current suite and its parents
|
|
30
|
+
await runHooks(suite.afterEach);
|
|
31
|
+
const duration = Date.now() - startTime;
|
|
32
|
+
console.log(`✓ ${test.name}`);
|
|
33
|
+
return {
|
|
34
|
+
name: test.name,
|
|
35
|
+
status: 'passed',
|
|
36
|
+
duration,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const duration = Date.now() - startTime;
|
|
41
|
+
console.error(`✗ ${test.name}`);
|
|
42
|
+
console.error(error);
|
|
43
|
+
return {
|
|
44
|
+
name: test.name,
|
|
45
|
+
status: 'failed',
|
|
46
|
+
error: {
|
|
47
|
+
name: typeof error === 'object' && error !== null && 'name' in error
|
|
48
|
+
? error.name
|
|
49
|
+
: 'Unknown error',
|
|
50
|
+
message: typeof error === 'object' && error !== null && 'message' in error
|
|
51
|
+
? error.message
|
|
52
|
+
: JSON.stringify(error),
|
|
53
|
+
stack: typeof error === 'object' && error !== null && 'stack' in error
|
|
54
|
+
? error.stack
|
|
55
|
+
: undefined,
|
|
56
|
+
},
|
|
57
|
+
duration,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export async function runSuite(suite) {
|
|
62
|
+
console.log(`\n${suite.name}`);
|
|
63
|
+
const startTime = Date.now();
|
|
64
|
+
const testResults = [];
|
|
65
|
+
const suiteResults = [];
|
|
66
|
+
let suiteError;
|
|
67
|
+
try {
|
|
68
|
+
// Run beforeAll hooks
|
|
69
|
+
await runHooks(suite.beforeAll);
|
|
70
|
+
// Run all tests in the current suite
|
|
71
|
+
for (const test of suite.tests) {
|
|
72
|
+
const result = await runTest(test, suite);
|
|
73
|
+
testResults.push(result);
|
|
74
|
+
}
|
|
75
|
+
// Run all child suites
|
|
76
|
+
for (const childSuite of suite.suites) {
|
|
77
|
+
const result = await runSuite(childSuite);
|
|
78
|
+
suiteResults.push(result);
|
|
79
|
+
}
|
|
80
|
+
// Run afterAll hooks
|
|
81
|
+
await runHooks(suite.afterAll);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error(`Suite "${suite.name}" failed`);
|
|
85
|
+
suiteError = error;
|
|
86
|
+
}
|
|
87
|
+
const duration = Date.now() - startTime;
|
|
88
|
+
// Determine overall suite status
|
|
89
|
+
let status = 'passed';
|
|
90
|
+
if (suiteError) {
|
|
91
|
+
status = 'failed';
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// Check if any tests or child suites failed
|
|
95
|
+
const hasFailedTests = testResults.some((result) => result.status === 'failed');
|
|
96
|
+
const hasFailedSuites = suiteResults.some((result) => result.status === 'failed');
|
|
97
|
+
if (hasFailedTests || hasFailedSuites) {
|
|
98
|
+
status = 'failed';
|
|
99
|
+
}
|
|
100
|
+
else if ((testResults.every((result) => result.status === 'skipped') &&
|
|
101
|
+
suiteResults.every((result) => result.status === 'skipped') &&
|
|
102
|
+
testResults.length > 0) ||
|
|
103
|
+
suiteResults.length > 0) {
|
|
104
|
+
status = 'skipped';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
name: suite.name,
|
|
109
|
+
tests: testResults,
|
|
110
|
+
suites: suiteResults,
|
|
111
|
+
status,
|
|
112
|
+
error: suiteError,
|
|
113
|
+
duration,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const getClient: () => Promise<import("@react-native-harness/bridge/client").BridgeClient>;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,SAAS,2EA6BlB,CAAC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getBridgeClient } from '@react-native-harness/bridge/client';
|
|
2
|
+
import { collectTests } from './rntl/describe.js';
|
|
3
|
+
import { fetchModule, executeModule } from './module.js';
|
|
4
|
+
import { runSuite } from './runner.js';
|
|
5
|
+
import { state } from './state.js';
|
|
6
|
+
const consumeTestModule = async (fileName) => {
|
|
7
|
+
const moduleJs = await fetchModule(fileName);
|
|
8
|
+
const testSuite = collectTests(() => executeModule(moduleJs));
|
|
9
|
+
return testSuite;
|
|
10
|
+
};
|
|
11
|
+
export const getClient = () => getBridgeClient('http://localhost:3001', {
|
|
12
|
+
runTests: async (path) => {
|
|
13
|
+
if (state.getState().status === 'running') {
|
|
14
|
+
throw new Error('Already running tests');
|
|
15
|
+
}
|
|
16
|
+
state.getState().setStatus('running');
|
|
17
|
+
try {
|
|
18
|
+
const testSuite = await consumeTestModule(path);
|
|
19
|
+
const results = await runSuite(testSuite);
|
|
20
|
+
return results;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return {
|
|
24
|
+
error: {
|
|
25
|
+
message: error instanceof Error ? error.message : String(error),
|
|
26
|
+
stack: error instanceof Error ? error.stack : 'Unknown',
|
|
27
|
+
name: error instanceof Error ? error.name : 'Unknown',
|
|
28
|
+
},
|
|
29
|
+
name: 'Root',
|
|
30
|
+
tests: [],
|
|
31
|
+
suites: [],
|
|
32
|
+
status: 'failed',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
state.getState().setStatus('idle');
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
});
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BridgeClient } from '@react-native-harness/bridge/client';
|
|
3
|
+
type ComponentHarnessState = {
|
|
4
|
+
node: ReactNode;
|
|
5
|
+
options: unknown;
|
|
6
|
+
layout: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type RunnerState = {
|
|
14
|
+
status: 'loading' | 'idle' | 'running';
|
|
15
|
+
componentHarness: ComponentHarnessState | null;
|
|
16
|
+
client: BridgeClient | null;
|
|
17
|
+
setStatus: (status: 'idle' | 'running') => void;
|
|
18
|
+
render: (node: ReactNode, options: unknown) => void;
|
|
19
|
+
cleanup: () => void;
|
|
20
|
+
bootstrap: () => Promise<void>;
|
|
21
|
+
reportLayout: (x: number, y: number, width: number, height: number) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const state: import("zustand/react").UseBoundStore<import("zustand/vanilla").StoreApi<RunnerState>>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGnE,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,gBAAgB,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC/C,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAChD,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACpD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7E,CAAC;AAUF,eAAO,MAAM,KAAK,wFA+Bf,CAAC"}
|
package/dist/state.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { create } from 'zustand/react';
|
|
2
|
+
import { getClient } from './runtime.js';
|
|
3
|
+
function assertComponentHarnessReady(state) {
|
|
4
|
+
if (!state.componentHarness) {
|
|
5
|
+
throw new Error('ComponentHarness is not ready');
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export const state = create((set) => ({
|
|
9
|
+
status: 'loading',
|
|
10
|
+
componentHarness: null,
|
|
11
|
+
client: null,
|
|
12
|
+
setStatus: (status) => set({ status }),
|
|
13
|
+
render: (node, options) => set({
|
|
14
|
+
componentHarness: {
|
|
15
|
+
node,
|
|
16
|
+
options,
|
|
17
|
+
layout: { x: 0, y: 0, width: 0, height: 0 },
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
cleanup: () => set({ componentHarness: null }),
|
|
21
|
+
bootstrap: async () => {
|
|
22
|
+
const client = await getClient();
|
|
23
|
+
set({ client, status: 'idle' });
|
|
24
|
+
client.rpc.reportReady();
|
|
25
|
+
},
|
|
26
|
+
reportLayout: (x, y, width, height) => {
|
|
27
|
+
set((state) => {
|
|
28
|
+
assertComponentHarnessReady(state);
|
|
29
|
+
return {
|
|
30
|
+
componentHarness: {
|
|
31
|
+
...state.componentHarness,
|
|
32
|
+
layout: { x, y, width, height },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
}));
|