Skip to content

Commit dded988

Browse files
committed
test: mock bun:test
1 parent 19e5232 commit dded988

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

test/bun.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { getLocalDatabase } from '../src/utils/database.ts'
44

55
describe('Local database', () => {
66
let db: LocalDevelopmentDatabase
7+
78
afterAll(async () => {
89
if (db) {
910
await db.close()
1011
}
1112
})
13+
1214
test('Is Bun', async () => {
1315
expect(process.versions.bun).toBeDefined()
1416
})

test/mock/bun-test-stub.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Stub for bun:test to prevent bundling errors in Vitest
2+
export const mock = () => {}
3+
export const beforeAll = () => {}
4+
export const afterAll = () => {}
5+
export const beforeEach = () => {}
6+
export const afterEach = () => {}
7+
export const describe = () => {}
8+
export const test = () => {}
9+
export const it = () => {}
10+
export const expect = () => {}
11+

vitest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { resolve } from 'node:path'
22
import { defineVitestConfig } from '@nuxt/test-utils/config'
33

44
export default defineVitestConfig({
5+
resolve: {
6+
alias: {
7+
'bun:test': resolve('./test/mock/bun-test-stub.ts'),
8+
},
9+
},
510
test: {
611
environment: 'nuxt',
712
alias: {

0 commit comments

Comments
 (0)