Skip to content

Commit 0dc1748

Browse files
committed
test(unit): mock async components in Validation.spec to fix vitest worker errors
defineAsyncComponent triggers internal Vite dev-server fetch requests when the component is registered. When the vitest worker closes after all tests finish, those fetches are still pending, producing 13 'Closing rpc while fetch was pending' unhandled rejections. Mocking the three async component modules prevents the dynamic imports from ever being initiated during the test run. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent b260d8d commit 0dc1748

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/tests/views/Validation.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import { getCapabilities } from '@nextcloud/capabilities'
1010
import JSConfetti from 'js-confetti'
1111
import Validation from '../../views/Validation.vue'
1212

13+
// Mock async components to prevent defineAsyncComponent from triggering
14+
// pending Vite dev-server fetches that outlive the worker and cause
15+
// "Closing rpc while fetch was pending" errors in Vitest.
16+
vi.mock('../../components/validation/EnvelopeValidation.vue', () => ({ default: { template: '<div />' } }))
17+
vi.mock('../../components/validation/FileValidation.vue', () => ({ default: { template: '<div />' } }))
18+
vi.mock('../../components/validation/SigningProgress.vue', () => ({ default: { template: '<div />' } }))
19+
1320
// Mock js-confetti
1421
vi.mock('js-confetti', () => ({
1522
default: vi.fn(),

0 commit comments

Comments
 (0)