mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-06 09:52:06 +02:00
Maybe finally fix that flaky test??
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { configure, render, screen, waitFor } from '@testing-library/react';
|
import { configure, render, screen, waitFor } from '@testing-library/react';
|
||||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
const mocks = vi.hoisted(() => ({
|
const mocks = vi.hoisted(() => ({
|
||||||
api: {
|
api: {
|
||||||
@@ -150,25 +150,27 @@ const publicChannel = {
|
|||||||
favorite: false,
|
favorite: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('App startup hash resolution', () => {
|
// App startup fans out several async fetches (config, settings, channels,
|
||||||
// App startup fans out several async fetches (config, settings, channels,
|
// contacts, unreads) that must all settle before conversation selection
|
||||||
// contacts, unreads) that must all settle before conversation selection
|
// renders. This suite passes in isolation, but under the full parallel suite
|
||||||
// renders. This suite passes 20/20 in isolation, but under the full parallel
|
// (~70 files) CPU contention can stretch that startup well past RTL's 1000ms
|
||||||
// suite (~69 files) CPU contention can stretch that startup well past RTL's
|
// default — and even past vitest's 5000ms test timeout — for any waitFor in
|
||||||
// 1000ms default — and even past vitest's 5000ms test timeout — for any
|
// this file. It's starvation, not a hang, so give this file generous headroom
|
||||||
// waitFor in this file. It's starvation, not a hang, so give this suite
|
// on both timeouts: a healthy render still settles in ~100ms (nothing is
|
||||||
// generous headroom on both timeouts: a healthy render still settles in
|
// slowed), only a starved run waits longer.
|
||||||
// ~100ms (nothing is slowed), only a starved run waits longer. Scoped to this
|
//
|
||||||
// file and restored afterward so other test files are unaffected.
|
// These MUST run at module scope, not in beforeAll: vitest bakes each test's
|
||||||
beforeAll(() => {
|
// timeout in when it() registers the test (during collection, before any
|
||||||
vi.setConfig({ testTimeout: 15000 });
|
// beforeAll runs), so a beforeAll setConfig is too late and the test keeps the
|
||||||
configure({ asyncUtilTimeout: 10000 });
|
// 5000ms default. configure() worked from beforeAll only because waitFor reads
|
||||||
});
|
// asyncUtilTimeout dynamically — which left an inverted pair (waitFor allowed
|
||||||
afterAll(() => {
|
// 10s but the test killed at 5s) that flaked under load. vi.setConfig is scoped
|
||||||
vi.resetConfig();
|
// to this file (each file runs in its own isolated worker), so other files are
|
||||||
configure({ asyncUtilTimeout: 1000 });
|
// unaffected.
|
||||||
});
|
vi.setConfig({ testTimeout: 15000 });
|
||||||
|
configure({ asyncUtilTimeout: 10000 });
|
||||||
|
|
||||||
|
describe('App startup hash resolution', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user