Skip to content

Commit dbff62b

Browse files
committed
fix: stabilize jest plugin integration tests
1 parent e94b655 commit dbff62b

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

packages/jest/src/__tests__/harness.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ describe('restart(testFilePath)', () => {
481481
const platformInstance = createPlatformRunner({
482482
restartApp,
483483
stopApp,
484+
isAppRunning: vi.fn(async () => false),
484485
createAppMonitor: () => appMonitor.appMonitor,
485486
});
486487

@@ -528,17 +529,17 @@ describe('restart(testFilePath)', () => {
528529
await flush();
529530

530531
expect(stopApp).toHaveBeenCalledTimes(1);
531-
expect(restartApp).toHaveBeenCalledTimes(1);
532-
expect(restartApp).toHaveBeenNthCalledWith(1, {
533-
extras: {
534-
source: 'restart',
535-
},
536-
});
532+
expect(restartApp).toHaveBeenCalledTimes(0);
537533

538534
await vi.advanceTimersByTimeAsync(1_000);
539535
await flush();
540536

541537
expect(restartApp).toHaveBeenCalledTimes(2);
538+
expect(restartApp).toHaveBeenNthCalledWith(1, {
539+
extras: {
540+
source: 'restart',
541+
},
542+
});
542543
expect(restartApp).toHaveBeenNthCalledWith(2, {
543544
extras: {
544545
source: 'restart',

packages/jest/src/__tests__/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ describe('JestHarness', () => {
1414
ensureAppReady: vi
1515
.fn()
1616
.mockRejectedValue(new StartupStallError(1500, 3)),
17+
callHook: vi.fn(async () => undefined),
18+
setRunState: vi.fn(),
19+
getRunState: vi.fn(() => null),
1720
crashSupervisor: {
1821
beginTestRun: vi.fn(),
1922
waitForCrash: vi.fn(),

packages/jest/src/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const getHarnessInternal = async (
236236
maybeLogMetroCacheReuse(config, platform, projectRoot);
237237
const pluginAbortController = new AbortController();
238238
const pluginManager = createHarnessPluginManager<HarnessConfig, HarnessPlatform>({
239-
plugins: config.plugins as Array<
239+
plugins: (config.plugins ?? []) as Array<
240240
HarnessPlugin<object, HarnessConfig, HarnessPlatform>
241241
>,
242242
projectRoot,

packages/jest/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ export default class JestHarness implements CallbackTestRunnerInterface {
114114
const startTime = Date.now();
115115
const runId = randomUUID();
116116
const watchMode = this.#globalConfig.watch || this.#globalConfig.watchAll;
117+
const rootDir = this.#globalConfig.rootDir ?? process.cwd();
117118
const testFiles = tests.map((test) =>
118-
path.relative(this.#globalConfig.rootDir, test.path)
119+
path.relative(rootDir, test.path)
119120
);
120121
const summary = createRunSummary();
121122
const updateRunState = (overrides: Partial<HarnessRunState> = {}) => {
@@ -157,7 +158,7 @@ export default class JestHarness implements CallbackTestRunnerInterface {
157158
return promise
158159
.then(async () => {
159160
const relativeTestPath = path.relative(
160-
this.#globalConfig.rootDir,
161+
rootDir,
161162
test.path
162163
);
163164
const testFileStartedAt = Date.now();

0 commit comments

Comments
 (0)