msw.test.ts19 lines · main
1import { expect, test } from 'vitest'
2
3import { API_URL } from '@/lib/constants'
4
5test('MSW works as expected', async () => {
6 const res = await fetch(`${API_URL}/msw/test`)
7 const json = await res.json()
8
9 expect(res.status).toBe(200)
10 expect(json).toEqual({ message: 'Hello from MSW!' })
11})
12
13test('MSW errors on missing endpoints', async () => {
14 expect(async () => {
15 const res = await fetch(`${API_URL}/endpoint-that-doesnt-exist`)
16 const json = await res.json()
17 expect(json).toEqual({ message: '🚫 MSW missed' })
18 })
19})