@react-native-harness/runtime 1.3.0 → 1.4.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/collector/functions.d.ts.map +1 -1
- package/dist/collector/functions.js +8 -0
- package/dist/runner/runSuite.d.ts.map +1 -1
- package/dist/runner/runSuite.js +84 -35
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/out-tsc/vitest/src/collector/functions.d.ts.map +1 -1
- package/out-tsc/vitest/src/runner/runSuite.d.ts.map +1 -1
- package/out-tsc/vitest/src/ui/state.d.ts +1 -1
- package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/__tests__/runner-context.test.ts +49 -0
- package/src/collector/functions.ts +9 -0
- package/src/runner/runSuite.ts +109 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/collector/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/collector/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAqMzC,eAAO,MAAM,QAAQ,UACZ,MAAM,MAAM,MAAM,IAAI;iBAsBd,MAAM,MAAM,MAAM,IAAI;iBAqBtB,MAAM,MAAM,MAAM,IAAI;CAsBtC,CAAC;AAEF,eAAO,MAAM,IAAI,UACR,MAAM,MAAM,MAAM;iBAaV,MAAM,MAAM,MAAM;iBAWlB,MAAM,MAAM,MAAM;iBAWlB,MAAM;CAiBtB,CAAC;AAEF,eAAO,MAAM,EAAE,UAtDN,MAAM,MAAM,MAAM;iBAaV,MAAM,MAAM,MAAM;iBAWlB,MAAM,MAAM,MAAM;iBAWlB,MAAM;CAmBD,CAAC;AAEvB,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,QAQxC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,QAQvC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,QAQpC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAQnC;AAgBD,eAAO,MAAM,YAAY,GACvB,IAAI,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAC7B,OAAO,CAAC,gBAAgB,CAiB1B,CAAC"}
|
|
@@ -30,10 +30,18 @@ const computeSuiteStatus = (suite, parentContext) => {
|
|
|
30
30
|
return 'active';
|
|
31
31
|
};
|
|
32
32
|
const convertRawTestCaseToTestCase = (rawTest, suiteContext) => {
|
|
33
|
+
const declarationMode = rawTest.options.todo
|
|
34
|
+
? 'todo'
|
|
35
|
+
: rawTest.options.skip
|
|
36
|
+
? 'skip'
|
|
37
|
+
: rawTest.options.only
|
|
38
|
+
? 'only'
|
|
39
|
+
: undefined;
|
|
33
40
|
return {
|
|
34
41
|
name: rawTest.name,
|
|
35
42
|
fn: rawTest.fn,
|
|
36
43
|
status: computeTestStatus(rawTest, suiteContext),
|
|
44
|
+
declarationMode,
|
|
37
45
|
};
|
|
38
46
|
};
|
|
39
47
|
const convertRawTestSuiteToTestSuite = (rawSuite, parentContext = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runSuite.d.ts","sourceRoot":"","sources":["../../src/runner/runSuite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,SAAS,EACT,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"runSuite.d.ts","sourceRoot":"","sources":["../../src/runner/runSuite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,SAAS,EACT,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0DlE,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,iBAAiB,EAAE,MAAM,CAAC;CAC/B;AAyMD,eAAO,MAAM,QAAQ,GACnB,OAAO,SAAS,EAChB,SAAS,iBAAiB,KACzB,OAAO,CAAC,eAAe,CA6IzB,CAAC"}
|
package/dist/runner/runSuite.js
CHANGED
|
@@ -3,8 +3,39 @@ import { flushExpectTestState } from '../expect/errors.js';
|
|
|
3
3
|
import { runHooks } from './hooks.js';
|
|
4
4
|
import { getTestExecutionError } from './errors.js';
|
|
5
5
|
import { createTestContext, createTestLifecycleState, isSkipTestError, runOnTestFailed, runOnTestFinished, } from './test-context.js';
|
|
6
|
+
const getAncestorTitles = (suite) => {
|
|
7
|
+
const ancestorTitles = [];
|
|
8
|
+
let currentSuite = suite.parent;
|
|
9
|
+
while (currentSuite) {
|
|
10
|
+
if (currentSuite.name !== 'root') {
|
|
11
|
+
ancestorTitles.unshift(currentSuite.name);
|
|
12
|
+
}
|
|
13
|
+
currentSuite = currentSuite.parent;
|
|
14
|
+
}
|
|
15
|
+
if (suite.name !== 'root') {
|
|
16
|
+
ancestorTitles.push(suite.name);
|
|
17
|
+
}
|
|
18
|
+
return ancestorTitles;
|
|
19
|
+
};
|
|
20
|
+
const getFullName = (ancestorTitles, testName) => [...ancestorTitles, testName].join(' ');
|
|
21
|
+
const emitTestFinished = (context, options) => {
|
|
22
|
+
const ancestorTitles = getAncestorTitles(options.suite);
|
|
23
|
+
context.events.emit({
|
|
24
|
+
type: 'test-finished',
|
|
25
|
+
file: context.testFilePath,
|
|
26
|
+
suite: options.suite.name,
|
|
27
|
+
name: options.test.name,
|
|
28
|
+
ancestorTitles,
|
|
29
|
+
fullName: getFullName(ancestorTitles, options.test.name),
|
|
30
|
+
startedAt: options.startedAt,
|
|
31
|
+
declarationMode: options.test.declarationMode,
|
|
32
|
+
duration: options.duration,
|
|
33
|
+
error: options.error,
|
|
34
|
+
status: options.status,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
6
37
|
const runTest = async (test, suite, context) => {
|
|
7
|
-
const
|
|
38
|
+
const startedAt = Date.now();
|
|
8
39
|
const task = {
|
|
9
40
|
name: test.name,
|
|
10
41
|
type: 'test',
|
|
@@ -23,11 +54,16 @@ const runTest = async (test, suite, context) => {
|
|
|
23
54
|
const lifecycleState = createTestLifecycleState();
|
|
24
55
|
const activeTestContext = createTestContext(task, lifecycleState);
|
|
25
56
|
// Emit test-started event
|
|
57
|
+
const ancestorTitles = getAncestorTitles(suite);
|
|
26
58
|
context.events.emit({
|
|
27
59
|
type: 'test-started',
|
|
28
60
|
name: test.name,
|
|
29
61
|
suite: suite.name,
|
|
30
62
|
file: context.testFilePath,
|
|
63
|
+
ancestorTitles,
|
|
64
|
+
fullName: getFullName(ancestorTitles, test.name),
|
|
65
|
+
startedAt,
|
|
66
|
+
declarationMode: test.declarationMode,
|
|
31
67
|
});
|
|
32
68
|
try {
|
|
33
69
|
if (test.status === 'skipped') {
|
|
@@ -35,13 +71,15 @@ const runTest = async (test, suite, context) => {
|
|
|
35
71
|
name: test.name,
|
|
36
72
|
status: 'skipped',
|
|
37
73
|
duration: 0,
|
|
74
|
+
ancestorTitles,
|
|
75
|
+
fullName: getFullName(ancestorTitles, test.name),
|
|
76
|
+
startedAt,
|
|
77
|
+
declarationMode: test.declarationMode,
|
|
38
78
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
suite: suite.name,
|
|
44
|
-
file: context.testFilePath,
|
|
79
|
+
emitTestFinished(context, {
|
|
80
|
+
test,
|
|
81
|
+
suite,
|
|
82
|
+
startedAt,
|
|
45
83
|
duration: 0,
|
|
46
84
|
status: 'skipped',
|
|
47
85
|
});
|
|
@@ -53,13 +91,15 @@ const runTest = async (test, suite, context) => {
|
|
|
53
91
|
name: test.name,
|
|
54
92
|
status: 'todo',
|
|
55
93
|
duration: 0,
|
|
94
|
+
ancestorTitles,
|
|
95
|
+
fullName: getFullName(ancestorTitles, test.name),
|
|
96
|
+
startedAt,
|
|
97
|
+
declarationMode: test.declarationMode,
|
|
56
98
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
suite: suite.name,
|
|
62
|
-
file: context.testFilePath,
|
|
99
|
+
emitTestFinished(context, {
|
|
100
|
+
test,
|
|
101
|
+
suite,
|
|
102
|
+
startedAt,
|
|
63
103
|
duration: 0,
|
|
64
104
|
status: 'todo',
|
|
65
105
|
});
|
|
@@ -86,18 +126,21 @@ const runTest = async (test, suite, context) => {
|
|
|
86
126
|
await runHooks(suite, 'afterEach', activeTestContext);
|
|
87
127
|
}
|
|
88
128
|
if (didSkip) {
|
|
89
|
-
const duration = Date.now() -
|
|
129
|
+
const duration = Date.now() - startedAt;
|
|
90
130
|
await runOnTestFinished(lifecycleState);
|
|
91
131
|
const result = {
|
|
92
132
|
name: test.name,
|
|
93
133
|
status: 'skipped',
|
|
94
134
|
duration,
|
|
135
|
+
ancestorTitles,
|
|
136
|
+
fullName: getFullName(ancestorTitles, test.name),
|
|
137
|
+
startedAt,
|
|
138
|
+
declarationMode: test.declarationMode,
|
|
95
139
|
};
|
|
96
|
-
context
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
name: test.name,
|
|
140
|
+
emitTestFinished(context, {
|
|
141
|
+
test,
|
|
142
|
+
suite,
|
|
143
|
+
startedAt,
|
|
101
144
|
duration,
|
|
102
145
|
status: 'skipped',
|
|
103
146
|
});
|
|
@@ -109,18 +152,20 @@ const runTest = async (test, suite, context) => {
|
|
|
109
152
|
finally {
|
|
110
153
|
setCurrentExpectTestState(undefined);
|
|
111
154
|
}
|
|
112
|
-
const duration = Date.now() -
|
|
155
|
+
const duration = Date.now() - startedAt;
|
|
113
156
|
const result = {
|
|
114
157
|
name: test.name,
|
|
115
158
|
status: 'passed',
|
|
116
159
|
duration,
|
|
160
|
+
ancestorTitles,
|
|
161
|
+
fullName: getFullName(ancestorTitles, test.name),
|
|
162
|
+
startedAt,
|
|
163
|
+
declarationMode: test.declarationMode,
|
|
117
164
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
suite: suite.name,
|
|
123
|
-
name: test.name,
|
|
165
|
+
emitTestFinished(context, {
|
|
166
|
+
test,
|
|
167
|
+
suite,
|
|
168
|
+
startedAt,
|
|
124
169
|
duration,
|
|
125
170
|
status: 'passed',
|
|
126
171
|
});
|
|
@@ -130,19 +175,21 @@ const runTest = async (test, suite, context) => {
|
|
|
130
175
|
await runOnTestFailed(lifecycleState);
|
|
131
176
|
await runOnTestFinished(lifecycleState);
|
|
132
177
|
const testError = await getTestExecutionError(error, context.testFilePath, suite.name, test.name);
|
|
133
|
-
const duration = Date.now() -
|
|
178
|
+
const duration = Date.now() - startedAt;
|
|
134
179
|
const result = {
|
|
135
180
|
name: test.name,
|
|
136
181
|
status: 'failed',
|
|
137
182
|
error: testError.toSerializedJSON(),
|
|
138
183
|
duration,
|
|
184
|
+
ancestorTitles,
|
|
185
|
+
fullName: getFullName(ancestorTitles, test.name),
|
|
186
|
+
startedAt,
|
|
187
|
+
declarationMode: test.declarationMode,
|
|
139
188
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
suite: suite.name,
|
|
145
|
-
name: test.name,
|
|
189
|
+
emitTestFinished(context, {
|
|
190
|
+
test,
|
|
191
|
+
suite,
|
|
192
|
+
startedAt,
|
|
146
193
|
duration,
|
|
147
194
|
error: testError.toSerializedJSON(),
|
|
148
195
|
status: 'failed',
|
|
@@ -160,10 +207,12 @@ export const runSuite = async (suite, context) => {
|
|
|
160
207
|
});
|
|
161
208
|
// Check if suite should be skipped or is todo
|
|
162
209
|
if (suite.status === 'skipped') {
|
|
210
|
+
const testResults = await Promise.all(suite.tests.map((test) => runTest({ ...test, status: 'skipped' }, suite, context)));
|
|
211
|
+
const suiteResults = await Promise.all(suite.suites.map((childSuite) => runSuite({ ...childSuite, status: 'skipped' }, context)));
|
|
163
212
|
const result = {
|
|
164
213
|
name: suite.name,
|
|
165
|
-
tests:
|
|
166
|
-
suites:
|
|
214
|
+
tests: testResults,
|
|
215
|
+
suites: suiteResults,
|
|
167
216
|
status: 'skipped',
|
|
168
217
|
duration: 0,
|
|
169
218
|
};
|