Skip to content

Commit 9274396

Browse files
Also bump the waitFor timeout — testTimeout alone isn't enough (#4270)
## Summary Follow-up to #4268. That PR bumped `testTimeout` to 20s for this test but missed the second 9s ceiling: `configure({ asyncUtilTimeout: 9_000 })` in `packages/graphiql/setup-files.ts`. RTL's `waitFor` gives up at the asyncUtilTimeout regardless of how big the `it()` timeout is — its final assertion then runs against a `null` `queryEditor` and fails with `expect(...).toBeVisible()` instead of the original "Test timed out" message. Evidence the previous fix was luck-of-the-draw: #4268 passed because Monaco cold-booted at 7927ms — 73ms under the 9s cliff. #4266 failed at 9066ms on the same fix because Monaco took longer that run. This PR adds `{ timeout: 15_000 }` to the `waitFor(...)` call so the polling window matches the test's 20s ceiling. Keeps `it(..., 20000)` so the two timeouts don't race in the other direction.
1 parent e4f5148 commit 9274396

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

packages/graphiql/src/GraphiQL.spec.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,22 @@ describe('GraphiQL', () => {
167167
}); // schema
168168

169169
describe('default query', () => {
170-
// First test to boot Monaco's editor worker; cold start needs extra time under Vitest 4's forks pool.
170+
// First test to boot Monaco's editor worker; cold start needs extra time under
171+
// Vitest 4's forks pool. Both the it() testTimeout and the waitFor()
172+
// asyncUtilTimeout (configured at 9s in setup-files.ts) must be bumped.
171173
it('defaults to the built-in default query', async () => {
172174
const { container } = render(<GraphiQL fetcher={noOpFetcher} />);
173175

174-
await waitFor(() => {
175-
const queryEditor = container.querySelector<HTMLDivElement>(
176-
'.graphiql-editor .monaco-scrollable-element',
177-
);
178-
expect(queryEditor).toBeVisible();
179-
expect(queryEditor!.textContent).toBe('# Welcome to GraphiQL');
180-
});
176+
await waitFor(
177+
() => {
178+
const queryEditor = container.querySelector<HTMLDivElement>(
179+
'.graphiql-editor .monaco-scrollable-element',
180+
);
181+
expect(queryEditor).toBeVisible();
182+
expect(queryEditor!.textContent).toBe('# Welcome to GraphiQL');
183+
},
184+
{ timeout: 15_000 },
185+
);
181186
}, 20000);
182187

183188
it('accepts a custom default query', async () => {

0 commit comments

Comments
 (0)