Skip to content

Commit

Permalink
chore(tests): fix vitest can't terminate worker (#2644)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin authored Mar 4, 2024
1 parent edfbe2c commit 0fa87f7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/nuxt/content-rich.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?.() })
Expand Down
8 changes: 8 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ export default defineVitestConfig({
setupFiles: [
'/tests/setup.ts',
],
environmentOptions: {
nuxt: {
mock: {
indexedDb: true,
intersectionObserver: true,
},
},
},
},
})

0 comments on commit 0fa87f7

Please sign in to comment.