@react-native-harness/runtime 1.1.0-rc.4 → 1.2.0-rc.1
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/disableHMRWhenReady.d.ts.map +1 -1
- package/dist/disableHMRWhenReady.js +10 -4
- 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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/initialize.js +11 -1
- package/dist/jsx/jsx-runtime.d.ts +3 -1
- package/dist/jsx/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-runtime.js +8 -0
- package/dist/render/TestComponentOverlay.d.ts.map +1 -1
- package/dist/render/TestComponentOverlay.js +1 -2
- package/dist/runner/runSuite.d.ts.map +1 -1
- package/dist/runner/runSuite.js +16 -6
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/ui/ReadyScreen.d.ts.map +1 -1
- package/dist/ui/ReadyScreen.js +8 -97
- package/dist/ui/RunnerScreen.d.ts +8 -0
- package/dist/ui/RunnerScreen.d.ts.map +1 -0
- package/dist/ui/RunnerScreen.js +58 -0
- package/dist/ui/WrongEnvironmentScreen.d.ts.map +1 -1
- package/dist/ui/WrongEnvironmentScreen.js +3 -77
- package/dist/ui/images.d.ts +3 -0
- package/dist/ui/images.d.ts.map +1 -0
- package/dist/ui/images.js +2 -0
- package/out-tsc/vitest/src/client/getWSServer.d.ts.map +1 -1
- 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/disableHMRWhenReady.d.ts.map +1 -1
- 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/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.map +1 -1
- package/out-tsc/vitest/src/index.d.ts +1 -0
- package/out-tsc/vitest/src/index.d.ts.map +1 -1
- package/out-tsc/vitest/src/jsx/jsx-runtime.d.ts +3 -1
- package/out-tsc/vitest/src/jsx/jsx-runtime.d.ts.map +1 -1
- package/out-tsc/vitest/src/render/TestComponentOverlay.d.ts.map +1 -1
- package/out-tsc/vitest/src/runner/runSuite.d.ts.map +1 -1
- package/out-tsc/vitest/src/ui/ReadyScreen.d.ts.map +1 -1
- 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.map +1 -1
- 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/tsconfig.spec.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/disableHMRWhenReady.test.ts +42 -0
- package/src/disableHMRWhenReady.ts +15 -7
- package/src/expect/context.ts +30 -0
- package/src/expect/errors.ts +76 -0
- package/src/expect/expect.ts +16 -5
- package/src/index.ts +1 -0
- package/src/initialize.ts +11 -5
- package/src/jsx/jsx-runtime.ts +16 -1
- package/src/react-native.d.ts +14 -0
- package/src/render/TestComponentOverlay.tsx +5 -2
- package/src/runner/runSuite.ts +25 -11
- package/src/ui/ReadyScreen.tsx +10 -130
- package/src/ui/RunnerScreen.tsx +93 -0
- package/src/ui/WrongEnvironmentScreen.tsx +6 -90
- package/src/ui/images.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disableHMRWhenReady.d.ts","sourceRoot":"","sources":["../src/disableHMRWhenReady.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"disableHMRWhenReady.d.ts","sourceRoot":"","sources":["../src/disableHMRWhenReady.ts"],"names":[],"mappings":"AAIA,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,IAAI,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,SAAK,iBAmChB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Platform } from
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
const HMR_SETUP_ERROR = 'Expected HMRClient.setup() call at startup.';
|
|
2
3
|
export function disableHMRWhenReady(disable, retriesLeft, retryDelay = 10) {
|
|
3
4
|
return new Promise((resolve, reject) => {
|
|
4
5
|
if (Platform.OS === 'web') {
|
|
@@ -12,12 +13,17 @@ export function disableHMRWhenReady(disable, retriesLeft, retryDelay = 10) {
|
|
|
12
13
|
resolve();
|
|
13
14
|
}
|
|
14
15
|
catch (error) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
error.message.includes('Expected HMRClient.setup() call at startup.')) {
|
|
16
|
+
const isMissingHMRSetupError = error instanceof Error && error.message.includes(HMR_SETUP_ERROR);
|
|
17
|
+
if (remaining > 0 && isMissingHMRSetupError) {
|
|
18
18
|
setTimeout(() => attempt(remaining - 1), retryDelay);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
+
// Expo's metro runtime does not guarantee that React Native's HMRClient
|
|
22
|
+
// is initialized, so disabling HMR is best-effort in that environment.
|
|
23
|
+
if (isMissingHMRSetupError) {
|
|
24
|
+
resolve();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
21
27
|
reject(error);
|
|
22
28
|
}
|
|
23
29
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type HarnessExpectError = {
|
|
2
|
+
name?: string;
|
|
3
|
+
message?: string;
|
|
4
|
+
stack?: string;
|
|
5
|
+
};
|
|
6
|
+
export type HarnessExpectTestState = {
|
|
7
|
+
result?: {
|
|
8
|
+
state: 'pass' | 'fail';
|
|
9
|
+
errors?: HarnessExpectError[];
|
|
10
|
+
};
|
|
11
|
+
promises?: Promise<unknown>[];
|
|
12
|
+
onFinished?: Array<() => void | Promise<void>>;
|
|
13
|
+
};
|
|
14
|
+
declare global {
|
|
15
|
+
var HARNESS_EXPECT_TEST_STATE: HarnessExpectTestState | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare const getCurrentExpectTestState: () => HarnessExpectTestState | undefined;
|
|
18
|
+
export declare const setCurrentExpectTestState: (state: HarnessExpectTestState | undefined) => void;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/expect/context.ts"],"names":[],"mappings":"AAAA,KAAK,kBAAkB,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE;QACP,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;KAC/B,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,yBAAyB,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACnE;AAED,eAAO,MAAM,yBAAyB,QAClC,sBAAsB,GACtB,SAEH,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,OAAO,sBAAsB,GAAG,SAAS,KACxC,IAEF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/expect/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAgD3D,eAAO,MAAM,oBAAoB,GAC/B,OAAO,sBAAsB,KAC5B,OAAO,CAAC,IAAI,CAyBd,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const formatErrorMessage = (error) => {
|
|
2
|
+
if (error instanceof Error) {
|
|
3
|
+
return `${error.name}: ${error.message}`;
|
|
4
|
+
}
|
|
5
|
+
if (error && typeof error === 'object') {
|
|
6
|
+
const maybeError = error;
|
|
7
|
+
if (maybeError.name || maybeError.message) {
|
|
8
|
+
return [maybeError.name, maybeError.message].filter(Boolean).join(': ');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return String(error);
|
|
12
|
+
};
|
|
13
|
+
const createExpectError = (errors, title) => {
|
|
14
|
+
const message = [title, ...errors.map(formatErrorMessage)]
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join('\n\n');
|
|
17
|
+
const error = new Error(message);
|
|
18
|
+
const firstError = errors.find((value) => !!value && typeof value === 'object');
|
|
19
|
+
if (firstError?.name) {
|
|
20
|
+
error.name = firstError.name;
|
|
21
|
+
}
|
|
22
|
+
if (firstError?.stack) {
|
|
23
|
+
error.stack = firstError.stack.replace(/^([^\n]+)(\n|$)/, `${error.name}: ${message}$2`);
|
|
24
|
+
}
|
|
25
|
+
return error;
|
|
26
|
+
};
|
|
27
|
+
export const flushExpectTestState = async (state) => {
|
|
28
|
+
if (state.promises?.length) {
|
|
29
|
+
const results = await Promise.allSettled(state.promises);
|
|
30
|
+
const rejected = results
|
|
31
|
+
.filter((result) => result.status === 'rejected')
|
|
32
|
+
.map((result) => result.reason);
|
|
33
|
+
if (rejected.length > 0) {
|
|
34
|
+
throw createExpectError(rejected);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (const hook of state.onFinished ?? []) {
|
|
38
|
+
await hook();
|
|
39
|
+
}
|
|
40
|
+
const softErrors = state.result?.errors ?? [];
|
|
41
|
+
if (softErrors.length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
throw createExpectError(softErrors, 'Soft assertion failures:');
|
|
45
|
+
};
|
|
@@ -1 +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;
|
|
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;AAI7B,OAAO,YAAY,CAAC;AAGpB,wBAAgB,YAAY,IAAI,YAAY,CAkG3C;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/expect.js
CHANGED
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
import { addCustomEqualityTesters, ASYMMETRIC_MATCHERS_OBJECT, customMatchers, getState, GLOBAL_EXPECT, setState, } from '@vitest/expect';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
// Setup additional matchers
|
|
6
|
+
import { getCurrentExpectTestState } from './context.js';
|
|
6
7
|
import './setup.js';
|
|
7
8
|
import { toMatchImageSnapshot } from './matchers/toMatchImageSnapshot.js';
|
|
8
9
|
export function createExpect() {
|
|
9
10
|
const expect = ((value, message) => {
|
|
10
11
|
const { assertionCalls } = getState(expect);
|
|
11
12
|
setState({ assertionCalls: assertionCalls + 1 }, expect);
|
|
12
|
-
|
|
13
|
+
const assertion = chai.expect(value, message);
|
|
14
|
+
const currentTest = getCurrentExpectTestState();
|
|
15
|
+
return currentTest && assertion.withTest
|
|
16
|
+
? assertion.withTest(currentTest)
|
|
17
|
+
: assertion;
|
|
13
18
|
});
|
|
14
19
|
Object.assign(expect, chai.expect);
|
|
15
20
|
Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AACxB,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,EAAE,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACzD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AACxB,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,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
|
@@ -16,7 +16,17 @@ const HMRClientModule = require('react-native/Libraries/Utilities/HMRClient');
|
|
|
16
16
|
const HMRClient = 'default' in HMRClientModule ? HMRClientModule.default : HMRClientModule;
|
|
17
17
|
// Wait for HMRClient to be initialized
|
|
18
18
|
setTimeout(() => {
|
|
19
|
-
void
|
|
19
|
+
void (async () => {
|
|
20
|
+
try {
|
|
21
|
+
await disableHMRWhenReady(() => HMRClient.disable(), 50);
|
|
22
|
+
const client = await getClient();
|
|
23
|
+
const deviceDescriptor = getDeviceDescriptor();
|
|
24
|
+
await client.rpc.reportReady(deviceDescriptor);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('Failed to initialize React Native Harness', error);
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
20
30
|
});
|
|
21
31
|
// Re-throw fatal errors
|
|
22
32
|
ErrorUtils.setGlobalHandler((error) => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const Fragment: React.ExoticComponent<React.FragmentProps>;
|
|
2
3
|
export declare function jsx(type: React.ElementType, props: unknown, key?: React.Key): React.ReactElement;
|
|
3
4
|
export declare function jsxs(type: React.ElementType, props: unknown, key?: React.Key): React.ReactElement;
|
|
5
|
+
export declare function createElement(type: React.ElementType, props?: Record<string, unknown> | null, ...children: React.ReactNode[]): React.ReactElement;
|
|
4
6
|
//# sourceMappingURL=jsx-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx/jsx-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx/jsx-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,eAAO,MAAM,QAAQ,4CAA2B,CAAC;AAmBjD,wBAAgB,GAAG,CACjB,IAAI,EAAE,KAAK,CAAC,WAAW,EACvB,KAAK,EAAE,OAAO,EACd,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,GACd,KAAK,CAAC,YAAY,CAEpB;AAED,wBAAgB,IAAI,CAClB,IAAI,EAAE,KAAK,CAAC,WAAW,EACvB,KAAK,EAAE,OAAO,EACd,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,GACd,KAAK,CAAC,YAAY,CAEpB;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,KAAK,CAAC,WAAW,EACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACtC,GAAG,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,GAC7B,KAAK,CAAC,YAAY,CAQpB"}
|
package/dist/jsx/jsx-runtime.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { View } from 'react-native';
|
|
2
3
|
import * as ReactJSXRuntime from 'react/jsx-runtime';
|
|
3
4
|
import { getHarnessGlobal } from '../globals.js';
|
|
@@ -17,3 +18,10 @@ export function jsx(type, props, key) {
|
|
|
17
18
|
export function jsxs(type, props, key) {
|
|
18
19
|
return wrap(type, props, key, true);
|
|
19
20
|
}
|
|
21
|
+
export function createElement(type, props, ...children) {
|
|
22
|
+
const disableViewFlattening = getHarnessGlobal().disableViewFlattening;
|
|
23
|
+
if (disableViewFlattening && type === View) {
|
|
24
|
+
props = { ...props, collapsable: false };
|
|
25
|
+
}
|
|
26
|
+
return React.createElement(type, props, ...children);
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestComponentOverlay.d.ts","sourceRoot":"","sources":["../../src/render/TestComponentOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAqBzC,eAAO,MAAM,oBAAoB,QAAO,KAAK,CAAC,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"TestComponentOverlay.d.ts","sourceRoot":"","sources":["../../src/render/TestComponentOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAqBzC,eAAO,MAAM,oBAAoB,QAAO,KAAK,CAAC,YAAY,GAAG,IAyC5D,CAAC"}
|
|
@@ -44,11 +44,10 @@ export const TestComponentOverlay = () => {
|
|
|
44
44
|
store.getState().setOnLayoutCallback(null);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
return (_jsx(View, { style: styles.overlay, onLayout: handleLayout, children: _jsx(ErrorBoundary, { children: element }) }, key));
|
|
47
|
+
return (_jsx(View, { style: [StyleSheet.absoluteFill, styles.overlay], onLayout: handleLayout, children: _jsx(ErrorBoundary, { children: element }) }, key));
|
|
48
48
|
};
|
|
49
49
|
const styles = StyleSheet.create({
|
|
50
50
|
overlay: {
|
|
51
|
-
...StyleSheet.absoluteFillObject,
|
|
52
51
|
backgroundColor: '#0a1628',
|
|
53
52
|
zIndex: 1000,
|
|
54
53
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runSuite.d.ts","sourceRoot":"","sources":["../../src/runner/runSuite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,SAAS,EACT,eAAe,EAChB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"runSuite.d.ts","sourceRoot":"","sources":["../../src/runner/runSuite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,SAAS,EACT,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,iBAAiB,EAAE,MAAM,CAAC;CAC/B;AA+HD,eAAO,MAAM,QAAQ,GACnB,OAAO,SAAS,EAChB,SAAS,iBAAiB,KACzB,OAAO,CAAC,eAAe,CAoIzB,CAAC"}
|
package/dist/runner/runSuite.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { setCurrentExpectTestState, } from '../expect/context.js';
|
|
2
|
+
import { flushExpectTestState } from '../expect/errors.js';
|
|
1
3
|
import { runHooks } from './hooks.js';
|
|
2
4
|
import { getTestExecutionError } from './errors.js';
|
|
3
5
|
const runTest = async (test, suite, context) => {
|
|
@@ -45,12 +47,20 @@ const runTest = async (test, suite, context) => {
|
|
|
45
47
|
});
|
|
46
48
|
return result;
|
|
47
49
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const expectTestState = {};
|
|
51
|
+
setCurrentExpectTestState(expectTestState);
|
|
52
|
+
try {
|
|
53
|
+
// Run all beforeEach hooks from the current suite and its parents
|
|
54
|
+
await runHooks(suite, 'beforeEach');
|
|
55
|
+
// Run the actual test
|
|
56
|
+
await test.fn();
|
|
57
|
+
// Run all afterEach hooks from the current suite and its parents
|
|
58
|
+
await runHooks(suite, 'afterEach');
|
|
59
|
+
await flushExpectTestState(expectTestState);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
setCurrentExpectTestState(undefined);
|
|
63
|
+
}
|
|
54
64
|
const duration = Date.now() - startTime;
|
|
55
65
|
const result = {
|
|
56
66
|
name: test.name,
|