@react-native-harness/runtime 1.0.0-alpha.15 → 1.0.0-alpha.18
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/assets/moduleSystem.flow.js +15 -98
- package/dist/bundler/bundle.d.ts.map +1 -1
- package/dist/bundler/bundle.js +1 -2
- package/dist/bundler/evaluate.d.ts.map +1 -1
- package/dist/bundler/evaluate.js +7 -7
- package/dist/client/factory.d.ts.map +1 -1
- package/dist/client/factory.js +26 -6
- 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/collector/functions.d.ts +1 -1
- package/dist/collector/functions.d.ts.map +1 -1
- package/dist/collector/functions.js +2 -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/entry-point.d.ts +2 -0
- package/dist/entry-point.d.ts.map +1 -0
- package/dist/entry-point.js +4 -0
- package/dist/filtering/index.d.ts +1 -1
- package/dist/filtering/index.d.ts.map +1 -1
- package/dist/filtering/index.js +1 -1
- package/dist/filtering/testNameFilter.d.ts +6 -0
- package/dist/filtering/testNameFilter.d.ts.map +1 -1
- package/dist/filtering/testNameFilter.js +36 -5
- package/dist/globals.d.ts +5 -2
- package/dist/globals.d.ts.map +1 -1
- package/dist/globals.js +7 -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 +7 -0
- 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/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/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/factory.d.ts.map +1 -1
- package/dist/runner/factory.js +6 -1
- 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/out-tsc/vitest/src/bundler/bundle.d.ts.map +1 -1
- package/out-tsc/vitest/src/bundler/evaluate.d.ts.map +1 -1
- package/out-tsc/vitest/src/client/factory.d.ts.map +1 -1
- 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/collector/functions.d.ts +1 -1
- package/out-tsc/vitest/src/collector/functions.d.ts.map +1 -1
- package/out-tsc/vitest/src/collector/types.d.ts +1 -1
- package/out-tsc/vitest/src/collector/types.d.ts.map +1 -1
- package/out-tsc/vitest/src/constants.d.ts +0 -1
- package/out-tsc/vitest/src/constants.d.ts.map +1 -1
- 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/filtering/index.d.ts +1 -1
- package/out-tsc/vitest/src/filtering/index.d.ts.map +1 -1
- package/out-tsc/vitest/src/filtering/testNameFilter.d.ts +6 -0
- package/out-tsc/vitest/src/filtering/testNameFilter.d.ts.map +1 -1
- package/out-tsc/vitest/src/globals.d.ts +5 -2
- package/out-tsc/vitest/src/globals.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/jest-mock.d.ts +2 -0
- package/out-tsc/vitest/src/jest-mock.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/factory.d.ts.map +1 -1
- package/out-tsc/vitest/src/ui/ReadyScreen.d.ts.map +1 -1
- package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts.map +1 -1
- package/out-tsc/vitest/src/ui/state.d.ts +14 -1
- package/out-tsc/vitest/src/ui/state.d.ts.map +1 -1
- package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +1 -1
- package/package.json +10 -4
- package/src/__tests__/collector.test.ts +55 -55
- package/src/__tests__/error-handling.test.ts +34 -34
- package/src/bundler/bundle.ts +1 -2
- package/src/bundler/evaluate.ts +9 -9
- package/src/client/factory.ts +31 -9
- package/src/client/setup-files.ts +81 -0
- package/src/collector/functions.ts +4 -2
- package/src/collector/types.ts +4 -1
- package/src/constants.ts +0 -1
- package/src/entry-point.ts +8 -0
- package/src/filtering/index.ts +4 -1
- package/src/filtering/testNameFilter.ts +53 -8
- package/src/globals.ts +14 -2
- package/src/index.ts +1 -0
- package/src/initialize.ts +11 -1
- package/src/jest-mock.ts +32 -0
- package/src/mocker/metro-require.d.ts +1 -0
- package/src/react-native.d.ts +0 -8
- 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/factory.ts +8 -1
- package/src/ui/ReadyScreen.tsx +2 -12
- package/src/ui/WrongEnvironmentScreen.tsx +1 -19
- package/src/ui/state.ts +39 -0
- package/assets/logo.png +0 -0
- package/out-tsc/tsconfig.spec.tsbuildinfo +0 -1
- package/types/global.d.ts +0 -2
- package/types/index.d.ts +0 -1
|
@@ -6,8 +6,8 @@ const noop = () => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
describe('test collector - test case recognition', () => {
|
|
9
|
-
it('should collect basic test cases using it()', () => {
|
|
10
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
9
|
+
it('should collect basic test cases using it()', async () => {
|
|
10
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
11
11
|
collectorFunctions.describe('Sample Suite', () => {
|
|
12
12
|
collectorFunctions.it('test 1', noop);
|
|
13
13
|
collectorFunctions.it('test 2', noop);
|
|
@@ -24,8 +24,8 @@ describe('test collector - test case recognition', () => {
|
|
|
24
24
|
expect(sampleSuite.tests[1].status).toBe('active');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
it('should collect basic test cases using test()', () => {
|
|
28
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
27
|
+
it('should collect basic test cases using test()', async () => {
|
|
28
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
29
29
|
collectorFunctions.describe('Sample Suite', () => {
|
|
30
30
|
collectorFunctions.test('test 1', noop);
|
|
31
31
|
collectorFunctions.test('test 2', noop);
|
|
@@ -39,8 +39,8 @@ describe('test collector - test case recognition', () => {
|
|
|
39
39
|
expect(sampleSuite.tests[1].name).toBe('test 2');
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
it('should collect async test functions', () => {
|
|
43
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
42
|
+
it('should collect async test functions', async () => {
|
|
43
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
44
44
|
collectorFunctions.describe('Async Suite', () => {
|
|
45
45
|
collectorFunctions.it('async test', async () => {
|
|
46
46
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
@@ -53,8 +53,8 @@ describe('test collector - test case recognition', () => {
|
|
|
53
53
|
expect(typeof asyncSuite.tests[0].fn).toBe('function');
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it('should collect tests at root level', () => {
|
|
57
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
56
|
+
it('should collect tests at root level', async () => {
|
|
57
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
58
58
|
collectorFunctions.it('root test 1', noop);
|
|
59
59
|
collectorFunctions.test('root test 2', noop);
|
|
60
60
|
|
|
@@ -76,8 +76,8 @@ describe('test collector - test case recognition', () => {
|
|
|
76
76
|
expect(collectedSuite.testSuite.suites[0].tests[0].name).toBe('suite test');
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
it('should collect tests with modifiers at root level', () => {
|
|
80
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
79
|
+
it('should collect tests with modifiers at root level', async () => {
|
|
80
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
81
81
|
collectorFunctions.it('regular root test', noop);
|
|
82
82
|
collectorFunctions.test.skip('skipped root test', noop);
|
|
83
83
|
collectorFunctions.it.todo('todo root test');
|
|
@@ -101,8 +101,8 @@ describe('test collector - test case recognition', () => {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
describe('test collector - suite recognition', () => {
|
|
104
|
-
it('should collect nested describe blocks', () => {
|
|
105
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
104
|
+
it('should collect nested describe blocks', async () => {
|
|
105
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
106
106
|
collectorFunctions.describe('Outer Suite', () => {
|
|
107
107
|
collectorFunctions.describe('Inner Suite 1', () => {
|
|
108
108
|
collectorFunctions.it('test 1', noop);
|
|
@@ -123,8 +123,8 @@ describe('test collector - suite recognition', () => {
|
|
|
123
123
|
expect(outerSuite.suites[1].tests[0].name).toBe('test 2');
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it('should collect multiple top-level describe blocks', () => {
|
|
127
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
126
|
+
it('should collect multiple top-level describe blocks', async () => {
|
|
127
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
128
128
|
collectorFunctions.describe('Suite 1', () => {
|
|
129
129
|
collectorFunctions.it('test 1', noop);
|
|
130
130
|
});
|
|
@@ -138,8 +138,8 @@ describe('test collector - suite recognition', () => {
|
|
|
138
138
|
expect(collectedSuite.testSuite.suites[1].name).toBe('Suite 2');
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
it('should collect deeply nested suites', () => {
|
|
142
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
141
|
+
it('should collect deeply nested suites', async () => {
|
|
142
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
143
143
|
collectorFunctions.describe('Level 1', () => {
|
|
144
144
|
collectorFunctions.describe('Level 2', () => {
|
|
145
145
|
collectorFunctions.describe('Level 3', () => {
|
|
@@ -161,8 +161,8 @@ describe('test collector - suite recognition', () => {
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
describe('test collector - skip modifier recognition', () => {
|
|
164
|
-
it('should collect and mark skipped tests with test.skip()', () => {
|
|
165
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
164
|
+
it('should collect and mark skipped tests with test.skip()', async () => {
|
|
165
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
166
166
|
collectorFunctions.describe('Skip Suite', () => {
|
|
167
167
|
collectorFunctions.it('active test', noop);
|
|
168
168
|
collectorFunctions.test.skip('skipped test', noop);
|
|
@@ -177,8 +177,8 @@ describe('test collector - skip modifier recognition', () => {
|
|
|
177
177
|
expect(skipSuite.tests[2].status).toBe('skipped');
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
it('should collect and mark skipped suites with describe.skip()', () => {
|
|
181
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
180
|
+
it('should collect and mark skipped suites with describe.skip()', async () => {
|
|
181
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
182
182
|
collectorFunctions.describe('Active Suite', () => {
|
|
183
183
|
collectorFunctions.it('active test', noop);
|
|
184
184
|
});
|
|
@@ -192,8 +192,8 @@ describe('test collector - skip modifier recognition', () => {
|
|
|
192
192
|
expect(collectedSuite.testSuite.suites[1].status).toBe('skipped');
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
it('should collect nested skipped suites', () => {
|
|
196
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
195
|
+
it('should collect nested skipped suites', async () => {
|
|
196
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
197
197
|
collectorFunctions.describe.skip('Outer Skipped', () => {
|
|
198
198
|
collectorFunctions.describe('Inner Suite', () => {
|
|
199
199
|
collectorFunctions.it('test', noop);
|
|
@@ -208,8 +208,8 @@ describe('test collector - skip modifier recognition', () => {
|
|
|
208
208
|
});
|
|
209
209
|
|
|
210
210
|
describe('test collector - only modifier recognition', () => {
|
|
211
|
-
it('should collect and mark only tests and skip others with test.only()', () => {
|
|
212
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
211
|
+
it('should collect and mark only tests and skip others with test.only()', async () => {
|
|
212
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
213
213
|
collectorFunctions.describe('Only Suite', () => {
|
|
214
214
|
collectorFunctions.it('regular test 1', noop);
|
|
215
215
|
collectorFunctions.test.only('focused test', noop);
|
|
@@ -225,8 +225,8 @@ describe('test collector - only modifier recognition', () => {
|
|
|
225
225
|
expect(onlySuite._hasFocused).toBe(true);
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
-
it('should collect multiple test.only() calls', () => {
|
|
229
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
228
|
+
it('should collect multiple test.only() calls', async () => {
|
|
229
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
230
230
|
collectorFunctions.describe('Multiple Only Suite', () => {
|
|
231
231
|
collectorFunctions.it('regular test', noop);
|
|
232
232
|
collectorFunctions.test.only('focused test 1', noop);
|
|
@@ -240,8 +240,8 @@ describe('test collector - only modifier recognition', () => {
|
|
|
240
240
|
expect(multipleSuite.tests[2].status).toBe('active'); // Second only also active
|
|
241
241
|
});
|
|
242
242
|
|
|
243
|
-
it('should collect and mark only suites and skip others with describe.only()', () => {
|
|
244
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
243
|
+
it('should collect and mark only suites and skip others with describe.only()', async () => {
|
|
244
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
245
245
|
collectorFunctions.describe('Regular Suite 1', () => {
|
|
246
246
|
collectorFunctions.it('test 1', noop);
|
|
247
247
|
});
|
|
@@ -260,8 +260,8 @@ describe('test collector - only modifier recognition', () => {
|
|
|
260
260
|
expect(collectedSuite.testSuite.suites[1]._hasFocused).toBe(true);
|
|
261
261
|
});
|
|
262
262
|
|
|
263
|
-
it('should collect nested describe.only()', () => {
|
|
264
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
263
|
+
it('should collect nested describe.only()', async () => {
|
|
264
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
265
265
|
collectorFunctions.describe('Outer Suite', () => {
|
|
266
266
|
collectorFunctions.describe('Regular Inner', () => {
|
|
267
267
|
collectorFunctions.it('test 1', noop);
|
|
@@ -281,8 +281,8 @@ describe('test collector - only modifier recognition', () => {
|
|
|
281
281
|
});
|
|
282
282
|
|
|
283
283
|
describe('test collector - todo test recognition', () => {
|
|
284
|
-
it('should collect and mark todo tests with test.todo()', () => {
|
|
285
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
284
|
+
it('should collect and mark todo tests with test.todo()', async () => {
|
|
285
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
286
286
|
collectorFunctions.describe('Todo Suite', () => {
|
|
287
287
|
collectorFunctions.it('regular test', noop);
|
|
288
288
|
collectorFunctions.test.todo('todo test');
|
|
@@ -297,8 +297,8 @@ describe('test collector - todo test recognition', () => {
|
|
|
297
297
|
expect(todoSuite.tests[2].status).toBe('todo');
|
|
298
298
|
});
|
|
299
299
|
|
|
300
|
-
it('should collect todo tests without function bodies', () => {
|
|
301
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
300
|
+
it('should collect todo tests without function bodies', async () => {
|
|
301
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
302
302
|
collectorFunctions.describe('Todo Suite', () => {
|
|
303
303
|
collectorFunctions.test.todo('implement this feature');
|
|
304
304
|
});
|
|
@@ -312,8 +312,8 @@ describe('test collector - todo test recognition', () => {
|
|
|
312
312
|
});
|
|
313
313
|
|
|
314
314
|
describe('test collector - hook recognition', () => {
|
|
315
|
-
it('should collect beforeAll hooks', () => {
|
|
316
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
315
|
+
it('should collect beforeAll hooks', async () => {
|
|
316
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
317
317
|
collectorFunctions.describe('Hook Suite', () => {
|
|
318
318
|
collectorFunctions.beforeAll(() => {
|
|
319
319
|
// setup
|
|
@@ -331,8 +331,8 @@ describe('test collector - hook recognition', () => {
|
|
|
331
331
|
expect(typeof hookSuite.beforeAll[1]).toBe('function');
|
|
332
332
|
});
|
|
333
333
|
|
|
334
|
-
it('should collect afterAll hooks', () => {
|
|
335
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
334
|
+
it('should collect afterAll hooks', async () => {
|
|
335
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
336
336
|
collectorFunctions.describe('Hook Suite', () => {
|
|
337
337
|
collectorFunctions.afterAll(() => {
|
|
338
338
|
// cleanup
|
|
@@ -346,8 +346,8 @@ describe('test collector - hook recognition', () => {
|
|
|
346
346
|
expect(typeof hookSuite.afterAll[0]).toBe('function');
|
|
347
347
|
});
|
|
348
348
|
|
|
349
|
-
it('should collect beforeEach hooks', () => {
|
|
350
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
349
|
+
it('should collect beforeEach hooks', async () => {
|
|
350
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
351
351
|
collectorFunctions.describe('Hook Suite', () => {
|
|
352
352
|
collectorFunctions.beforeEach(() => {
|
|
353
353
|
// setup each
|
|
@@ -365,8 +365,8 @@ describe('test collector - hook recognition', () => {
|
|
|
365
365
|
expect(typeof hookSuite.beforeEach[1]).toBe('function');
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
-
it('should collect afterEach hooks', () => {
|
|
369
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
368
|
+
it('should collect afterEach hooks', async () => {
|
|
369
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
370
370
|
collectorFunctions.describe('Hook Suite', () => {
|
|
371
371
|
collectorFunctions.afterEach(() => {
|
|
372
372
|
// cleanup each
|
|
@@ -380,8 +380,8 @@ describe('test collector - hook recognition', () => {
|
|
|
380
380
|
expect(typeof hookSuite.afterEach[0]).toBe('function');
|
|
381
381
|
});
|
|
382
382
|
|
|
383
|
-
it('should collect all types of hooks together', () => {
|
|
384
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
383
|
+
it('should collect all types of hooks together', async () => {
|
|
384
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
385
385
|
collectorFunctions.describe('All Hooks Suite', () => {
|
|
386
386
|
collectorFunctions.beforeAll(noop);
|
|
387
387
|
collectorFunctions.afterAll(noop);
|
|
@@ -398,8 +398,8 @@ describe('test collector - hook recognition', () => {
|
|
|
398
398
|
expect(allHooksSuite.afterEach).toHaveLength(1);
|
|
399
399
|
});
|
|
400
400
|
|
|
401
|
-
it('should collect hooks at root level', () => {
|
|
402
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
401
|
+
it('should collect hooks at root level', async () => {
|
|
402
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
403
403
|
collectorFunctions.beforeAll(() => {
|
|
404
404
|
// root level setup
|
|
405
405
|
});
|
|
@@ -429,8 +429,8 @@ describe('test collector - hook recognition', () => {
|
|
|
429
429
|
expect(typeof collectedSuite.testSuite.afterEach[0]).toBe('function');
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
-
it('should collect hooks at both root and suite levels', () => {
|
|
433
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
432
|
+
it('should collect hooks at both root and suite levels', async () => {
|
|
433
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
434
434
|
// Root level hooks
|
|
435
435
|
collectorFunctions.beforeAll(() => {
|
|
436
436
|
// global setup
|
|
@@ -463,8 +463,8 @@ describe('test collector - hook recognition', () => {
|
|
|
463
463
|
});
|
|
464
464
|
|
|
465
465
|
describe('test collector - complex scenarios', () => {
|
|
466
|
-
it('should collect mix of tests, suites, hooks, and modifiers', () => {
|
|
467
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
466
|
+
it('should collect mix of tests, suites, hooks, and modifiers', async () => {
|
|
467
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
468
468
|
collectorFunctions.describe('Complex Suite', () => {
|
|
469
469
|
collectorFunctions.beforeAll(noop);
|
|
470
470
|
collectorFunctions.beforeEach(noop);
|
|
@@ -515,14 +515,14 @@ describe('test collector - complex scenarios', () => {
|
|
|
515
515
|
expect(innerSuite.tests[2].status).toBe('skipped'); // Due to .only
|
|
516
516
|
});
|
|
517
517
|
|
|
518
|
-
it('should clear collector state between collectTests calls', () => {
|
|
519
|
-
const collectedSuite1 = collectorFunctions.collectTests(() => {
|
|
518
|
+
it('should clear collector state between collectTests calls', async () => {
|
|
519
|
+
const collectedSuite1 = await collectorFunctions.collectTests(() => {
|
|
520
520
|
collectorFunctions.describe('Suite 1', () => {
|
|
521
521
|
collectorFunctions.it('test 1', noop);
|
|
522
522
|
});
|
|
523
523
|
});
|
|
524
524
|
|
|
525
|
-
const collectedSuite2 = collectorFunctions.collectTests(() => {
|
|
525
|
+
const collectedSuite2 = await collectorFunctions.collectTests(() => {
|
|
526
526
|
collectorFunctions.describe('Suite 2', () => {
|
|
527
527
|
collectorFunctions.it('test 2', noop);
|
|
528
528
|
});
|
|
@@ -534,8 +534,8 @@ describe('test collector - complex scenarios', () => {
|
|
|
534
534
|
expect(collectedSuite2.testSuite.suites[0].name).toBe('Suite 2');
|
|
535
535
|
});
|
|
536
536
|
|
|
537
|
-
it('should collect empty describe blocks', () => {
|
|
538
|
-
const collectedSuite = collectorFunctions.collectTests(() => {
|
|
537
|
+
it('should collect empty describe blocks', async () => {
|
|
538
|
+
const collectedSuite = await collectorFunctions.collectTests(() => {
|
|
539
539
|
collectorFunctions.describe('Empty Suite', () => {
|
|
540
540
|
// No tests or hooks
|
|
541
541
|
});
|
|
@@ -7,44 +7,44 @@ const noop = () => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
describe('error handling', () => {
|
|
10
|
-
it('should throw TestError with proper code for invalid test names', () => {
|
|
11
|
-
expect(() =>
|
|
10
|
+
it('should throw TestError with proper code for invalid test names', async () => {
|
|
11
|
+
await expect(() =>
|
|
12
12
|
harnessRuntime.collectTests(() => {
|
|
13
13
|
harnessRuntime.describe('Test Suite', () => {
|
|
14
14
|
harnessRuntime.test('', noop);
|
|
15
15
|
});
|
|
16
|
-
})
|
|
17
|
-
|
|
16
|
+
})
|
|
17
|
+
).rejects.toThrow(TestError);
|
|
18
18
|
|
|
19
|
-
expect(() =>
|
|
19
|
+
await expect(() =>
|
|
20
20
|
harnessRuntime.collectTests(() => {
|
|
21
21
|
harnessRuntime.describe('Test Suite', () => {
|
|
22
22
|
harnessRuntime.test(null as unknown as string, noop);
|
|
23
23
|
});
|
|
24
|
-
})
|
|
25
|
-
|
|
24
|
+
})
|
|
25
|
+
).rejects.toThrow(TestError);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it('should throw TestError with proper code for invalid functions', () => {
|
|
29
|
-
expect(() =>
|
|
28
|
+
it('should throw TestError with proper code for invalid functions', async () => {
|
|
29
|
+
await expect(() =>
|
|
30
30
|
harnessRuntime.collectTests(() => {
|
|
31
31
|
harnessRuntime.describe('Test Suite', () => {
|
|
32
32
|
// @ts-expect-error - Testing invalid input
|
|
33
33
|
harnessRuntime.test('test name', null);
|
|
34
34
|
});
|
|
35
|
-
})
|
|
36
|
-
|
|
35
|
+
})
|
|
36
|
+
).rejects.toThrow(TestError);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
it('should throw TestError for duplicate test names', () => {
|
|
40
|
-
expect(() =>
|
|
39
|
+
it('should throw TestError for duplicate test names', async () => {
|
|
40
|
+
await expect(() =>
|
|
41
41
|
harnessRuntime.collectTests(() => {
|
|
42
42
|
harnessRuntime.describe('Test Suite', () => {
|
|
43
43
|
harnessRuntime.test('duplicate name', noop);
|
|
44
44
|
harnessRuntime.test('duplicate name', noop);
|
|
45
45
|
});
|
|
46
|
-
})
|
|
47
|
-
|
|
46
|
+
})
|
|
47
|
+
).rejects.toThrow(TestError);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it('should throw TestError when calling test outside describe', () => {
|
|
@@ -71,9 +71,9 @@ describe('error handling', () => {
|
|
|
71
71
|
}).toThrow(TestError);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
it('should provide proper error context', () => {
|
|
74
|
+
it('should provide proper error context', async () => {
|
|
75
75
|
try {
|
|
76
|
-
harnessRuntime.collectTests(() => {
|
|
76
|
+
await harnessRuntime.collectTests(() => {
|
|
77
77
|
harnessRuntime.describe('Test Suite', () => {
|
|
78
78
|
harnessRuntime.test('test1', noop);
|
|
79
79
|
harnessRuntime.test('test1', noop);
|
|
@@ -89,44 +89,44 @@ describe('error handling', () => {
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
it('should validate describe function inputs', () => {
|
|
93
|
-
expect(() =>
|
|
92
|
+
it('should validate describe function inputs', async () => {
|
|
93
|
+
await expect(() =>
|
|
94
94
|
harnessRuntime.collectTests(() => {
|
|
95
95
|
harnessRuntime.describe('', noop);
|
|
96
|
-
})
|
|
97
|
-
|
|
96
|
+
})
|
|
97
|
+
).rejects.toThrow(TestError);
|
|
98
98
|
|
|
99
|
-
expect(() =>
|
|
99
|
+
await expect(() =>
|
|
100
100
|
harnessRuntime.collectTests(() => {
|
|
101
101
|
// @ts-expect-error - Testing invalid input
|
|
102
102
|
harnessRuntime.describe('Test Suite', null);
|
|
103
|
-
})
|
|
104
|
-
|
|
103
|
+
})
|
|
104
|
+
).rejects.toThrow(TestError);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
it('should validate test modifiers', () => {
|
|
108
|
-
expect(() =>
|
|
107
|
+
it('should validate test modifiers', async () => {
|
|
108
|
+
await expect(() =>
|
|
109
109
|
harnessRuntime.collectTests(() => {
|
|
110
110
|
harnessRuntime.describe('Test Suite', () => {
|
|
111
111
|
harnessRuntime.test.skip('', noop);
|
|
112
112
|
});
|
|
113
|
-
})
|
|
114
|
-
|
|
113
|
+
})
|
|
114
|
+
).rejects.toThrow(TestError);
|
|
115
115
|
|
|
116
|
-
expect(() =>
|
|
116
|
+
await expect(() =>
|
|
117
117
|
harnessRuntime.collectTests(() => {
|
|
118
118
|
harnessRuntime.describe('Test Suite', () => {
|
|
119
119
|
harnessRuntime.test.only('', noop);
|
|
120
120
|
});
|
|
121
|
-
})
|
|
122
|
-
|
|
121
|
+
})
|
|
122
|
+
).rejects.toThrow(TestError);
|
|
123
123
|
|
|
124
|
-
expect(() =>
|
|
124
|
+
await expect(() =>
|
|
125
125
|
harnessRuntime.collectTests(() => {
|
|
126
126
|
harnessRuntime.describe('Test Suite', () => {
|
|
127
127
|
harnessRuntime.test.todo('');
|
|
128
128
|
});
|
|
129
|
-
})
|
|
130
|
-
|
|
129
|
+
})
|
|
130
|
+
).rejects.toThrow(TestError);
|
|
131
131
|
});
|
|
132
132
|
});
|
package/src/bundler/bundle.ts
CHANGED
|
@@ -8,10 +8,9 @@ const getModuleUrl = (fileName: string): string => {
|
|
|
8
8
|
const urlSearchParams = new URLSearchParams({
|
|
9
9
|
modulesOnly: 'true',
|
|
10
10
|
platform: Platform.OS,
|
|
11
|
-
'resolver.isHarness': 'true',
|
|
12
11
|
});
|
|
13
12
|
|
|
14
|
-
return `${devServerUrl}
|
|
13
|
+
return `${devServerUrl}${bundleName}?${urlSearchParams.toString()}`;
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export const fetchModule = async (fileName: string): Promise<string> => {
|
package/src/bundler/evaluate.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { MalformedModuleError } from './errors.js';
|
|
2
|
-
import { EnvironmentError } from '../errors.js';
|
|
3
2
|
|
|
4
3
|
export const evaluateModule = (moduleJs: string, modulePath: string): void => {
|
|
5
|
-
const
|
|
4
|
+
const __rMatches = Array.from(moduleJs.matchAll(/__r\((\d+)\)/g));
|
|
6
5
|
|
|
7
|
-
if (
|
|
6
|
+
if (__rMatches.length === 0) {
|
|
8
7
|
throw new MalformedModuleError(modulePath, 'No __r function found');
|
|
9
8
|
}
|
|
10
9
|
|
|
10
|
+
// Get the last match as there may be many require calls
|
|
11
|
+
const __rMatch = __rMatches[__rMatches.length - 1];
|
|
11
12
|
const __rParam = __rMatch[1];
|
|
12
13
|
|
|
13
14
|
if (!__rParam) {
|
|
14
15
|
throw new MalformedModuleError(modulePath, 'No __r parameter found');
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
eval(moduleJs);
|
|
18
|
+
const moduleId = Number(__rParam);
|
|
19
19
|
|
|
20
|
-
if
|
|
21
|
-
|
|
22
|
-
}
|
|
20
|
+
// This is important as if module was already initialized, it would not be re-initialized
|
|
21
|
+
global.__clearModule(moduleId);
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
// eslint-disable-next-line no-eval
|
|
24
|
+
eval(moduleJs);
|
|
25
25
|
};
|
package/src/client/factory.ts
CHANGED
|
@@ -11,7 +11,9 @@ import { getTestCollector, TestCollector } from '../collector/index.js';
|
|
|
11
11
|
import { combineEventEmitters, EventEmitter } from '../utils/emitter.js';
|
|
12
12
|
import { getWSServer } from './getWSServer.js';
|
|
13
13
|
import { getBundler, evaluateModule, Bundler } from '../bundler/index.js';
|
|
14
|
-
import {
|
|
14
|
+
import { markTestsAsSkippedByName } from '../filtering/index.js';
|
|
15
|
+
import { setup } from '../render/setup.js';
|
|
16
|
+
import { runSetupFiles } from './setup-files.js';
|
|
15
17
|
|
|
16
18
|
export const getClient = async () => {
|
|
17
19
|
const client = await getBridgeClient(getWSServer(), {
|
|
@@ -51,18 +53,38 @@ export const getClient = async () => {
|
|
|
51
53
|
client.rpc.emitEvent(event.type, event);
|
|
52
54
|
});
|
|
53
55
|
|
|
56
|
+
await runSetupFiles({
|
|
57
|
+
setupFiles: options.setupFiles ?? [],
|
|
58
|
+
setupFilesAfterEnv: [],
|
|
59
|
+
events: events as EventEmitter<BundlerEvents>,
|
|
60
|
+
bundler: bundler as Bundler,
|
|
61
|
+
evaluateModule,
|
|
62
|
+
});
|
|
63
|
+
|
|
54
64
|
const moduleJs = await bundler.getModule(path);
|
|
55
|
-
const collectionResult = await collector.collect(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
const collectionResult = await collector.collect(async () => {
|
|
66
|
+
await runSetupFiles({
|
|
67
|
+
setupFiles: [],
|
|
68
|
+
setupFilesAfterEnv: options.setupFilesAfterEnv ?? [],
|
|
69
|
+
events: events as EventEmitter<BundlerEvents>,
|
|
70
|
+
bundler: bundler as Bundler,
|
|
71
|
+
evaluateModule,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Setup automatic cleanup for rendered components
|
|
75
|
+
setup();
|
|
76
|
+
evaluateModule(moduleJs, path);
|
|
77
|
+
}, path);
|
|
59
78
|
|
|
60
|
-
// Apply test name
|
|
61
|
-
const
|
|
62
|
-
?
|
|
79
|
+
// Apply test name pattern by marking non-matching tests as skipped
|
|
80
|
+
const processedTestSuite = options.testNamePattern
|
|
81
|
+
? markTestsAsSkippedByName(
|
|
82
|
+
collectionResult.testSuite,
|
|
83
|
+
options.testNamePattern
|
|
84
|
+
)
|
|
63
85
|
: collectionResult.testSuite;
|
|
64
86
|
|
|
65
|
-
const result = await runner.run(
|
|
87
|
+
const result = await runner.run(processedTestSuite, path);
|
|
66
88
|
return result;
|
|
67
89
|
} finally {
|
|
68
90
|
collector?.dispose();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EventEmitter } from '../utils/emitter.js';
|
|
2
|
+
import { Bundler } from '../bundler/index.js';
|
|
3
|
+
import { BundlerEvents } from '@react-native-harness/bridge';
|
|
4
|
+
|
|
5
|
+
export type RunSetupFilesOptions = {
|
|
6
|
+
setupFiles: string[];
|
|
7
|
+
setupFilesAfterEnv: string[];
|
|
8
|
+
events: EventEmitter<BundlerEvents>;
|
|
9
|
+
bundler: Bundler;
|
|
10
|
+
evaluateModule: (moduleJs: string, filePath: string) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const runSetupFiles = async ({
|
|
14
|
+
setupFiles,
|
|
15
|
+
setupFilesAfterEnv,
|
|
16
|
+
events,
|
|
17
|
+
bundler,
|
|
18
|
+
evaluateModule,
|
|
19
|
+
}: RunSetupFilesOptions) => {
|
|
20
|
+
for (const setupFile of setupFiles) {
|
|
21
|
+
const startTime = Date.now();
|
|
22
|
+
events.emit({
|
|
23
|
+
type: 'setup-file-bundling-started',
|
|
24
|
+
file: setupFile,
|
|
25
|
+
setupType: 'setupFiles',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const setupModuleJs = await bundler.getModule(setupFile);
|
|
30
|
+
events.emit({
|
|
31
|
+
type: 'setup-file-bundling-finished',
|
|
32
|
+
file: setupFile,
|
|
33
|
+
setupType: 'setupFiles',
|
|
34
|
+
duration: Date.now() - startTime,
|
|
35
|
+
});
|
|
36
|
+
evaluateModule(setupModuleJs, setupFile);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const errorMessage =
|
|
39
|
+
error instanceof Error ? error.message : 'Unknown error';
|
|
40
|
+
events.emit({
|
|
41
|
+
type: 'setup-file-bundling-failed',
|
|
42
|
+
file: setupFile,
|
|
43
|
+
setupType: 'setupFiles',
|
|
44
|
+
duration: Date.now() - startTime,
|
|
45
|
+
error: errorMessage,
|
|
46
|
+
});
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const setupFile of setupFilesAfterEnv) {
|
|
52
|
+
const startTime = Date.now();
|
|
53
|
+
events.emit({
|
|
54
|
+
type: 'setup-file-bundling-started',
|
|
55
|
+
file: setupFile,
|
|
56
|
+
setupType: 'setupFilesAfterEnv',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const setupModuleJs = await bundler.getModule(setupFile);
|
|
61
|
+
events.emit({
|
|
62
|
+
type: 'setup-file-bundling-finished',
|
|
63
|
+
file: setupFile,
|
|
64
|
+
setupType: 'setupFilesAfterEnv',
|
|
65
|
+
duration: Date.now() - startTime,
|
|
66
|
+
});
|
|
67
|
+
evaluateModule(setupModuleJs, setupFile);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
const errorMessage =
|
|
70
|
+
error instanceof Error ? error.message : 'Unknown error';
|
|
71
|
+
events.emit({
|
|
72
|
+
type: 'setup-file-bundling-failed',
|
|
73
|
+
file: setupFile,
|
|
74
|
+
setupType: 'setupFilesAfterEnv',
|
|
75
|
+
duration: Date.now() - startTime,
|
|
76
|
+
error: errorMessage,
|
|
77
|
+
});
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
@@ -370,11 +370,13 @@ const countTests = (suite: TestSuite): number => {
|
|
|
370
370
|
return count;
|
|
371
371
|
};
|
|
372
372
|
|
|
373
|
-
export const collectTests =
|
|
373
|
+
export const collectTests = async (
|
|
374
|
+
fn: () => void | Promise<void>
|
|
375
|
+
): Promise<CollectionResult> => {
|
|
374
376
|
currentContext = clearState();
|
|
375
377
|
|
|
376
378
|
try {
|
|
377
|
-
fn();
|
|
379
|
+
await fn();
|
|
378
380
|
|
|
379
381
|
// Convert raw structure to final structure using computation phase
|
|
380
382
|
const testSuite = convertRawTestSuiteToTestSuite(getRootSuite());
|
package/src/collector/types.ts
CHANGED
|
@@ -10,6 +10,9 @@ export type TestCollectorEventsEmitter = EventEmitter<TestCollectorEvents>;
|
|
|
10
10
|
|
|
11
11
|
export type TestCollector = {
|
|
12
12
|
events: TestCollectorEventsEmitter;
|
|
13
|
-
collect: (
|
|
13
|
+
collect: (
|
|
14
|
+
fn: () => void | Promise<void>,
|
|
15
|
+
testFilePath: string
|
|
16
|
+
) => Promise<CollectionResult>;
|
|
14
17
|
dispose: () => void;
|
|
15
18
|
};
|
package/src/constants.ts
CHANGED
package/src/filtering/index.ts
CHANGED