@react-native-harness/jest 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/bridge.test.d.ts +2 -0
- package/dist/__tests__/bridge.test.d.ts.map +1 -0
- package/dist/__tests__/bridge.test.js +142 -0
- package/dist/__tests__/client-log-handler.test.js +116 -72
- package/dist/__tests__/crash-monitor.test.d.ts +2 -0
- package/dist/__tests__/crash-monitor.test.d.ts.map +1 -0
- package/dist/__tests__/crash-monitor.test.js +212 -0
- package/dist/__tests__/execute-run.test.d.ts +2 -0
- package/dist/__tests__/execute-run.test.d.ts.map +1 -0
- package/dist/__tests__/execute-run.test.js +229 -0
- package/dist/__tests__/harness.test.js +35 -0
- package/dist/__tests__/hook-queue.test.d.ts +2 -0
- package/dist/__tests__/hook-queue.test.d.ts.map +1 -0
- package/dist/__tests__/hook-queue.test.js +56 -0
- package/dist/__tests__/index.test.js +94 -37
- package/dist/__tests__/resource-lock.test.js +24 -24
- package/dist/cli-args.test.d.ts +2 -0
- package/dist/cli-args.test.d.ts.map +1 -0
- package/dist/cli-args.test.js +1 -0
- package/dist/client-log-handler.d.ts +10 -11
- package/dist/client-log-handler.d.ts.map +1 -1
- package/dist/client-log-handler.js +36 -58
- package/dist/crash-monitor.d.ts +23 -0
- package/dist/crash-monitor.d.ts.map +1 -0
- package/dist/crash-monitor.js +176 -0
- package/dist/event-mapper.d.ts +16 -0
- package/dist/event-mapper.d.ts.map +1 -0
- package/dist/event-mapper.js +120 -0
- package/dist/execute-run.d.ts +4 -0
- package/dist/execute-run.d.ts.map +1 -0
- package/dist/execute-run.js +151 -0
- package/dist/global-setup.d.ts +3 -0
- package/dist/global-setup.d.ts.map +1 -0
- package/dist/global-setup.js +60 -0
- package/dist/global-teardown.d.ts +3 -0
- package/dist/global-teardown.d.ts.map +1 -0
- package/dist/global-teardown.js +11 -0
- package/dist/harness-reporter.d.ts +8 -0
- package/dist/harness-reporter.d.ts.map +1 -0
- package/dist/harness-reporter.js +12 -0
- package/dist/harness-session.d.ts +34 -0
- package/dist/harness-session.d.ts.map +1 -0
- package/dist/harness-session.js +523 -0
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +6 -1
- package/dist/hook-queue.d.ts +6 -0
- package/dist/hook-queue.d.ts.map +1 -0
- package/dist/hook-queue.js +18 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -230
- package/dist/jest-options.d.ts +2 -0
- package/dist/jest-options.d.ts.map +1 -0
- package/dist/jest-options.js +1 -0
- package/dist/logs.d.ts +1 -0
- package/dist/logs.d.ts.map +1 -1
- package/dist/logs.js +3 -0
- package/dist/resource-lock.d.ts +0 -1
- package/dist/resource-lock.d.ts.map +1 -1
- package/dist/resource-lock.js +1 -1
- package/dist/run.d.ts +2 -2
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +3 -3
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +7 -8
- package/src/__tests__/bridge.test.ts +184 -0
- package/src/__tests__/client-log-handler.test.ts +117 -81
- package/src/__tests__/crash-monitor.test.ts +288 -0
- package/src/__tests__/execute-run.test.ts +325 -0
- package/src/__tests__/hook-queue.test.ts +77 -0
- package/src/__tests__/index.test.ts +135 -55
- package/src/__tests__/resource-lock.test.ts +29 -42
- package/src/client-log-handler.ts +48 -64
- package/src/crash-monitor.ts +248 -0
- package/src/execute-run.ts +199 -0
- package/src/harness-session.ts +734 -0
- package/src/hook-queue.ts +26 -0
- package/src/index.ts +17 -330
- package/src/logs.ts +4 -0
- package/src/resource-lock.ts +1 -1
- package/src/run.ts +5 -5
- package/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/crash-supervisor.test.ts +0 -200
- package/src/__tests__/harness-cache.test.ts +0 -74
- package/src/__tests__/harness.test.ts +0 -870
- package/src/crash-supervisor.ts +0 -321
- package/src/env.d.ts +0 -9
- package/src/harness.ts +0 -864
- package/src/setup.ts +0 -127
- package/src/teardown.ts +0 -14
package/dist/index.js
CHANGED
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { setup } from './setup.js';
|
|
4
|
-
import { teardown } from './teardown.js';
|
|
1
|
+
import { createHarnessSession } from './harness-session.js';
|
|
2
|
+
import { executeRun } from './execute-run.js';
|
|
5
3
|
import { HarnessError } from '@react-native-harness/tools';
|
|
6
4
|
import { getErrorMessage } from './logs.js';
|
|
7
|
-
import { DeviceNotRespondingError } from '@react-native-harness/bridge/server';
|
|
8
|
-
import { NativeCrashError, StartupStallError } from './errors.js';
|
|
9
|
-
import { logger } from '@react-native-harness/tools';
|
|
10
|
-
import { randomUUID } from 'node:crypto';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
const runLogger = logger.child('run');
|
|
13
|
-
const createRunSummary = () => ({
|
|
14
|
-
passed: 0,
|
|
15
|
-
failed: 0,
|
|
16
|
-
skipped: 0,
|
|
17
|
-
todo: 0,
|
|
18
|
-
});
|
|
19
|
-
const applyJestResultToSummary = (summary, result) => {
|
|
20
|
-
summary.passed += result.numPassingTests;
|
|
21
|
-
summary.failed += result.numFailingTests;
|
|
22
|
-
summary.skipped += result.numPendingTests;
|
|
23
|
-
summary.todo += result.numTodoTests;
|
|
24
|
-
};
|
|
25
|
-
class CancelRun extends Error {
|
|
26
|
-
constructor(message) {
|
|
27
|
-
super(message);
|
|
28
|
-
this.name = 'CancelRun';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
5
|
export default class JestHarness {
|
|
32
6
|
isSerial = true;
|
|
33
7
|
#globalConfig;
|
|
8
|
+
#session = null;
|
|
34
9
|
constructor(globalConfig) {
|
|
35
10
|
this.#globalConfig = globalConfig;
|
|
36
11
|
}
|
|
@@ -38,217 +13,24 @@ export default class JestHarness {
|
|
|
38
13
|
if (!options.serial) {
|
|
39
14
|
throw new Error('Parallel test running is not supported');
|
|
40
15
|
}
|
|
16
|
+
const isWatchMode = this.#globalConfig.watch || this.#globalConfig.watchAll;
|
|
41
17
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return await this._createInBandTestRun(tests, watcher, harness, harnessConfig, onStart, onResult, onFailure);
|
|
18
|
+
if (!this.#session) {
|
|
19
|
+
this.#session = await createHarnessSession(this.#globalConfig);
|
|
20
|
+
}
|
|
21
|
+
await executeRun(this.#session, tests, watcher, onStart, onResult, onFailure, this.#globalConfig);
|
|
47
22
|
}
|
|
48
23
|
catch (error) {
|
|
49
24
|
if (error instanceof HarnessError) {
|
|
50
|
-
// Jest will print strings as they are, without processing them further.
|
|
51
25
|
throw getErrorMessage(error);
|
|
52
26
|
}
|
|
53
27
|
throw error;
|
|
54
28
|
}
|
|
55
29
|
finally {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
async _createInBandTestRun(tests, watcher, harness, harnessConfig, onStart, onResult, onFailure) {
|
|
61
|
-
const mutex = pLimit(1);
|
|
62
|
-
let isFirstTest = true;
|
|
63
|
-
const startTime = Date.now();
|
|
64
|
-
const runId = randomUUID();
|
|
65
|
-
const watchMode = this.#globalConfig.watch || this.#globalConfig.watchAll;
|
|
66
|
-
const rootDir = this.#globalConfig.rootDir ?? process.cwd();
|
|
67
|
-
const testFiles = tests.map((test) => path.relative(rootDir, test.path));
|
|
68
|
-
const summary = createRunSummary();
|
|
69
|
-
const updateRunState = (overrides = {}) => {
|
|
70
|
-
const nextRunState = {
|
|
71
|
-
runId,
|
|
72
|
-
startTime,
|
|
73
|
-
testFiles,
|
|
74
|
-
watchMode,
|
|
75
|
-
coverageEnabled: this.#globalConfig.collectCoverage,
|
|
76
|
-
summary,
|
|
77
|
-
status: summary.failed > 0 ? 'failed' : 'passed',
|
|
78
|
-
...overrides,
|
|
79
|
-
};
|
|
80
|
-
harness.setRunState(nextRunState);
|
|
81
|
-
return nextRunState;
|
|
82
|
-
};
|
|
83
|
-
updateRunState();
|
|
84
|
-
runLogger.debug('run started: runId=%s files=%d watchMode=%s coverage=%s', runId, testFiles.length, watchMode, this.#globalConfig.collectCoverage);
|
|
85
|
-
await harness.callHook('run:started', {
|
|
86
|
-
runId,
|
|
87
|
-
startTime,
|
|
88
|
-
testFiles,
|
|
89
|
-
watchMode,
|
|
90
|
-
coverageEnabled: this.#globalConfig.collectCoverage,
|
|
91
|
-
});
|
|
92
|
-
await harness.callHook('metro:initialized', {
|
|
93
|
-
runId,
|
|
94
|
-
port: harnessConfig.metroPort,
|
|
95
|
-
host: harnessConfig.host?.trim() || undefined,
|
|
96
|
-
});
|
|
97
|
-
try {
|
|
98
|
-
await tests.reduce((promise, test) => mutex(() => {
|
|
99
|
-
let didApplySummary = false;
|
|
100
|
-
return promise
|
|
101
|
-
.then(async () => {
|
|
102
|
-
const relativeTestPath = path.relative(rootDir, test.path);
|
|
103
|
-
const testFileStartedAt = Date.now();
|
|
104
|
-
let didEmitTestFileFinished = false;
|
|
105
|
-
await harness.callHook('test-file:started', {
|
|
106
|
-
runId,
|
|
107
|
-
file: relativeTestPath,
|
|
108
|
-
});
|
|
109
|
-
runLogger.debug('test file started: %s', relativeTestPath);
|
|
110
|
-
const emitTestFileFinished = async (options) => {
|
|
111
|
-
didEmitTestFileFinished = true;
|
|
112
|
-
runLogger.debug('test file finished: %s status=%s duration=%dms', relativeTestPath, options.status, options.duration);
|
|
113
|
-
await harness.callHook('test-file:finished', {
|
|
114
|
-
runId,
|
|
115
|
-
file: relativeTestPath,
|
|
116
|
-
duration: options.duration,
|
|
117
|
-
status: options.status,
|
|
118
|
-
result: options.result,
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
try {
|
|
122
|
-
if (watcher.isInterrupted()) {
|
|
123
|
-
throw new CancelRun();
|
|
124
|
-
}
|
|
125
|
-
if (harnessConfig.resetEnvironmentBetweenTestFiles &&
|
|
126
|
-
!isFirstTest) {
|
|
127
|
-
runLogger.debug('resetting environment before %s', relativeTestPath);
|
|
128
|
-
await harness.restart(test.path);
|
|
129
|
-
}
|
|
130
|
-
isFirstTest = false;
|
|
131
|
-
const result = await onStart(test).then(async () => {
|
|
132
|
-
if (!harnessConfig.detectNativeCrashes) {
|
|
133
|
-
runLogger.debug('native crash detection disabled for %s', relativeTestPath);
|
|
134
|
-
await harness.ensureAppReady(test.path);
|
|
135
|
-
return runHarnessTestFile({
|
|
136
|
-
testPath: test.path,
|
|
137
|
-
harness,
|
|
138
|
-
globalConfig: this.#globalConfig,
|
|
139
|
-
projectConfig: test.context.config,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
await harness.ensureAppReady(test.path);
|
|
143
|
-
harness.crashSupervisor.beginTestRun(test.path);
|
|
144
|
-
runLogger.debug('native crash detection armed for %s', relativeTestPath);
|
|
145
|
-
const crashPromise = harness.crashSupervisor.waitForCrash(test.path);
|
|
146
|
-
try {
|
|
147
|
-
return await Promise.race([
|
|
148
|
-
runHarnessTestFile({
|
|
149
|
-
testPath: test.path,
|
|
150
|
-
harness,
|
|
151
|
-
globalConfig: this.#globalConfig,
|
|
152
|
-
projectConfig: test.context.config,
|
|
153
|
-
}),
|
|
154
|
-
crashPromise,
|
|
155
|
-
]);
|
|
156
|
-
}
|
|
157
|
-
finally {
|
|
158
|
-
harness.crashSupervisor.cancelCrashWaiters();
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
applyJestResultToSummary(summary, result.jestResult);
|
|
162
|
-
didApplySummary = true;
|
|
163
|
-
updateRunState();
|
|
164
|
-
await emitTestFileFinished({
|
|
165
|
-
status: result.harnessResult.status,
|
|
166
|
-
duration: result.duration,
|
|
167
|
-
result: result.harnessResult,
|
|
168
|
-
});
|
|
169
|
-
return result;
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
if (!didEmitTestFileFinished) {
|
|
173
|
-
await emitTestFileFinished({
|
|
174
|
-
status: 'failed',
|
|
175
|
-
duration: Date.now() - testFileStartedAt,
|
|
176
|
-
result: null,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
throw error;
|
|
180
|
-
}
|
|
181
|
-
})
|
|
182
|
-
.then(async (result) => {
|
|
183
|
-
if (!result) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
await onResult(test, result.jestResult);
|
|
187
|
-
})
|
|
188
|
-
.catch(async (err) => {
|
|
189
|
-
if (err instanceof NativeCrashError ||
|
|
190
|
-
err instanceof StartupStallError ||
|
|
191
|
-
err instanceof DeviceNotRespondingError) {
|
|
192
|
-
runLogger.debug('classified runtime failure for %s: %s', test.path, err.name);
|
|
193
|
-
summary.failed += 1;
|
|
194
|
-
updateRunState();
|
|
195
|
-
}
|
|
196
|
-
if (err instanceof NativeCrashError) {
|
|
197
|
-
harness.crashSupervisor.reset();
|
|
198
|
-
onFailure(test, {
|
|
199
|
-
message: err.message,
|
|
200
|
-
stack: '',
|
|
201
|
-
});
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (err instanceof StartupStallError) {
|
|
205
|
-
onFailure(test, {
|
|
206
|
-
message: err.message,
|
|
207
|
-
stack: '',
|
|
208
|
-
});
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
if (err instanceof DeviceNotRespondingError) {
|
|
212
|
-
onFailure(test, {
|
|
213
|
-
message: err.message,
|
|
214
|
-
stack: '',
|
|
215
|
-
});
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (!(err instanceof CancelRun) && !didApplySummary) {
|
|
219
|
-
summary.failed += 1;
|
|
220
|
-
}
|
|
221
|
-
updateRunState({ error: err });
|
|
222
|
-
onFailure(test, err);
|
|
223
|
-
});
|
|
224
|
-
}), Promise.resolve());
|
|
225
|
-
const runState = updateRunState();
|
|
226
|
-
runLogger.debug('run finished: runId=%s status=%s duration=%dms', runId, runState.status ?? 'passed', Date.now() - startTime);
|
|
227
|
-
await harness.callHook('run:finished', {
|
|
228
|
-
runId,
|
|
229
|
-
startTime,
|
|
230
|
-
duration: Date.now() - startTime,
|
|
231
|
-
testFiles,
|
|
232
|
-
summary,
|
|
233
|
-
status: runState.status ?? 'passed',
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
const runState = updateRunState({
|
|
238
|
-
error,
|
|
239
|
-
status: 'failed',
|
|
240
|
-
});
|
|
241
|
-
runLogger.debug('run failed: runId=%s status=%s', runId, runState.status ?? 'failed');
|
|
242
|
-
await harness.callHook('run:finished', {
|
|
243
|
-
runId,
|
|
244
|
-
startTime,
|
|
245
|
-
duration: Date.now() - startTime,
|
|
246
|
-
testFiles,
|
|
247
|
-
summary,
|
|
248
|
-
status: runState.status ?? 'failed',
|
|
249
|
-
error,
|
|
250
|
-
});
|
|
251
|
-
throw error;
|
|
30
|
+
if (!isWatchMode) {
|
|
31
|
+
await this.#session?.dispose();
|
|
32
|
+
this.#session = null;
|
|
33
|
+
}
|
|
252
34
|
}
|
|
253
35
|
}
|
|
254
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-options.d.ts","sourceRoot":"","sources":["../src/jest-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/logs.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export declare const logRunnerStarting: (runner: HarnessPlatform) => void;
|
|
|
9
9
|
export declare const logMetroPrewarmCompleted: (runner: HarnessPlatform) => void;
|
|
10
10
|
export declare const logMetroCacheReused: (runner: HarnessPlatform) => void;
|
|
11
11
|
export declare const logMetroPortFallback: (initialPort: number, selectedPort: number) => void;
|
|
12
|
+
export declare const logNativeCoverageCollected: (lcovPath: string) => void;
|
|
12
13
|
export declare const getErrorMessage: (error: HarnessError) => string;
|
|
13
14
|
//# sourceMappingURL=logs.d.ts.map
|
package/dist/logs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAY3D,eAAO,MAAM,GAAG,GAAI,SAAS,MAAM,KAAG,IAErC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,eAAe,KAAG,IAI1D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,eAAe,KAAG,IAEjE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,eAAe,KAAG,IAEjE,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,QAAQ,eAAe,KAAG,IAEtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,KAAG,IAE3D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,eAAe,KAAG,IAElE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,QAAQ,eAAe,KAAG,IAE7D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,aAAa,MAAM,EACnB,cAAc,MAAM,KACnB,IAMF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,YAAY,KAAG,MAErD,CAAC"}
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAY3D,eAAO,MAAM,GAAG,GAAI,SAAS,MAAM,KAAG,IAErC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,eAAe,KAAG,IAI1D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,eAAe,KAAG,IAEjE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,eAAe,KAAG,IAEjE,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,QAAQ,eAAe,KAAG,IAEtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,KAAG,IAE3D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,eAAe,KAAG,IAElE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,QAAQ,eAAe,KAAG,IAE7D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,aAAa,MAAM,EACnB,cAAc,MAAM,KACnB,IAMF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,UAAU,MAAM,KAAG,IAE7D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,YAAY,KAAG,MAErD,CAAC"}
|
package/dist/logs.js
CHANGED
|
@@ -33,6 +33,9 @@ export const logMetroCacheReused = (runner) => {
|
|
|
33
33
|
export const logMetroPortFallback = (initialPort, selectedPort) => {
|
|
34
34
|
log(`${TAG} Harness could not use Metro port ${chalk.bold(String(initialPort))} and is using ${chalk.bold(String(selectedPort))} instead.\n`);
|
|
35
35
|
};
|
|
36
|
+
export const logNativeCoverageCollected = (lcovPath) => {
|
|
37
|
+
log(`${TAG} Native coverage written to ${chalk.bold(lcovPath)}\n`);
|
|
38
|
+
};
|
|
36
39
|
export const getErrorMessage = (error) => {
|
|
37
40
|
return `${ERROR_TAG} ${error.message}\n`;
|
|
38
41
|
};
|
package/dist/resource-lock.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ type ResourceLockManagerOptions = {
|
|
|
19
19
|
logger?: HarnessLogger;
|
|
20
20
|
isProcessActive?: (pid: number) => boolean;
|
|
21
21
|
};
|
|
22
|
-
export declare const hashResourceLockKey: (key: string) => string;
|
|
23
22
|
export declare const createResourceLockManager: (options?: ResourceLockManagerOptions) => ResourceLockManager;
|
|
24
23
|
export {};
|
|
25
24
|
//# sourceMappingURL=resource-lock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-lock.d.ts","sourceRoot":"","sources":["../src/resource-lock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAiBzE,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,CACP,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,0BAA0B,KACjC,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-lock.d.ts","sourceRoot":"","sources":["../src/resource-lock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAiBzE,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,CACP,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,0BAA0B,KACjC,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C,CAAC;AAqQF,eAAO,MAAM,yBAAyB,GACpC,UAAS,0BAA+B,KACvC,mBAkKF,CAAC"}
|
package/dist/resource-lock.js
CHANGED
|
@@ -12,7 +12,7 @@ const wait = async (ms) => {
|
|
|
12
12
|
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
13
|
};
|
|
14
14
|
const createAbortError = () => new DOMException('The operation was aborted', 'AbortError');
|
|
15
|
-
|
|
15
|
+
const hashResourceLockKey = (key) => {
|
|
16
16
|
return crypto.createHash('sha256').update(key).digest('hex');
|
|
17
17
|
};
|
|
18
18
|
const getPathsForKey = (rootDir, key) => {
|
package/dist/run.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Config as JestConfig } from 'jest-runner';
|
|
2
2
|
import { TestResult as JestTestResult } from '@jest/test-result';
|
|
3
3
|
import type { TestSuiteResult as HarnessTestSuiteResult } from '@react-native-harness/bridge';
|
|
4
|
-
import type {
|
|
4
|
+
import type { HarnessSession } from './harness-session.js';
|
|
5
5
|
export type RunHarnessTestFile = (options: {
|
|
6
6
|
testPath: string;
|
|
7
|
-
|
|
7
|
+
session: HarnessSession;
|
|
8
8
|
projectConfig: JestConfig.ProjectConfig;
|
|
9
9
|
globalConfig: JestConfig.GlobalConfig;
|
|
10
10
|
}) => Promise<{
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EACV,eAAe,IAAI,sBAAsB,EAE1C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EACV,eAAe,IAAI,sBAAsB,EAE1C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAuD3D,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,cAAc,CAAC;IACxB,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC;IACxC,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC;CACvC,KAAK,OAAO,CAAC;IACZ,UAAU,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,sBAAsB,CAAC;IACtC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,kBAkFhC,CAAC"}
|
package/dist/run.js
CHANGED
|
@@ -42,17 +42,17 @@ const calculateStats = (tests) => {
|
|
|
42
42
|
}
|
|
43
43
|
return { passes, failures, pending, todo };
|
|
44
44
|
};
|
|
45
|
-
export const runHarnessTestFile = async ({ testPath, globalConfig, projectConfig,
|
|
45
|
+
export const runHarnessTestFile = async ({ testPath, globalConfig, projectConfig, session, }) => {
|
|
46
46
|
const start = Date.now();
|
|
47
47
|
const relativeTestPath = path.relative(globalConfig.rootDir, testPath);
|
|
48
48
|
// Extract setup files from Jest config and convert to relative paths
|
|
49
49
|
const setupFiles = projectConfig.setupFiles?.map((setupFile) => path.relative(globalConfig.rootDir, setupFile));
|
|
50
50
|
const setupFilesAfterEnv = projectConfig.setupFilesAfterEnv?.map((setupFile) => path.relative(globalConfig.rootDir, setupFile));
|
|
51
|
-
const harnessResult = await
|
|
51
|
+
const harnessResult = await session.runTestFile(relativeTestPath, {
|
|
52
52
|
testNamePattern: globalConfig.testNamePattern,
|
|
53
53
|
setupFiles,
|
|
54
54
|
setupFilesAfterEnv,
|
|
55
|
-
runner:
|
|
55
|
+
runner: session.context.platform.runner,
|
|
56
56
|
});
|
|
57
57
|
const end = Date.now();
|
|
58
58
|
const allTests = flattenTests(harnessResult);
|