Skip to content

Commit eb0bec9

Browse files
committed
e2e/routes/category: Migrate from mirage to @crates-io/msw
1 parent f42ba2f commit eb0bec9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

e2e/routes/category.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { test, expect } from '@/e2e/helper';
1+
import { expect, test } from '@/e2e/helper';
2+
import { http, HttpResponse } from 'msw';
23

34
test.describe('Route | category', { tag: '@routes' }, () => {
45
test("shows an error message if the category can't be found", async ({ page }) => {
@@ -10,10 +11,8 @@ test.describe('Route | category', { tag: '@routes' }, () => {
1011
await expect(page.locator('[data-test-try-again]')).toHaveCount(0);
1112
});
1213

13-
test('server error causes the error page to be shown', async ({ page, mirage }) => {
14-
await mirage.addHook(server => {
15-
server.get('/api/v1/categories/:categoryId', {}, 500);
16-
});
14+
test('server error causes the error page to be shown', async ({ page, msw }) => {
15+
msw.worker.use(http.get('/api/v1/categories/:categoryId', () => HttpResponse.json({}, { status: 500 })));
1716

1817
await page.goto('/categories/foo');
1918
await expect(page).toHaveURL('/categories/foo');
@@ -23,10 +22,8 @@ test.describe('Route | category', { tag: '@routes' }, () => {
2322
await expect(page.locator('[data-test-try-again]')).toBeVisible();
2423
});
2524

26-
test('updates the search field when the categories route is accessed', async ({ page, mirage }) => {
27-
await mirage.addHook(server => {
28-
server.create('category', { category: 'foo' });
29-
});
25+
test('updates the search field when the categories route is accessed', async ({ page, msw }) => {
26+
msw.db.category.create({ category: 'foo' });
3027

3128
const searchInput = page.locator('[data-test-search-input]');
3229
await page.goto('/');

0 commit comments

Comments
 (0)