From 0fa87f71a430acf8c3beb0e1a9a8f66369438055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Mon, 4 Mar 2024 17:41:38 +0100 Subject: [PATCH] chore(tests): fix vitest can't terminate worker (#2644) --- .github/workflows/ci.yml | 2 +- tests/nuxt/content-rich.test.ts | 24 ++++++++++++++++++++++++ vitest.config.ts | 8 ++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 065fb4c2..e824a50e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 cache: pnpm - name: 📦 Install dependencies diff --git a/tests/nuxt/content-rich.test.ts b/tests/nuxt/content-rich.test.ts index 04266de5..e07a898d 100644 --- a/tests/nuxt/content-rich.test.ts +++ b/tests/nuxt/content-rich.test.ts @@ -211,6 +211,30 @@ vi.mock('vue-router', async () => { } }) +vi.mock('@vueuse/shared', async () => { + const vueuseShared = await import('@vueuse/shared') + // mock pausableWatch and watchPausable: vitest process hangs from time to time + return { + ...vueuseShared, + pausableWatch: () => { + return { + stop: () => {}, + pause: () => {}, + resume: () => {}, + isActive: readonly(ref(true)), + } + }, + watchPausable: () => { + return { + stop: () => {}, + pause: () => {}, + resume: () => {}, + isActive: readonly(ref(true)), + } + }, + } +}) + mockComponent('ContentMentionGroup', { setup(props, { slots }) { return () => h('mention-group', null, { default: () => slots?.default?.() }) diff --git a/vitest.config.ts b/vitest.config.ts index d8ff19ef..1c274a66 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -10,5 +10,13 @@ export default defineVitestConfig({ setupFiles: [ '/tests/setup.ts', ], + environmentOptions: { + nuxt: { + mock: { + indexedDb: true, + intersectionObserver: true, + }, + }, + }, }, })