Skip to content

Commit 2583279

Browse files
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 4865d84 commit 2583279

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
@@ -9,6 +9,13 @@ import axios from '@nextcloud/axios'
99
import JSConfetti from 'js-confetti'
1010
import Validation from '../../views/Validation.vue'
1111

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

0 commit comments

Comments
 (0)