@react-native-harness/runtime 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +2 -1
- package/dist/client/factory.d.ts.map +1 -1
- package/dist/client/factory.js +53 -59
- package/dist/client/store.d.ts +3 -3
- package/dist/client/store.d.ts.map +1 -1
- package/dist/client/store.js +7 -7
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +1 -0
- package/dist/expect/context.d.ts +20 -0
- package/dist/expect/context.d.ts.map +1 -0
- package/dist/expect/context.js +6 -0
- package/dist/expect/errors.d.ts +3 -0
- package/dist/expect/errors.d.ts.map +1 -0
- package/dist/expect/errors.js +45 -0
- package/dist/expect/expect.d.ts.map +1 -1
- package/dist/expect/expect.js +6 -1
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts +1 -1
- package/dist/expect/matchers/toMatchImageSnapshot.d.ts.map +1 -1
- package/dist/expect/matchers/toMatchImageSnapshot.js +4 -12
- package/dist/initialize.js +14 -5
- package/dist/jsx/jsx-dev-runtime.d.ts +2 -1
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +16 -7
- package/dist/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/runSuite.d.ts.map +1 -1
- package/dist/runner/runSuite.js +16 -6
- 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/userEvent/index.d.ts +16 -0
- package/dist/userEvent/index.d.ts.map +1 -0
- package/dist/userEvent/index.js +31 -0
- package/dist/utils/hmr.d.ts +2 -0
- package/dist/utils/hmr.d.ts.map +1 -0
- package/dist/utils/hmr.js +3 -0
- package/dist/utils/parse-error-stack.d.ts +9 -0
- package/dist/utils/parse-error-stack.d.ts.map +1 -0
- package/dist/utils/parse-error-stack.js +56 -0
- package/dist/waitFor.d.ts.map +1 -1
- package/dist/waitFor.js +5 -3
- 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 +3 -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/getWSServer.test.d.ts +2 -0
- package/out-tsc/vitest/src/client/getWSServer.test.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/disableHMRWhenReady.test.d.ts +2 -0
- package/out-tsc/vitest/src/disableHMRWhenReady.test.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/context.d.ts +20 -0
- package/out-tsc/vitest/src/expect/context.d.ts.map +1 -0
- package/out-tsc/vitest/src/expect/errors.d.ts +3 -0
- package/out-tsc/vitest/src/expect/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 +13 -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 +19 -0
- package/out-tsc/vitest/src/globals.d.ts.map +1 -0
- package/out-tsc/vitest/src/index.d.ts +12 -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/jsx/jsx-dev-runtime.d.ts +4 -0
- package/out-tsc/vitest/src/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/out-tsc/vitest/src/jsx/jsx-runtime.d.ts +6 -0
- package/out-tsc/vitest/src/jsx/jsx-runtime.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 +17 -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/RunnerScreen.d.ts +8 -0
- package/out-tsc/vitest/src/ui/RunnerScreen.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/images.d.ts +3 -0
- package/out-tsc/vitest/src/ui/images.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 +2 -2
- package/src/client/factory.ts +63 -74
- package/src/client/store.ts +8 -8
- package/src/expect/context.ts +30 -0
- package/src/expect/errors.ts +76 -0
- package/src/expect/expect.ts +16 -5
- package/src/expect/matchers/toMatchImageSnapshot.ts +9 -23
- package/src/initialize.ts +14 -5
- package/src/jsx/jsx-dev-runtime.ts +34 -15
- package/src/runner/runSuite.ts +25 -11
- package/src/waitFor.ts +8 -6
package/src/expect/expect.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import * as chai from 'chai';
|
|
14
14
|
|
|
15
15
|
// Setup additional matchers
|
|
16
|
+
import { getCurrentExpectTestState } from './context.js';
|
|
16
17
|
import './setup.js';
|
|
17
18
|
import { toMatchImageSnapshot } from './matchers/toMatchImageSnapshot.js';
|
|
18
19
|
|
|
@@ -20,12 +21,22 @@ export function createExpect(): ExpectStatic {
|
|
|
20
21
|
const expect = ((value: unknown, message?: string): Assertion => {
|
|
21
22
|
const { assertionCalls } = getState(expect);
|
|
22
23
|
setState({ assertionCalls: assertionCalls + 1 }, expect);
|
|
23
|
-
|
|
24
|
+
|
|
25
|
+
const assertion = chai.expect(value, message) as unknown as Assertion & {
|
|
26
|
+
withTest?: (test: unknown) => Assertion;
|
|
27
|
+
};
|
|
28
|
+
const currentTest = getCurrentExpectTestState();
|
|
29
|
+
|
|
30
|
+
return currentTest && assertion.withTest
|
|
31
|
+
? assertion.withTest(currentTest)
|
|
32
|
+
: assertion;
|
|
24
33
|
}) as ExpectStatic;
|
|
25
34
|
Object.assign(expect, chai.expect);
|
|
26
35
|
Object.assign(
|
|
27
36
|
expect,
|
|
28
|
-
globalThis[
|
|
37
|
+
globalThis[
|
|
38
|
+
ASYMMETRIC_MATCHERS_OBJECT as unknown as keyof typeof globalThis
|
|
39
|
+
],
|
|
29
40
|
);
|
|
30
41
|
|
|
31
42
|
expect.getState = () => getState<MatcherState>(expect);
|
|
@@ -44,7 +55,7 @@ export function createExpect(): ExpectStatic {
|
|
|
44
55
|
expectedAssertionsNumber: null,
|
|
45
56
|
expectedAssertionsNumberErrorGen: null,
|
|
46
57
|
},
|
|
47
|
-
expect
|
|
58
|
+
expect,
|
|
48
59
|
);
|
|
49
60
|
|
|
50
61
|
// @ts-expect-error untyped
|
|
@@ -62,7 +73,7 @@ export function createExpect(): ExpectStatic {
|
|
|
62
73
|
// @ts-expect-error untyped
|
|
63
74
|
expect.unreachable = (message?: string) => {
|
|
64
75
|
chai.assert.fail(
|
|
65
|
-
`expected${message ? ` "${message}" ` : ' '}not to be reached
|
|
76
|
+
`expected${message ? ` "${message}" ` : ' '}not to be reached`,
|
|
66
77
|
);
|
|
67
78
|
};
|
|
68
79
|
|
|
@@ -71,7 +82,7 @@ export function createExpect(): ExpectStatic {
|
|
|
71
82
|
new Error(
|
|
72
83
|
`expected number of assertions to be ${expected}, but got ${
|
|
73
84
|
expect.getState().assertionCalls
|
|
74
|
-
}
|
|
85
|
+
}`,
|
|
75
86
|
);
|
|
76
87
|
if (Error.captureStackTrace) {
|
|
77
88
|
Error.captureStackTrace(errorGen(), assertions);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getHandle } from '../../client/store.js';
|
|
2
2
|
import type { MatcherState } from '@vitest/expect';
|
|
3
|
-
import {
|
|
4
|
-
type ImageSnapshotOptions,
|
|
5
|
-
generateTransferId,
|
|
6
|
-
} from '@react-native-harness/bridge';
|
|
3
|
+
import type { ImageSnapshotOptions } from '@react-native-harness/bridge';
|
|
7
4
|
import { getHarnessContext } from '../../runner/index.js';
|
|
8
5
|
|
|
9
6
|
type ScreenshotResult = {
|
|
@@ -17,30 +14,19 @@ export async function toMatchImageSnapshot(
|
|
|
17
14
|
received: ScreenshotResult,
|
|
18
15
|
options: ImageSnapshotOptions
|
|
19
16
|
): Promise<{ pass: boolean; message: () => string }> {
|
|
20
|
-
const
|
|
17
|
+
const handle = getHandle();
|
|
21
18
|
const context = getHarnessContext();
|
|
22
19
|
|
|
23
|
-
const
|
|
24
|
-
|
|
20
|
+
const screenshotFile = await handle.transferScreenshot(received.data, {
|
|
21
|
+
width: received.width,
|
|
22
|
+
height: received.height,
|
|
23
|
+
});
|
|
25
24
|
|
|
26
|
-
const
|
|
27
|
-
{
|
|
28
|
-
type: 'binary',
|
|
29
|
-
transferId,
|
|
30
|
-
size: received.data.length,
|
|
31
|
-
mimeType: 'image/png',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
width: received.width,
|
|
35
|
-
height: received.height,
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const result = await client.rpc['test.matchImageSnapshot'](
|
|
25
|
+
const result = await handle.matchImageSnapshot(
|
|
40
26
|
screenshotFile,
|
|
41
27
|
context.testFilePath,
|
|
42
28
|
options,
|
|
43
|
-
context.runner
|
|
29
|
+
context.runner,
|
|
44
30
|
);
|
|
45
31
|
|
|
46
32
|
return {
|
package/src/initialize.ts
CHANGED
|
@@ -3,10 +3,19 @@ import { getClient } from './client/index.js';
|
|
|
3
3
|
import { disableHMRWhenReady } from './disableHMRWhenReady.js';
|
|
4
4
|
import { setupJestMock } from './jest-mock.js';
|
|
5
5
|
|
|
6
|
-
// Polyfill for EventTarget
|
|
6
|
+
// Polyfill for EventTarget on runtimes that don't ship one (RN's JSC).
|
|
7
|
+
// Do NOT overwrite when a native ctor already exists (RN Web / browsers):
|
|
8
|
+
// Safari's EventTarget.dispatchEvent() does an internal brand check and
|
|
9
|
+
// rejects polyfill instances with a TypeError, which breaks any
|
|
10
|
+
// DOM-event-driven flow in the page — most visibly DRM (FairPlay) via
|
|
11
|
+
// libraries that re-dispatch synthetic `encrypted` events.
|
|
7
12
|
const Shim = require('event-target-shim');
|
|
8
|
-
globalThis.Event
|
|
9
|
-
globalThis.
|
|
13
|
+
if (typeof globalThis.Event !== 'function') {
|
|
14
|
+
globalThis.Event = Shim.Event;
|
|
15
|
+
}
|
|
16
|
+
if (typeof globalThis.EventTarget !== 'function') {
|
|
17
|
+
globalThis.EventTarget = Shim.EventTarget;
|
|
18
|
+
}
|
|
10
19
|
|
|
11
20
|
// Setup jest mock to warn users about using Jest APIs
|
|
12
21
|
setupJestMock();
|
|
@@ -25,10 +34,10 @@ setTimeout(() => {
|
|
|
25
34
|
void (async () => {
|
|
26
35
|
try {
|
|
27
36
|
await disableHMRWhenReady(() => HMRClient.disable(), 50);
|
|
28
|
-
const
|
|
37
|
+
const handle = await getClient();
|
|
29
38
|
|
|
30
39
|
const deviceDescriptor = getDeviceDescriptor();
|
|
31
|
-
|
|
40
|
+
handle.reportReady(deviceDescriptor);
|
|
32
41
|
} catch (error) {
|
|
33
42
|
console.error('Failed to initialize React Native Harness', error);
|
|
34
43
|
}
|
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
import * as ReactJSXRuntimeDev from 'react/jsx-dev-runtime';
|
|
2
2
|
|
|
3
|
+
type NamedElementType = {
|
|
4
|
+
displayName?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const isNamedElementType = (value: unknown): value is NamedElementType =>
|
|
9
|
+
(typeof value === 'function' ||
|
|
10
|
+
(typeof value === 'object' && value !== null)) &&
|
|
11
|
+
('displayName' in value || 'name' in value);
|
|
12
|
+
|
|
13
|
+
const isPropsObject = (value: unknown): value is Record<string, unknown> =>
|
|
14
|
+
typeof value === 'object' && value !== null;
|
|
15
|
+
|
|
3
16
|
export const Fragment = ReactJSXRuntimeDev.Fragment;
|
|
4
17
|
|
|
5
|
-
export function jsxDEV(
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
13
|
-
if (
|
|
14
|
-
type &&
|
|
15
|
-
(type.displayName === 'View' || type.name === 'View') &&
|
|
16
|
-
props &&
|
|
18
|
+
export function jsxDEV(...args: Parameters<typeof ReactJSXRuntimeDev.jsxDEV>) {
|
|
19
|
+
const [type, props, key, isStaticChildren, source, self] = args;
|
|
20
|
+
const isViewType =
|
|
21
|
+
isNamedElementType(type) &&
|
|
22
|
+
(type.displayName === 'View' || type.name === 'View');
|
|
23
|
+
const nextProps =
|
|
24
|
+
isViewType &&
|
|
25
|
+
isPropsObject(props) &&
|
|
17
26
|
props.collapsable === undefined
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
? { ...props, collapsable: true }
|
|
28
|
+
: props;
|
|
29
|
+
|
|
30
|
+
if (isViewType && isPropsObject(props) && props.collapsable === undefined) {
|
|
31
|
+
return ReactJSXRuntimeDev.jsxDEV(
|
|
32
|
+
type,
|
|
33
|
+
nextProps,
|
|
34
|
+
key,
|
|
35
|
+
isStaticChildren,
|
|
36
|
+
source,
|
|
37
|
+
self
|
|
38
|
+
);
|
|
20
39
|
}
|
|
21
40
|
return ReactJSXRuntimeDev.jsxDEV(
|
|
22
41
|
type,
|
|
23
|
-
|
|
42
|
+
nextProps,
|
|
24
43
|
key,
|
|
25
44
|
isStaticChildren,
|
|
26
45
|
source,
|
package/src/runner/runSuite.ts
CHANGED
|
@@ -4,6 +4,11 @@ import type {
|
|
|
4
4
|
TestSuite,
|
|
5
5
|
TestSuiteResult,
|
|
6
6
|
} from '@react-native-harness/bridge';
|
|
7
|
+
import {
|
|
8
|
+
setCurrentExpectTestState,
|
|
9
|
+
type HarnessExpectTestState,
|
|
10
|
+
} from '../expect/context.js';
|
|
11
|
+
import { flushExpectTestState } from '../expect/errors.js';
|
|
7
12
|
import { runHooks } from './hooks.js';
|
|
8
13
|
import { getTestExecutionError } from './errors.js';
|
|
9
14
|
import { TestRunnerContext } from './types.js';
|
|
@@ -15,7 +20,7 @@ declare global {
|
|
|
15
20
|
const runTest = async (
|
|
16
21
|
test: TestCase,
|
|
17
22
|
suite: TestSuite,
|
|
18
|
-
context: TestRunnerContext
|
|
23
|
+
context: TestRunnerContext,
|
|
19
24
|
): Promise<TestResult> => {
|
|
20
25
|
const startTime = Date.now();
|
|
21
26
|
|
|
@@ -69,14 +74,23 @@ const runTest = async (
|
|
|
69
74
|
return result;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
const expectTestState: HarnessExpectTestState = {};
|
|
78
|
+
setCurrentExpectTestState(expectTestState);
|
|
74
79
|
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
try {
|
|
81
|
+
// Run all beforeEach hooks from the current suite and its parents
|
|
82
|
+
await runHooks(suite, 'beforeEach');
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
// Run the actual test
|
|
85
|
+
await test.fn();
|
|
86
|
+
|
|
87
|
+
// Run all afterEach hooks from the current suite and its parents
|
|
88
|
+
await runHooks(suite, 'afterEach');
|
|
89
|
+
|
|
90
|
+
await flushExpectTestState(expectTestState);
|
|
91
|
+
} finally {
|
|
92
|
+
setCurrentExpectTestState(undefined);
|
|
93
|
+
}
|
|
80
94
|
|
|
81
95
|
const duration = Date.now() - startTime;
|
|
82
96
|
|
|
@@ -102,7 +116,7 @@ const runTest = async (
|
|
|
102
116
|
error,
|
|
103
117
|
context.testFilePath,
|
|
104
118
|
suite.name,
|
|
105
|
-
test.name
|
|
119
|
+
test.name,
|
|
106
120
|
);
|
|
107
121
|
const duration = Date.now() - startTime;
|
|
108
122
|
|
|
@@ -130,7 +144,7 @@ const runTest = async (
|
|
|
130
144
|
|
|
131
145
|
export const runSuite = async (
|
|
132
146
|
suite: TestSuite,
|
|
133
|
-
context: TestRunnerContext
|
|
147
|
+
context: TestRunnerContext,
|
|
134
148
|
): Promise<TestSuiteResult> => {
|
|
135
149
|
const startTime = Date.now();
|
|
136
150
|
|
|
@@ -212,10 +226,10 @@ export const runSuite = async (
|
|
|
212
226
|
|
|
213
227
|
// Check if any tests or child suites failed
|
|
214
228
|
const hasFailedTests = testResults.some(
|
|
215
|
-
(result) => result.status === 'failed'
|
|
229
|
+
(result) => result.status === 'failed',
|
|
216
230
|
);
|
|
217
231
|
const hasFailedSuites = suiteResults.some(
|
|
218
|
-
(result) => result.status === 'failed'
|
|
232
|
+
(result) => result.status === 'failed',
|
|
219
233
|
);
|
|
220
234
|
|
|
221
235
|
if (hasFailedTests || hasFailedSuites) {
|
package/src/waitFor.ts
CHANGED
|
@@ -114,6 +114,12 @@ export interface WaitUntilOptions
|
|
|
114
114
|
|
|
115
115
|
type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T;
|
|
116
116
|
|
|
117
|
+
const isPromiseLike = <T>(value: T | PromiseLike<T>): value is PromiseLike<T> =>
|
|
118
|
+
value !== null &&
|
|
119
|
+
typeof value === 'object' &&
|
|
120
|
+
'then' in value &&
|
|
121
|
+
typeof value.then === 'function';
|
|
122
|
+
|
|
117
123
|
export function waitUntil<T>(
|
|
118
124
|
callback: WaitUntilCallback<T>,
|
|
119
125
|
options: number | WaitUntilOptions = {}
|
|
@@ -164,12 +170,8 @@ export function waitUntil<T>(
|
|
|
164
170
|
}
|
|
165
171
|
try {
|
|
166
172
|
const result = callback();
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
typeof result === 'object' &&
|
|
170
|
-
typeof (result as any).then === 'function'
|
|
171
|
-
) {
|
|
172
|
-
const thenable = result as PromiseLike<T>;
|
|
173
|
+
if (isPromiseLike(result)) {
|
|
174
|
+
const thenable = result;
|
|
173
175
|
promiseStatus = 'pending';
|
|
174
176
|
thenable.then(
|
|
175
177
|
(resolvedValue) => {
|