@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,39 @@
|
|
|
1
|
+
type TestFn = () => void | Promise<void>;
|
|
2
|
+
export type TestStatus = 'active' | 'skipped' | 'todo';
|
|
3
|
+
export interface TestCase {
|
|
4
|
+
name: string;
|
|
5
|
+
fn: TestFn;
|
|
6
|
+
status: TestStatus;
|
|
7
|
+
}
|
|
8
|
+
export interface TestSuite {
|
|
9
|
+
name: string;
|
|
10
|
+
tests: TestCase[];
|
|
11
|
+
suites: TestSuite[];
|
|
12
|
+
beforeAll: TestFn[];
|
|
13
|
+
afterAll: TestFn[];
|
|
14
|
+
beforeEach: TestFn[];
|
|
15
|
+
afterEach: TestFn[];
|
|
16
|
+
status?: TestStatus;
|
|
17
|
+
_hasFocused?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const describe: ((name: string, fn: () => void) => void) & {
|
|
20
|
+
skip: (name: string, fn: () => void) => void;
|
|
21
|
+
only: (name: string, fn: () => void) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const test: ((name: string, fn: TestFn) => void) & {
|
|
24
|
+
skip: (name: string, fn: TestFn) => void;
|
|
25
|
+
only: (name: string, fn: TestFn) => void;
|
|
26
|
+
todo: (name: string) => void;
|
|
27
|
+
};
|
|
28
|
+
export declare const it: ((name: string, fn: TestFn) => void) & {
|
|
29
|
+
skip: (name: string, fn: TestFn) => void;
|
|
30
|
+
only: (name: string, fn: TestFn) => void;
|
|
31
|
+
todo: (name: string) => void;
|
|
32
|
+
};
|
|
33
|
+
export declare function beforeAll(fn: TestFn): void;
|
|
34
|
+
export declare function afterAll(fn: TestFn): void;
|
|
35
|
+
export declare function beforeEach(fn: TestFn): void;
|
|
36
|
+
export declare function afterEach(fn: TestFn): void;
|
|
37
|
+
export declare const collectTests: (fn: () => void) => TestSuite;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAwED,eAAO,MAAM,QAAQ,UACZ,MAAM,MAAM,MAAM,IAAI;iBA+Bd,MAAM,MAAM,MAAM,IAAI;iBAkBtB,MAAM,MAAM,MAAM,IAAI;CA0CtC,CAAC;AAcF,eAAO,MAAM,IAAI,UACR,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAQtB,CAAC;AAEF,eAAO,MAAM,EAAE,UAlDN,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAUD,CAAC;AAEvB,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,QAMlC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,QAMpC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAWD,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,IAAI,KAAG,SAK7C,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
const clearState = () => {
|
|
2
|
+
const rootSuite = createSuite('root');
|
|
3
|
+
globalThis.__INTERNAL_COLLECTION__ = {
|
|
4
|
+
rootSuite,
|
|
5
|
+
currentSuite: rootSuite,
|
|
6
|
+
hasFocusedTests: false,
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const getCurrentSuite = () => globalThis.__INTERNAL_COLLECTION__?.currentSuite ??
|
|
10
|
+
null;
|
|
11
|
+
const getRootSuite = () => {
|
|
12
|
+
const internalCollection = globalThis
|
|
13
|
+
.__INTERNAL_COLLECTION__;
|
|
14
|
+
if (!internalCollection) {
|
|
15
|
+
throw new Error('Internal collection not initialized');
|
|
16
|
+
}
|
|
17
|
+
return internalCollection.rootSuite;
|
|
18
|
+
};
|
|
19
|
+
const setCurrentSuite = (suite) => {
|
|
20
|
+
const internalCollection = globalThis
|
|
21
|
+
.__INTERNAL_COLLECTION__;
|
|
22
|
+
if (internalCollection) {
|
|
23
|
+
internalCollection.currentSuite = suite;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const getHasFocusedTests = () => {
|
|
27
|
+
const internalCollection = globalThis
|
|
28
|
+
.__INTERNAL_COLLECTION__;
|
|
29
|
+
return internalCollection?.hasFocusedTests || false;
|
|
30
|
+
};
|
|
31
|
+
const setHasFocusedTests = (value) => {
|
|
32
|
+
const internalCollection = globalThis
|
|
33
|
+
.__INTERNAL_COLLECTION__;
|
|
34
|
+
if (internalCollection) {
|
|
35
|
+
internalCollection.hasFocusedTests = value;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function createSuite(name, status = 'active') {
|
|
39
|
+
return {
|
|
40
|
+
name,
|
|
41
|
+
tests: [],
|
|
42
|
+
suites: [],
|
|
43
|
+
beforeAll: [],
|
|
44
|
+
afterAll: [],
|
|
45
|
+
beforeEach: [],
|
|
46
|
+
afterEach: [],
|
|
47
|
+
status,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export const describe = Object.assign((name, fn) => {
|
|
51
|
+
const suite = createSuite(name);
|
|
52
|
+
const previousSuite = getCurrentSuite();
|
|
53
|
+
// Only mark suites as skipped when ran after .only is called
|
|
54
|
+
suite.status =
|
|
55
|
+
getHasFocusedTests() && previousSuite !== getRootSuite()
|
|
56
|
+
? 'skipped'
|
|
57
|
+
: 'active';
|
|
58
|
+
setCurrentSuite(suite);
|
|
59
|
+
try {
|
|
60
|
+
fn();
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
setCurrentSuite(previousSuite);
|
|
64
|
+
}
|
|
65
|
+
// If this suite has focused tests/suites, propagate up to parent
|
|
66
|
+
if (suite._hasFocused && previousSuite) {
|
|
67
|
+
previousSuite._hasFocused = true;
|
|
68
|
+
suite.status = 'active';
|
|
69
|
+
}
|
|
70
|
+
// Add the suite to its parent
|
|
71
|
+
if (previousSuite) {
|
|
72
|
+
previousSuite.suites.push(suite);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
getRootSuite().suites.push(suite);
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
skip: (name, fn) => {
|
|
79
|
+
const suite = createSuite(name, 'skipped');
|
|
80
|
+
const previousSuite = getCurrentSuite();
|
|
81
|
+
setCurrentSuite(suite);
|
|
82
|
+
try {
|
|
83
|
+
fn();
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
setCurrentSuite(previousSuite);
|
|
87
|
+
}
|
|
88
|
+
// Add the suite to its parent
|
|
89
|
+
if (previousSuite) {
|
|
90
|
+
previousSuite.suites.push(suite);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
getRootSuite().suites.push(suite);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
only: (name, fn) => {
|
|
97
|
+
// Mark that we have focused tests in the test run
|
|
98
|
+
setHasFocusedTests(true);
|
|
99
|
+
const suite = createSuite(name, 'active');
|
|
100
|
+
suite._hasFocused = true;
|
|
101
|
+
const previousSuite = getCurrentSuite();
|
|
102
|
+
// Mark that parent suite has a focused child and should remain active
|
|
103
|
+
if (previousSuite) {
|
|
104
|
+
previousSuite._hasFocused = true;
|
|
105
|
+
// Skip sibling suites
|
|
106
|
+
for (const s of previousSuite.suites) {
|
|
107
|
+
s.status = 'skipped';
|
|
108
|
+
}
|
|
109
|
+
previousSuite.status = 'active';
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// If this is at the root level, mark all existing suites as skipped
|
|
113
|
+
const rootSuite = getRootSuite();
|
|
114
|
+
for (const s of rootSuite.suites) {
|
|
115
|
+
s.status = 'skipped';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
setCurrentSuite(suite);
|
|
119
|
+
try {
|
|
120
|
+
fn();
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
setCurrentSuite(previousSuite);
|
|
124
|
+
}
|
|
125
|
+
// Add the suite to its parent
|
|
126
|
+
if (previousSuite) {
|
|
127
|
+
previousSuite.suites.push(suite);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
getRootSuite().suites.push(suite);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
function createTest(name, fn, status = 'active') {
|
|
135
|
+
return {
|
|
136
|
+
name,
|
|
137
|
+
fn,
|
|
138
|
+
status,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export const test = Object.assign((name, fn) => {
|
|
142
|
+
const currentSuite = getCurrentSuite();
|
|
143
|
+
if (!currentSuite) {
|
|
144
|
+
throw new Error('test() must be called within a describe() block');
|
|
145
|
+
}
|
|
146
|
+
// If running tests directly, don't apply the hasFocusedTests check
|
|
147
|
+
// Tests only get skipped by `.only` in the same test suite
|
|
148
|
+
const status = currentSuite._hasFocused ? 'skipped' : 'active';
|
|
149
|
+
currentSuite.tests.push(createTest(name, fn, status));
|
|
150
|
+
}, {
|
|
151
|
+
skip: (name, fn) => {
|
|
152
|
+
const currentSuite = getCurrentSuite();
|
|
153
|
+
if (!currentSuite) {
|
|
154
|
+
throw new Error('test.skip() must be called within a describe() block');
|
|
155
|
+
}
|
|
156
|
+
currentSuite.tests.push(createTest(name, fn, 'skipped'));
|
|
157
|
+
},
|
|
158
|
+
only: (name, fn) => {
|
|
159
|
+
const currentSuite = getCurrentSuite();
|
|
160
|
+
if (!currentSuite) {
|
|
161
|
+
throw new Error('test.only() must be called within a describe() block');
|
|
162
|
+
}
|
|
163
|
+
// Mark the suite as having focused tests
|
|
164
|
+
currentSuite._hasFocused = true;
|
|
165
|
+
// Mark all existing tests in this suite as skipped
|
|
166
|
+
for (const test of currentSuite.tests) {
|
|
167
|
+
test.status = 'skipped';
|
|
168
|
+
}
|
|
169
|
+
// Add the new focused test
|
|
170
|
+
const newTest = createTest(name, fn, 'active');
|
|
171
|
+
currentSuite.tests.push(newTest);
|
|
172
|
+
// All subsequent tests in this suite will be skipped
|
|
173
|
+
// This happens automatically because of the _hasFocused flag
|
|
174
|
+
},
|
|
175
|
+
todo: (name) => {
|
|
176
|
+
const currentSuite = getCurrentSuite();
|
|
177
|
+
if (!currentSuite) {
|
|
178
|
+
throw new Error('test.todo() must be called within a describe() block');
|
|
179
|
+
}
|
|
180
|
+
currentSuite.tests.push(createTest(name, () => { }, 'todo'));
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
export const it = test;
|
|
184
|
+
export function beforeAll(fn) {
|
|
185
|
+
const currentSuite = getCurrentSuite();
|
|
186
|
+
if (!currentSuite) {
|
|
187
|
+
throw new Error('beforeAll() must be called within a describe() block');
|
|
188
|
+
}
|
|
189
|
+
currentSuite.beforeAll.push(fn);
|
|
190
|
+
}
|
|
191
|
+
export function afterAll(fn) {
|
|
192
|
+
const currentSuite = getCurrentSuite();
|
|
193
|
+
if (!currentSuite) {
|
|
194
|
+
throw new Error('afterAll() must be called within a describe() block');
|
|
195
|
+
}
|
|
196
|
+
currentSuite.afterAll.push(fn);
|
|
197
|
+
}
|
|
198
|
+
export function beforeEach(fn) {
|
|
199
|
+
const currentSuite = getCurrentSuite();
|
|
200
|
+
if (!currentSuite) {
|
|
201
|
+
throw new Error('beforeEach() must be called within a describe() block');
|
|
202
|
+
}
|
|
203
|
+
currentSuite.beforeEach.push(fn);
|
|
204
|
+
}
|
|
205
|
+
export function afterEach(fn) {
|
|
206
|
+
const currentSuite = getCurrentSuite();
|
|
207
|
+
if (!currentSuite) {
|
|
208
|
+
throw new Error('afterEach() must be called within a describe() block');
|
|
209
|
+
}
|
|
210
|
+
currentSuite.afterEach.push(fn);
|
|
211
|
+
}
|
|
212
|
+
const typedGlobal = global;
|
|
213
|
+
typedGlobal.describe = describe;
|
|
214
|
+
typedGlobal.test = test;
|
|
215
|
+
typedGlobal.it = it;
|
|
216
|
+
typedGlobal.beforeAll = beforeAll;
|
|
217
|
+
typedGlobal.afterAll = afterAll;
|
|
218
|
+
typedGlobal.beforeEach = beforeEach;
|
|
219
|
+
typedGlobal.afterEach = afterEach;
|
|
220
|
+
export const collectTests = (fn) => {
|
|
221
|
+
clearState();
|
|
222
|
+
fn();
|
|
223
|
+
return getRootSuite();
|
|
224
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEntryComponent.d.ts","sourceRoot":"","sources":["../src/getEntryComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEpC,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,UAAU,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,iBAAiB,GAAI,WAAW,aAAa,QAMzD,CAAC"}
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAIlE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,KAAG,IAQhD,CAAC"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { URL, URLSearchParams } from 'react-native-url-polyfill';
|
|
3
|
+
const METRO_URL = 'http://localhost:8081';
|
|
4
|
+
const getModuleUrl = (fileName) => {
|
|
5
|
+
const url = new URL(METRO_URL);
|
|
6
|
+
const bundleName = fileName.split('.').slice(0, -1).join('.') + '.bundle';
|
|
7
|
+
url.search = new URLSearchParams({
|
|
8
|
+
modulesOnly: 'true',
|
|
9
|
+
platform: Platform.OS,
|
|
10
|
+
}).toString();
|
|
11
|
+
url.pathname = `/${bundleName}`;
|
|
12
|
+
return url.toString();
|
|
13
|
+
};
|
|
14
|
+
export const fetchModule = async (fileName) => {
|
|
15
|
+
const url = getModuleUrl(fileName);
|
|
16
|
+
const response = await fetch(url);
|
|
17
|
+
return response.text();
|
|
18
|
+
};
|
|
19
|
+
export const executeModule = (moduleJs) => {
|
|
20
|
+
const __rMatch = moduleJs.match(/__r\((\d+)\)/);
|
|
21
|
+
const __rParam = __rMatch[1];
|
|
22
|
+
// eslint-disable-next-line no-eval
|
|
23
|
+
eval(moduleJs);
|
|
24
|
+
// @ts-ignore - __r is injected by Metro bundler
|
|
25
|
+
__r(Number(__rParam));
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.web.d.ts","sourceRoot":"","sources":["../src/module.web.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// const context = require.context('../..', false, /\.test.tsx$/);
|
|
2
|
+
export {};
|
|
3
|
+
// export const fetchModule = async (fileName: string): Promise<string> => {
|
|
4
|
+
// return fileName;
|
|
5
|
+
// };
|
|
6
|
+
// export const executeModule = (moduleJs: string): void => {
|
|
7
|
+
// const modulePath = `./${moduleJs}`;
|
|
8
|
+
// if (!context.keys().includes(modulePath)) {
|
|
9
|
+
// throw new Error(`Module ${moduleJs} not found`);
|
|
10
|
+
// }
|
|
11
|
+
// return context(modulePath);
|
|
12
|
+
// };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-harness/runtime",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"development": "./src/index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"react": "~18.3.1",
|
|
19
|
+
"react-native": "~0.76.3"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@react-native-harness/bridge": "workspace:*",
|
|
23
|
+
"chai": "^5.2.0",
|
|
24
|
+
"chai-as-promised": "^8.0.1",
|
|
25
|
+
"react-native-url-polyfill": "^2.0.0",
|
|
26
|
+
"sinon": "^21.0.0",
|
|
27
|
+
"sinon-chai": "^4.0.0",
|
|
28
|
+
"zustand": "^5.0.5"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@react-native-harness/interaction-engine": "workspace:*",
|
|
32
|
+
"@types/chai": "^5.2.2",
|
|
33
|
+
"@types/chai-as-promised": "^8.0.2",
|
|
34
|
+
"@types/sinon": "^17.0.4",
|
|
35
|
+
"@types/sinon-chai": "^4.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/rntl/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGnE,eAAO,MAAM,SAAS,QAAO,YAU5B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { state } from '../state.js';
|
|
2
|
+
export const getClient = () => {
|
|
3
|
+
const client = state.getState().client;
|
|
4
|
+
if (!client) {
|
|
5
|
+
throw new Error('Client not found. Are you sure you are running the test in the react-native-harness environment?');
|
|
6
|
+
}
|
|
7
|
+
return client;
|
|
8
|
+
};
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type TestFn = () => void | Promise<void>;
|
|
2
|
+
export type TestStatus = 'active' | 'skipped' | 'todo';
|
|
3
|
+
export interface TestCase {
|
|
4
|
+
name: string;
|
|
5
|
+
fn: TestFn;
|
|
6
|
+
status: TestStatus;
|
|
7
|
+
}
|
|
8
|
+
export interface TestSuite {
|
|
9
|
+
name: string;
|
|
10
|
+
tests: TestCase[];
|
|
11
|
+
suites: TestSuite[];
|
|
12
|
+
beforeAll: TestFn[];
|
|
13
|
+
afterAll: TestFn[];
|
|
14
|
+
beforeEach: TestFn[];
|
|
15
|
+
afterEach: TestFn[];
|
|
16
|
+
status?: TestStatus;
|
|
17
|
+
_hasFocused?: boolean;
|
|
18
|
+
}
|
|
3
19
|
export declare const describe: ((name: string, fn: () => void) => void) & {
|
|
4
20
|
skip: (name: string, fn: () => void) => void;
|
|
5
21
|
only: (name: string, fn: () => void) => void;
|
|
@@ -18,5 +34,6 @@ export declare function beforeAll(fn: TestFn): void;
|
|
|
18
34
|
export declare function afterAll(fn: TestFn): void;
|
|
19
35
|
export declare function beforeEach(fn: TestFn): void;
|
|
20
36
|
export declare function afterEach(fn: TestFn): void;
|
|
21
|
-
export declare const collectTests: (fn: () => void
|
|
22
|
-
|
|
37
|
+
export declare const collectTests: (fn: () => void) => TestSuite;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/rntl/describe.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAwED,eAAO,MAAM,QAAQ,UACZ,MAAM,MAAM,MAAM,IAAI;iBA+Bd,MAAM,MAAM,MAAM,IAAI;iBAkBtB,MAAM,MAAM,MAAM,IAAI;CA0CtC,CAAC;AAcF,eAAO,MAAM,IAAI,UACR,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAQtB,CAAC;AAEF,eAAO,MAAM,EAAE,UAlDN,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAUD,CAAC;AAEvB,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,QAMlC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,QAMpC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAED,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,IAAI,KAAG,SAK7C,CAAC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
const clearState = () => {
|
|
2
|
+
const rootSuite = createSuite('root');
|
|
3
|
+
globalThis.__INTERNAL_COLLECTION__ = {
|
|
4
|
+
rootSuite,
|
|
5
|
+
currentSuite: rootSuite,
|
|
6
|
+
hasFocusedTests: false,
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const getCurrentSuite = () => globalThis.__INTERNAL_COLLECTION__?.currentSuite ??
|
|
10
|
+
null;
|
|
11
|
+
const getRootSuite = () => {
|
|
12
|
+
const internalCollection = globalThis
|
|
13
|
+
.__INTERNAL_COLLECTION__;
|
|
14
|
+
if (!internalCollection) {
|
|
15
|
+
throw new Error('Internal collection not initialized');
|
|
16
|
+
}
|
|
17
|
+
return internalCollection.rootSuite;
|
|
18
|
+
};
|
|
19
|
+
const setCurrentSuite = (suite) => {
|
|
20
|
+
const internalCollection = globalThis
|
|
21
|
+
.__INTERNAL_COLLECTION__;
|
|
22
|
+
if (internalCollection) {
|
|
23
|
+
internalCollection.currentSuite = suite;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const getHasFocusedTests = () => {
|
|
27
|
+
const internalCollection = globalThis
|
|
28
|
+
.__INTERNAL_COLLECTION__;
|
|
29
|
+
return internalCollection?.hasFocusedTests || false;
|
|
30
|
+
};
|
|
31
|
+
const setHasFocusedTests = (value) => {
|
|
32
|
+
const internalCollection = globalThis
|
|
33
|
+
.__INTERNAL_COLLECTION__;
|
|
34
|
+
if (internalCollection) {
|
|
35
|
+
internalCollection.hasFocusedTests = value;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function createSuite(name, status = 'active') {
|
|
39
|
+
return {
|
|
40
|
+
name,
|
|
41
|
+
tests: [],
|
|
42
|
+
suites: [],
|
|
43
|
+
beforeAll: [],
|
|
44
|
+
afterAll: [],
|
|
45
|
+
beforeEach: [],
|
|
46
|
+
afterEach: [],
|
|
47
|
+
status,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export const describe = Object.assign((name, fn) => {
|
|
51
|
+
const suite = createSuite(name);
|
|
52
|
+
const previousSuite = getCurrentSuite();
|
|
53
|
+
// Only mark suites as skipped when ran after .only is called
|
|
54
|
+
suite.status =
|
|
55
|
+
getHasFocusedTests() && previousSuite !== getRootSuite()
|
|
56
|
+
? 'skipped'
|
|
57
|
+
: 'active';
|
|
58
|
+
setCurrentSuite(suite);
|
|
59
|
+
try {
|
|
60
|
+
fn();
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
setCurrentSuite(previousSuite);
|
|
64
|
+
}
|
|
65
|
+
// If this suite has focused tests/suites, propagate up to parent
|
|
66
|
+
if (suite._hasFocused && previousSuite) {
|
|
67
|
+
previousSuite._hasFocused = true;
|
|
68
|
+
suite.status = 'active';
|
|
69
|
+
}
|
|
70
|
+
// Add the suite to its parent
|
|
71
|
+
if (previousSuite) {
|
|
72
|
+
previousSuite.suites.push(suite);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
getRootSuite().suites.push(suite);
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
skip: (name, fn) => {
|
|
79
|
+
const suite = createSuite(name, 'skipped');
|
|
80
|
+
const previousSuite = getCurrentSuite();
|
|
81
|
+
setCurrentSuite(suite);
|
|
82
|
+
try {
|
|
83
|
+
fn();
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
setCurrentSuite(previousSuite);
|
|
87
|
+
}
|
|
88
|
+
// Add the suite to its parent
|
|
89
|
+
if (previousSuite) {
|
|
90
|
+
previousSuite.suites.push(suite);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
getRootSuite().suites.push(suite);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
only: (name, fn) => {
|
|
97
|
+
// Mark that we have focused tests in the test run
|
|
98
|
+
setHasFocusedTests(true);
|
|
99
|
+
const suite = createSuite(name, 'active');
|
|
100
|
+
suite._hasFocused = true;
|
|
101
|
+
const previousSuite = getCurrentSuite();
|
|
102
|
+
// Mark that parent suite has a focused child and should remain active
|
|
103
|
+
if (previousSuite) {
|
|
104
|
+
previousSuite._hasFocused = true;
|
|
105
|
+
// Skip sibling suites
|
|
106
|
+
for (const s of previousSuite.suites) {
|
|
107
|
+
s.status = 'skipped';
|
|
108
|
+
}
|
|
109
|
+
previousSuite.status = 'active';
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// If this is at the root level, mark all existing suites as skipped
|
|
113
|
+
const rootSuite = getRootSuite();
|
|
114
|
+
for (const s of rootSuite.suites) {
|
|
115
|
+
s.status = 'skipped';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
setCurrentSuite(suite);
|
|
119
|
+
try {
|
|
120
|
+
fn();
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
setCurrentSuite(previousSuite);
|
|
124
|
+
}
|
|
125
|
+
// Add the suite to its parent
|
|
126
|
+
if (previousSuite) {
|
|
127
|
+
previousSuite.suites.push(suite);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
getRootSuite().suites.push(suite);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
function createTest(name, fn, status = 'active') {
|
|
135
|
+
return {
|
|
136
|
+
name,
|
|
137
|
+
fn,
|
|
138
|
+
status,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export const test = Object.assign((name, fn) => {
|
|
142
|
+
const currentSuite = getCurrentSuite();
|
|
143
|
+
if (!currentSuite) {
|
|
144
|
+
throw new Error('test() must be called within a describe() block');
|
|
145
|
+
}
|
|
146
|
+
// If running tests directly, don't apply the hasFocusedTests check
|
|
147
|
+
// Tests only get skipped by `.only` in the same test suite
|
|
148
|
+
const status = currentSuite._hasFocused ? 'skipped' : 'active';
|
|
149
|
+
currentSuite.tests.push(createTest(name, fn, status));
|
|
150
|
+
}, {
|
|
151
|
+
skip: (name, fn) => {
|
|
152
|
+
const currentSuite = getCurrentSuite();
|
|
153
|
+
if (!currentSuite) {
|
|
154
|
+
throw new Error('test.skip() must be called within a describe() block');
|
|
155
|
+
}
|
|
156
|
+
currentSuite.tests.push(createTest(name, fn, 'skipped'));
|
|
157
|
+
},
|
|
158
|
+
only: (name, fn) => {
|
|
159
|
+
const currentSuite = getCurrentSuite();
|
|
160
|
+
if (!currentSuite) {
|
|
161
|
+
throw new Error('test.only() must be called within a describe() block');
|
|
162
|
+
}
|
|
163
|
+
// Mark the suite as having focused tests
|
|
164
|
+
currentSuite._hasFocused = true;
|
|
165
|
+
// Mark all existing tests in this suite as skipped
|
|
166
|
+
for (const test of currentSuite.tests) {
|
|
167
|
+
test.status = 'skipped';
|
|
168
|
+
}
|
|
169
|
+
// Add the new focused test
|
|
170
|
+
const newTest = createTest(name, fn, 'active');
|
|
171
|
+
currentSuite.tests.push(newTest);
|
|
172
|
+
// All subsequent tests in this suite will be skipped
|
|
173
|
+
// This happens automatically because of the _hasFocused flag
|
|
174
|
+
},
|
|
175
|
+
todo: (name) => {
|
|
176
|
+
const currentSuite = getCurrentSuite();
|
|
177
|
+
if (!currentSuite) {
|
|
178
|
+
throw new Error('test.todo() must be called within a describe() block');
|
|
179
|
+
}
|
|
180
|
+
currentSuite.tests.push(createTest(name, () => { }, 'todo'));
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
export const it = test;
|
|
184
|
+
export function beforeAll(fn) {
|
|
185
|
+
const currentSuite = getCurrentSuite();
|
|
186
|
+
if (!currentSuite) {
|
|
187
|
+
throw new Error('beforeAll() must be called within a describe() block');
|
|
188
|
+
}
|
|
189
|
+
currentSuite.beforeAll.push(fn);
|
|
190
|
+
}
|
|
191
|
+
export function afterAll(fn) {
|
|
192
|
+
const currentSuite = getCurrentSuite();
|
|
193
|
+
if (!currentSuite) {
|
|
194
|
+
throw new Error('afterAll() must be called within a describe() block');
|
|
195
|
+
}
|
|
196
|
+
currentSuite.afterAll.push(fn);
|
|
197
|
+
}
|
|
198
|
+
export function beforeEach(fn) {
|
|
199
|
+
const currentSuite = getCurrentSuite();
|
|
200
|
+
if (!currentSuite) {
|
|
201
|
+
throw new Error('beforeEach() must be called within a describe() block');
|
|
202
|
+
}
|
|
203
|
+
currentSuite.beforeEach.push(fn);
|
|
204
|
+
}
|
|
205
|
+
export function afterEach(fn) {
|
|
206
|
+
const currentSuite = getCurrentSuite();
|
|
207
|
+
if (!currentSuite) {
|
|
208
|
+
throw new Error('afterEach() must be called within a describe() block');
|
|
209
|
+
}
|
|
210
|
+
currentSuite.afterEach.push(fn);
|
|
211
|
+
}
|
|
212
|
+
export const collectTests = (fn) => {
|
|
213
|
+
clearState();
|
|
214
|
+
fn();
|
|
215
|
+
return getRootSuite();
|
|
216
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/rntl/expect.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAsC9B,OAAO,CAAC,MAAM,CAAC;IAGb,UAAU,IAAI,CAAC;QACb,UAAU,SAAS;YACjB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;YAC9B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;SAC9B;KACF;CACF"}
|