@react-native-harness/runtime 1.0.0-alpha.2 → 1.0.0-alpha.20
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/README.md +23 -4
- package/assets/harness-module-system.js +73 -0
- package/dist/bundler/bundle.d.ts.map +1 -1
- package/dist/bundler/bundle.js +7 -2
- package/dist/bundler/errors.d.ts +5 -0
- package/dist/bundler/errors.d.ts.map +1 -1
- package/dist/bundler/errors.js +10 -0
- package/dist/bundler/evaluate.d.ts.map +1 -1
- package/dist/bundler/evaluate.js +7 -7
- package/dist/bundler/factory.d.ts +3 -0
- package/dist/bundler/factory.d.ts.map +1 -0
- package/dist/bundler/factory.js +36 -0
- package/dist/bundler/index.d.ts +2 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/bundler/types.d.ts +7 -0
- package/dist/bundler/types.d.ts.map +1 -0
- package/dist/bundler/types.js +1 -0
- package/dist/client/factory.d.ts.map +1 -1
- package/dist/client/factory.js +34 -6
- package/dist/client/getDeviceDescriptor.d.ts +1 -1
- package/dist/client/getDeviceDescriptor.d.ts.map +1 -1
- package/dist/client/getDeviceDescriptor.js +18 -6
- package/dist/client/getWSServer.d.ts.map +1 -1
- package/dist/client/getWSServer.js +2 -1
- package/dist/client/setup-files.d.ts +12 -0
- package/dist/client/setup-files.d.ts.map +1 -0
- package/dist/client/setup-files.js +60 -0
- 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/collector/functions.d.ts +1 -1
- package/dist/collector/functions.d.ts.map +1 -1
- package/dist/collector/functions.js +10 -2
- package/dist/collector/types.d.ts +1 -1
- package/dist/collector/types.d.ts.map +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -1
- package/dist/disableHMRWhenReady.d.ts +2 -0
- package/dist/disableHMRWhenReady.d.ts.map +1 -0
- package/dist/disableHMRWhenReady.js +20 -0
- package/dist/entry-point.d.ts +2 -0
- package/dist/entry-point.d.ts.map +1 -0
- package/dist/entry-point.js +4 -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.map +1 -1
- package/dist/expect/index.js +2 -0
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts +12 -0
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts.map +1 -0
- package/dist/expect/matchers/toMatchImageSnapshot.js +11 -0
- package/dist/expect/setup.js +2 -0
- package/dist/filtering/index.d.ts +2 -0
- package/dist/filtering/index.d.ts.map +1 -0
- package/dist/filtering/index.js +1 -0
- package/dist/filtering/testNameFilter.d.ts +12 -0
- package/dist/filtering/testNameFilter.d.ts.map +1 -0
- package/dist/filtering/testNameFilter.js +56 -0
- package/dist/globals.d.ts +6 -2
- package/dist/globals.d.ts.map +1 -1
- package/dist/globals.js +7 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/initialize.js +14 -6
- package/dist/jest-mock.d.ts +2 -0
- package/dist/jest-mock.d.ts.map +1 -0
- package/dist/jest-mock.js +25 -0
- package/dist/mocker/index.d.ts +1 -1
- package/dist/mocker/index.d.ts.map +1 -1
- package/dist/mocker/index.js +1 -1
- package/dist/mocker/registry.d.ts +2 -3
- package/dist/mocker/registry.d.ts.map +1 -1
- package/dist/mocker/registry.js +25 -16
- package/dist/namespace.d.ts +18 -0
- package/dist/namespace.d.ts.map +1 -0
- package/dist/namespace.js +19 -0
- package/dist/render/ErrorBoundary.d.ts +17 -0
- package/dist/render/ErrorBoundary.d.ts.map +1 -0
- package/dist/render/ErrorBoundary.js +73 -0
- package/dist/render/TestComponentOverlay.d.ts +3 -0
- package/dist/render/TestComponentOverlay.d.ts.map +1 -0
- package/dist/render/TestComponentOverlay.js +36 -0
- package/dist/render/cleanup.d.ts +2 -0
- package/dist/render/cleanup.d.ts.map +1 -0
- package/dist/render/cleanup.js +6 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +66 -0
- 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/render/setup.d.ts +2 -0
- package/dist/render/setup.d.ts.map +1 -0
- package/dist/render/setup.js +7 -0
- package/dist/render/types.d.ts +12 -0
- package/dist/render/types.d.ts.map +1 -0
- package/dist/render/types.js +1 -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/errors.d.ts +4 -2
- package/dist/runner/errors.d.ts.map +1 -1
- package/dist/runner/errors.js +21 -3
- package/dist/runner/factory.d.ts.map +1 -1
- package/dist/runner/factory.js +6 -1
- package/dist/runner/runSuite.d.ts.map +1 -1
- package/dist/runner/runSuite.js +59 -7
- package/dist/screen/index.d.ts +8 -0
- package/dist/screen/index.d.ts.map +1 -0
- package/dist/screen/index.js +18 -0
- package/dist/symbolicate.d.ts +3 -0
- package/dist/symbolicate.d.ts.map +1 -0
- package/dist/symbolicate.js +19 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/ui/ReadyScreen.d.ts.map +1 -1
- package/dist/ui/ReadyScreen.js +3 -10
- package/dist/ui/WrongEnvironmentScreen.d.ts.map +1 -1
- package/dist/ui/WrongEnvironmentScreen.js +2 -10
- package/dist/ui/state.d.ts +14 -1
- package/dist/ui/state.d.ts.map +1 -1
- package/dist/ui/state.js +22 -0
- package/dist/userEvent/index.d.ts +6 -0
- package/dist/userEvent/index.d.ts.map +1 -0
- package/dist/userEvent/index.js +10 -0
- package/dist/utils/emitter.d.ts.map +1 -1
- package/dist/waitFor.d.ts +21 -0
- package/dist/waitFor.d.ts.map +1 -0
- package/dist/waitFor.js +137 -0
- package/eslint.config.mjs +1 -7
- 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__/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/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/index.d.ts +14 -0
- package/out-tsc/vitest/src/expect/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts +7 -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 +8 -0
- package/out-tsc/vitest/src/globals.d.ts.map +1 -0
- package/out-tsc/vitest/src/index.d.ts +13 -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 +7 -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/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/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 +4 -0
- package/out-tsc/vitest/src/runner/index.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/runSuite.d.ts +4 -0
- package/out-tsc/vitest/src/runner/runSuite.d.ts.map +1 -0
- package/out-tsc/vitest/src/runner/types.d.ts +13 -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 +22 -14
- package/src/__tests__/collector.test.ts +55 -55
- package/src/__tests__/error-handling.test.ts +34 -34
- package/src/__tests__/expect.test.ts +13 -5
- package/src/__tests__/initialize.test.ts +24 -0
- package/src/bundler/bundle.ts +9 -2
- package/src/bundler/errors.ts +10 -0
- package/src/bundler/evaluate.ts +9 -9
- package/src/bundler/factory.ts +43 -0
- package/src/bundler/index.ts +2 -1
- package/src/bundler/types.ts +7 -0
- package/src/client/factory.ts +53 -11
- package/src/client/getDeviceDescriptor.ts +29 -8
- package/src/client/getWSServer.ts +2 -1
- package/src/client/setup-files.ts +81 -0
- package/src/collector/functions.ts +18 -2
- package/src/collector/types.ts +4 -1
- package/src/constants.ts +0 -1
- package/src/disableHMRWhenReady.ts +27 -0
- package/src/entry-point.ts +8 -0
- package/src/expect/index.ts +8 -2
- package/src/expect/setup.ts +3 -0
- package/src/filtering/index.ts +4 -0
- package/src/filtering/testNameFilter.ts +82 -0
- package/src/globals.ts +15 -2
- package/src/index.ts +3 -0
- package/src/initialize.ts +21 -8
- package/src/jest-mock.ts +32 -0
- package/src/mocker/index.ts +6 -1
- package/src/mocker/metro-require.d.ts +2 -0
- package/src/mocker/registry.ts +29 -18
- package/src/namespace.ts +41 -0
- package/src/react-native.d.ts +35 -6
- package/src/render/ErrorBoundary.tsx +108 -0
- package/src/render/TestComponentOverlay.tsx +47 -0
- package/src/render/cleanup.ts +7 -0
- package/src/render/index.ts +96 -0
- package/src/render/setup.ts +8 -0
- package/src/render/types.ts +11 -0
- package/src/runner/errors.ts +35 -5
- package/src/runner/factory.ts +8 -1
- package/src/runner/runSuite.ts +70 -9
- package/src/symbolicate.ts +24 -0
- package/src/ui/ReadyScreen.tsx +2 -12
- package/src/ui/WrongEnvironmentScreen.tsx +1 -19
- package/src/ui/state.ts +39 -0
- package/src/utils/emitter.ts +1 -0
- package/src/waitFor.ts +199 -0
- package/tsconfig.spec.json +7 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/assets/logo.png +0 -0
- package/assets/moduleSystem.flow.js +0 -1062
- package/types/global.d.ts +0 -2
- package/types/index.d.ts +0 -1
|
@@ -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 };
|
|
@@ -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":"AAGA,OAAO,KAAK,EAAa,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAS5E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,YAAY,CAAC;AAEpB,wBAAgB,YAAY,IAAI,YAAY,CAqF3C;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"}
|
package/dist/expect/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
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.
|
|
1
3
|
import { addCustomEqualityTesters, ASYMMETRIC_MATCHERS_OBJECT, customMatchers, getState, GLOBAL_EXPECT, setState, } from '@vitest/expect';
|
|
2
4
|
import * as chai from 'chai';
|
|
3
5
|
// Setup additional matchers
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MatcherState } from '@vitest/expect';
|
|
2
|
+
import type { FileReference, ImageSnapshotOptions } from '@react-native-harness/bridge';
|
|
3
|
+
declare module '@vitest/expect' {
|
|
4
|
+
interface Matchers {
|
|
5
|
+
toMatchImageSnapshot(options: ImageSnapshotOptions): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function toMatchImageSnapshot(this: MatcherState, received: FileReference, options: ImageSnapshotOptions): Promise<{
|
|
9
|
+
pass: boolean;
|
|
10
|
+
message: () => string;
|
|
11
|
+
}>;
|
|
12
|
+
//# 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,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,QAAQ;QAChB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACpE;CACF;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,MAAM,CAAA;CAAE,CAAC,CAcnD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getClientInstance } from '../../client/store.js';
|
|
2
|
+
import { getHarnessContext } from '../../runner/index.js';
|
|
3
|
+
export async function toMatchImageSnapshot(received, options) {
|
|
4
|
+
const client = getClientInstance();
|
|
5
|
+
const context = getHarnessContext();
|
|
6
|
+
const result = await client.rpc['test.matchImageSnapshot'](received, context.testFilePath, options, context.runner);
|
|
7
|
+
return {
|
|
8
|
+
pass: result.pass,
|
|
9
|
+
message: () => result.message,
|
|
10
|
+
};
|
|
11
|
+
}
|
package/dist/expect/setup.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// This is adapted version of https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/integrations/chai/setup.ts
|
|
2
|
+
// Credits to Vitest team for the original implementation.
|
|
1
3
|
import { JestAsymmetricMatchers, JestChaiExpect, JestExtend, } from '@vitest/expect';
|
|
2
4
|
import * as chai from 'chai';
|
|
3
5
|
chai.use(JestExtend);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filtering/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { filterTestsByName, markTestsAsSkippedByName, } from './testNameFilter.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TestSuite } from '@react-native-harness/bridge';
|
|
2
|
+
/**
|
|
3
|
+
* Filters tests by name pattern, matching against test names and suite+test combinations
|
|
4
|
+
* @deprecated Use markTestsAsSkippedByName instead - this function will be removed in a future version
|
|
5
|
+
*/
|
|
6
|
+
export declare const filterTestsByName: (suite: TestSuite, testNamePattern: string) => TestSuite;
|
|
7
|
+
/**
|
|
8
|
+
* Marks tests as skipped based on name pattern, keeping all tests in the structure
|
|
9
|
+
* but setting non-matching tests to 'skipped' status
|
|
10
|
+
*/
|
|
11
|
+
export declare const markTestsAsSkippedByName: (suite: TestSuite, testNamePattern: string) => TestSuite;
|
|
12
|
+
//# sourceMappingURL=testNameFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testNameFilter.d.ts","sourceRoot":"","sources":["../../src/filtering/testNameFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,SAAS,EAChB,iBAAiB,MAAM,KACtB,SAGF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,SAAS,EAChB,iBAAiB,MAAM,KACtB,SAGF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters tests by name pattern, matching against test names and suite+test combinations
|
|
3
|
+
* @deprecated Use markTestsAsSkippedByName instead - this function will be removed in a future version
|
|
4
|
+
*/
|
|
5
|
+
export const filterTestsByName = (suite, testNamePattern) => {
|
|
6
|
+
const regex = new RegExp(testNamePattern);
|
|
7
|
+
return filterSuiteRecursively(suite, regex);
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Marks tests as skipped based on name pattern, keeping all tests in the structure
|
|
11
|
+
* but setting non-matching tests to 'skipped' status
|
|
12
|
+
*/
|
|
13
|
+
export const markTestsAsSkippedByName = (suite, testNamePattern) => {
|
|
14
|
+
const regex = new RegExp(testNamePattern);
|
|
15
|
+
return markTestsRecursively(suite, regex);
|
|
16
|
+
};
|
|
17
|
+
const markTestsRecursively = (suite, regex) => {
|
|
18
|
+
// Mark tests in current suite - skip tests that don't match the pattern
|
|
19
|
+
const updatedTests = suite.tests.map((test) => {
|
|
20
|
+
const matches = regex.test(test.name) || regex.test(`${suite.name} ${test.name}`);
|
|
21
|
+
// If test doesn't match pattern and is currently active, mark it as skipped
|
|
22
|
+
if (!matches && test.status === 'active') {
|
|
23
|
+
return {
|
|
24
|
+
...test,
|
|
25
|
+
status: 'skipped',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Keep original status for matching tests or already skipped/todo tests
|
|
29
|
+
return test;
|
|
30
|
+
});
|
|
31
|
+
// Recursively process child suites
|
|
32
|
+
const updatedChildSuites = suite.suites.map((childSuite) => markTestsRecursively(childSuite, regex));
|
|
33
|
+
return {
|
|
34
|
+
...suite,
|
|
35
|
+
tests: updatedTests,
|
|
36
|
+
suites: updatedChildSuites,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const filterSuiteRecursively = (suite, regex) => {
|
|
40
|
+
// Filter tests in current suite - match against test name or "suite test" combination
|
|
41
|
+
const filteredTests = suite.tests.filter((test) => regex.test(test.name) || regex.test(`${suite.name} ${test.name}`));
|
|
42
|
+
// Recursively filter child suites
|
|
43
|
+
const filteredChildSuites = suite.suites
|
|
44
|
+
.map((childSuite) => filterSuiteRecursively(childSuite, regex))
|
|
45
|
+
.filter((childSuite) => hasAnyActiveTests(childSuite));
|
|
46
|
+
return {
|
|
47
|
+
...suite,
|
|
48
|
+
tests: filteredTests,
|
|
49
|
+
suites: filteredChildSuites,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const hasAnyActiveTests = (suite) => {
|
|
53
|
+
const hasDirectTests = suite.tests.some((test) => test.status === 'active');
|
|
54
|
+
const hasChildTests = suite.suites.some((childSuite) => hasAnyActiveTests(childSuite));
|
|
55
|
+
return hasDirectTests || hasChildTests;
|
|
56
|
+
};
|
package/dist/globals.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
export type HarnessGlobal = {
|
|
2
|
+
appRegistryComponentName: string;
|
|
3
|
+
webSocketPort?: number;
|
|
4
|
+
};
|
|
1
5
|
declare global {
|
|
2
|
-
var RN_HARNESS:
|
|
6
|
+
var RN_HARNESS: HarnessGlobal | undefined;
|
|
3
7
|
}
|
|
4
|
-
export
|
|
8
|
+
export declare const getHarnessGlobal: () => HarnessGlobal;
|
|
5
9
|
//# 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,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,UAAU,EAAE,
|
|
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"}
|
package/dist/globals.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,7 @@ export * from './spy/index.js';
|
|
|
4
4
|
export * from './expect/index.js';
|
|
5
5
|
export * from './collector/index.js';
|
|
6
6
|
export * from './mocker/index.js';
|
|
7
|
+
export * from './namespace.js';
|
|
8
|
+
export * from './waitFor.js';
|
|
9
|
+
export * from './render/index.js';
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
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;AAExB,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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,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
package/dist/initialize.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { getDeviceDescriptor } from './client/getDeviceDescriptor.js';
|
|
2
2
|
import { getClient } from './client/index.js';
|
|
3
|
+
import { disableHMRWhenReady } from './disableHMRWhenReady.js';
|
|
4
|
+
import { setupJestMock } from './jest-mock.js';
|
|
3
5
|
// Polyfill for EventTarget
|
|
4
6
|
const Shim = require('event-target-shim');
|
|
5
7
|
globalThis.Event = Shim.Event;
|
|
6
8
|
globalThis.EventTarget = Shim.EventTarget;
|
|
9
|
+
// Setup jest mock to warn users about using Jest APIs
|
|
10
|
+
setupJestMock();
|
|
7
11
|
// Turn off LogBox
|
|
8
12
|
const { LogBox } = require('react-native');
|
|
9
13
|
LogBox.ignoreAllLogs(true);
|
|
10
14
|
// Turn off HMR
|
|
11
|
-
const
|
|
12
|
-
HMRClient
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const HMRClientModule = require('react-native/Libraries/Utilities/HMRClient');
|
|
16
|
+
const HMRClient = 'default' in HMRClientModule ? HMRClientModule.default : HMRClientModule;
|
|
17
|
+
// Wait for HMRClient to be initialized
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
void disableHMRWhenReady(() => HMRClient.disable(), 50).then(() => getClient().then((client) => client.rpc.reportReady(getDeviceDescriptor())));
|
|
20
|
+
});
|
|
21
|
+
// Re-throw fatal errors
|
|
22
|
+
ErrorUtils.setGlobalHandler((error) => {
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-mock.d.ts","sourceRoot":"","sources":["../src/jest-mock.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,QAAO,IA8BhC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Mock jest global to warn users about using Jest APIs in Harness tests
|
|
2
|
+
export const setupJestMock = () => {
|
|
3
|
+
function throwError() {
|
|
4
|
+
throw new Error(`Jest globals are not available in Harness tests. Import from 'react-native-harness' instead (e.g., import { harness } from 'react-native-harness'; harness.fn())`);
|
|
5
|
+
}
|
|
6
|
+
const jestMock = new Proxy({}, {
|
|
7
|
+
get() {
|
|
8
|
+
throwError();
|
|
9
|
+
},
|
|
10
|
+
set() {
|
|
11
|
+
throwError();
|
|
12
|
+
},
|
|
13
|
+
has() {
|
|
14
|
+
throwError();
|
|
15
|
+
},
|
|
16
|
+
ownKeys() {
|
|
17
|
+
throwError();
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(globalThis, 'jest', {
|
|
21
|
+
value: jestMock,
|
|
22
|
+
writable: false,
|
|
23
|
+
configurable: false,
|
|
24
|
+
});
|
|
25
|
+
};
|
package/dist/mocker/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mock, requireActual,
|
|
1
|
+
export { mock, requireActual, unmock, resetModules, } from './registry.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mocker/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mocker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,aAAa,EACb,MAAM,EACN,YAAY,GACb,MAAM,eAAe,CAAC"}
|
package/dist/mocker/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { mock, requireActual,
|
|
1
|
+
export { mock, requireActual, unmock, resetModules, } from './registry.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ModuleFactory } from './types.js';
|
|
2
2
|
export declare const mock: (moduleId: string, factory: ModuleFactory) => void;
|
|
3
|
-
export declare const clearMocks: () => void;
|
|
4
|
-
export declare const getMockRegistry: () => Map<number, ModuleFactory>;
|
|
5
|
-
export declare const getMockImplementation: (moduleId: number) => unknown | null;
|
|
6
3
|
export declare const requireActual: <T = any>(moduleId: string) => T;
|
|
4
|
+
export declare const unmock: (moduleId: string) => void;
|
|
5
|
+
export declare const resetModules: () => void;
|
|
7
6
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/mocker/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAO9D,eAAO,MAAM,IAAI,GAAI,UAAU,MAAM,EAAE,SAAS,aAAa,KAAG,IAG/D,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/mocker/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAO9D,eAAO,MAAM,IAAI,GAAI,UAAU,MAAM,EAAE,SAAS,aAAa,KAAG,IAG/D,CAAC;AAmBF,eAAO,MAAM,aAAa,GAAI,CAAC,GAAG,GAAG,EAAE,UAAU,MAAM,KAAG,CAEH,CAAC;AAExD,eAAO,MAAM,MAAM,GAAI,UAAU,MAAM,SAGtC,CAAC;AAEF,eAAO,MAAM,YAAY,QAAO,IAG/B,CAAC"}
|
package/dist/mocker/registry.js
CHANGED
|
@@ -1,40 +1,49 @@
|
|
|
1
|
+
const modulesCache = new Map();
|
|
1
2
|
const mockRegistry = new Map();
|
|
2
|
-
const mockCache = new Map();
|
|
3
3
|
const originalRequire = global.__r;
|
|
4
4
|
export const mock = (moduleId, factory) => {
|
|
5
|
-
|
|
5
|
+
modulesCache.delete(moduleId);
|
|
6
6
|
mockRegistry.set(moduleId, factory);
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
mockRegistry.
|
|
10
|
-
mockCache.clear();
|
|
11
|
-
};
|
|
12
|
-
export const getMockRegistry = () => {
|
|
13
|
-
return mockRegistry;
|
|
8
|
+
const isModuleMocked = (moduleId) => {
|
|
9
|
+
return mockRegistry.has(moduleId);
|
|
14
10
|
};
|
|
15
|
-
|
|
16
|
-
if (mockCache.has(moduleId)) {
|
|
17
|
-
return mockCache.get(moduleId);
|
|
18
|
-
}
|
|
11
|
+
const getMockImplementation = (moduleId) => {
|
|
19
12
|
const factory = mockRegistry.get(moduleId);
|
|
20
13
|
if (!factory) {
|
|
21
14
|
return null;
|
|
22
15
|
}
|
|
23
16
|
const implementation = factory();
|
|
24
|
-
|
|
17
|
+
modulesCache.set(moduleId, implementation);
|
|
25
18
|
return implementation;
|
|
26
19
|
};
|
|
27
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
21
|
export const requireActual = (moduleId) =>
|
|
29
22
|
// babel plugin will transform 'moduleId' to a number
|
|
30
23
|
originalRequire(moduleId);
|
|
24
|
+
export const unmock = (moduleId) => {
|
|
25
|
+
mockRegistry.delete(moduleId);
|
|
26
|
+
modulesCache.delete(moduleId);
|
|
27
|
+
};
|
|
28
|
+
export const resetModules = () => {
|
|
29
|
+
modulesCache.clear();
|
|
30
|
+
mockRegistry.clear();
|
|
31
|
+
};
|
|
31
32
|
const mockRequire = (moduleId) => {
|
|
32
33
|
// babel plugin will transform 'moduleId' to a number
|
|
33
|
-
const
|
|
34
|
-
|
|
34
|
+
const moduleIdNumber = moduleId;
|
|
35
|
+
const cachedModule = modulesCache.get(moduleIdNumber);
|
|
36
|
+
if (cachedModule) {
|
|
37
|
+
return cachedModule;
|
|
38
|
+
}
|
|
39
|
+
if (isModuleMocked(moduleIdNumber)) {
|
|
40
|
+
const mockedModule = getMockImplementation(moduleIdNumber);
|
|
41
|
+
modulesCache.set(moduleIdNumber, mockedModule);
|
|
35
42
|
return mockedModule;
|
|
36
43
|
}
|
|
37
|
-
|
|
44
|
+
const originalModule = originalRequire(moduleIdNumber);
|
|
45
|
+
modulesCache.set(moduleIdNumber, originalModule);
|
|
46
|
+
return originalModule;
|
|
38
47
|
};
|
|
39
48
|
Object.setPrototypeOf(mockRequire, Object.getPrototypeOf(originalRequire));
|
|
40
49
|
Object.defineProperties(mockRequire, Object.getOwnPropertyDescriptors(originalRequire));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { spyOn, fn, clearAllMocks, resetAllMocks, restoreAllMocks } from './spy/index.js';
|
|
2
|
+
import { mock, unmock, requireActual, resetModules } from './mocker/index.js';
|
|
3
|
+
import { waitFor, waitUntil } from './waitFor.js';
|
|
4
|
+
export type HarnessNamespace = {
|
|
5
|
+
spyOn: typeof spyOn;
|
|
6
|
+
fn: typeof fn;
|
|
7
|
+
mock: typeof mock;
|
|
8
|
+
unmock: typeof unmock;
|
|
9
|
+
requireActual: typeof requireActual;
|
|
10
|
+
clearAllMocks: typeof clearAllMocks;
|
|
11
|
+
resetAllMocks: typeof resetAllMocks;
|
|
12
|
+
restoreAllMocks: typeof restoreAllMocks;
|
|
13
|
+
resetModules: typeof resetModules;
|
|
14
|
+
waitFor: typeof waitFor;
|
|
15
|
+
waitUntil: typeof waitUntil;
|
|
16
|
+
};
|
|
17
|
+
export declare const harness: HarnessNamespace;
|
|
18
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../src/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,EAAE,EACF,aAAa,EACb,aAAa,EACb,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,EAAE,EAAE,OAAO,EAAE,CAAC;IACd,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,MAAM,CAAC;IACtB,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,SAAS,CAAC;CAC7B,CAAC;AAkBF,eAAO,MAAM,OAAO,kBAA2B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { spyOn, fn, clearAllMocks, resetAllMocks, restoreAllMocks, } from './spy/index.js';
|
|
2
|
+
import { mock, unmock, requireActual, resetModules } from './mocker/index.js';
|
|
3
|
+
import { waitFor, waitUntil } from './waitFor.js';
|
|
4
|
+
const createHarnessNamespace = () => {
|
|
5
|
+
return {
|
|
6
|
+
spyOn,
|
|
7
|
+
fn,
|
|
8
|
+
mock,
|
|
9
|
+
unmock,
|
|
10
|
+
requireActual,
|
|
11
|
+
clearAllMocks,
|
|
12
|
+
resetAllMocks,
|
|
13
|
+
restoreAllMocks,
|
|
14
|
+
resetModules,
|
|
15
|
+
waitFor,
|
|
16
|
+
waitUntil,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export const harness = createHarnessNamespace();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ErrorBoundaryProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
};
|
|
5
|
+
type ErrorBoundaryState = {
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
};
|
|
9
|
+
export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
10
|
+
constructor(props: ErrorBoundaryProps);
|
|
11
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
12
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
13
|
+
componentDidUpdate(prevProps: ErrorBoundaryProps): void;
|
|
14
|
+
render(): React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=ErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/render/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,qBAAa,aAAc,SAAQ,KAAK,CAAC,SAAS,CAChD,kBAAkB,EAClB,kBAAkB,CACnB;gBACa,KAAK,EAAE,kBAAkB;IAKrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;IAIxD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI;IAIjE,kBAAkB,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAAI;IAOvD,MAAM,IAAI,KAAK,CAAC,SAAS;CAwBnC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { View, Text, StyleSheet, ScrollView } from 'react-native';
|
|
4
|
+
export class ErrorBoundary extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.state = { hasError: false, error: null };
|
|
8
|
+
}
|
|
9
|
+
static getDerivedStateFromError(error) {
|
|
10
|
+
return { hasError: true, error };
|
|
11
|
+
}
|
|
12
|
+
componentDidCatch(error, errorInfo) {
|
|
13
|
+
console.error('Error caught by ErrorBoundary:', error, errorInfo);
|
|
14
|
+
}
|
|
15
|
+
componentDidUpdate(prevProps) {
|
|
16
|
+
// Reset error state when children change (new component rendered)
|
|
17
|
+
if (prevProps.children !== this.props.children && this.state.hasError) {
|
|
18
|
+
this.setState({ hasError: false, error: null });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
if (this.state.hasError && this.state.error) {
|
|
23
|
+
return (_jsx(View, { style: styles.errorContainer, children: _jsxs(View, { style: styles.errorContent, children: [_jsx(Text, { style: styles.errorTitle, children: "Component Error" }), _jsx(Text, { style: styles.errorSubtitle, children: "The rendered component threw an error:" }), _jsxs(ScrollView, { style: styles.errorScrollView, children: [_jsx(Text, { style: styles.errorMessage, children: this.state.error.message }), this.state.error.stack && (_jsx(Text, { style: styles.errorStack, children: this.state.error.stack }))] })] }) }));
|
|
24
|
+
}
|
|
25
|
+
return this.props.children;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
errorContainer: {
|
|
30
|
+
flex: 1,
|
|
31
|
+
backgroundColor: 'rgba(220, 38, 38, 0.1)',
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
padding: 20,
|
|
35
|
+
},
|
|
36
|
+
errorContent: {
|
|
37
|
+
backgroundColor: '#1f2937',
|
|
38
|
+
borderRadius: 12,
|
|
39
|
+
padding: 20,
|
|
40
|
+
maxWidth: 500,
|
|
41
|
+
width: '100%',
|
|
42
|
+
maxHeight: '80%',
|
|
43
|
+
borderWidth: 2,
|
|
44
|
+
borderColor: '#dc2626',
|
|
45
|
+
},
|
|
46
|
+
errorTitle: {
|
|
47
|
+
fontSize: 24,
|
|
48
|
+
fontWeight: '700',
|
|
49
|
+
color: '#dc2626',
|
|
50
|
+
marginBottom: 8,
|
|
51
|
+
},
|
|
52
|
+
errorSubtitle: {
|
|
53
|
+
fontSize: 14,
|
|
54
|
+
color: '#9ca3af',
|
|
55
|
+
marginBottom: 16,
|
|
56
|
+
},
|
|
57
|
+
errorScrollView: {
|
|
58
|
+
maxHeight: 400,
|
|
59
|
+
},
|
|
60
|
+
errorMessage: {
|
|
61
|
+
fontSize: 16,
|
|
62
|
+
fontWeight: '600',
|
|
63
|
+
color: '#fca5a5',
|
|
64
|
+
marginBottom: 12,
|
|
65
|
+
fontFamily: 'Courier',
|
|
66
|
+
},
|
|
67
|
+
errorStack: {
|
|
68
|
+
fontSize: 12,
|
|
69
|
+
color: '#d1d5db',
|
|
70
|
+
fontFamily: 'Courier',
|
|
71
|
+
lineHeight: 18,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestComponentOverlay.d.ts","sourceRoot":"","sources":["../../src/render/TestComponentOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAMzC,eAAO,MAAM,oBAAoB,QAAO,KAAK,CAAC,YAAY,GAAG,IAgC5D,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { View, StyleSheet } from 'react-native';
|
|
4
|
+
import { useRenderedElement } from '../ui/state.js';
|
|
5
|
+
import { store } from '../ui/state.js';
|
|
6
|
+
import { ErrorBoundary } from './ErrorBoundary.js';
|
|
7
|
+
export const TestComponentOverlay = () => {
|
|
8
|
+
const { element, key } = useRenderedElement();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
// Call onRenderCallback when element changes
|
|
11
|
+
const callback = store.getState().onRenderCallback;
|
|
12
|
+
if (callback) {
|
|
13
|
+
callback();
|
|
14
|
+
store.getState().setOnRenderCallback(null);
|
|
15
|
+
}
|
|
16
|
+
}, [element]);
|
|
17
|
+
if (!element) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const handleLayout = () => {
|
|
21
|
+
const callback = store.getState().onLayoutCallback;
|
|
22
|
+
if (callback) {
|
|
23
|
+
callback();
|
|
24
|
+
// Clear the callback after calling it
|
|
25
|
+
store.getState().setOnLayoutCallback(null);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return (_jsx(View, { style: styles.overlay, onLayout: handleLayout, children: _jsx(ErrorBoundary, { children: element }) }, key));
|
|
29
|
+
};
|
|
30
|
+
const styles = StyleSheet.create({
|
|
31
|
+
overlay: {
|
|
32
|
+
...StyleSheet.absoluteFillObject,
|
|
33
|
+
backgroundColor: '#0a1628',
|
|
34
|
+
zIndex: 1000,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/render/cleanup.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,QAAO,IAI1B,CAAC"}
|