Migrate test suite from Cypress and Jest to Playwright and Vitest

This commit is contained in:
Mike Cao committed 2026-05-09 01:23:20 -07:00
1 parent 2fd319f910
commit 216cf6c448
37 files changed
+2218 -3991

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
import { expect, test } from '@jest/globals';
import { expect, test } from 'vitest';
import { getApiUrl } from '../api-url';
test('uses the default api path', () => {
+1 -1
View File
@@ -257,7 +257,7 @@ export const DOMAIN_REGEX =
/^(localhost(:[1-9]\d{0,4})?|((?=[a-z0-9-_]{1,63}\.)(xn--)?[a-z0-9-_]+(-[a-z0-9-_]+)*\.)+(xn--)?[a-z0-9-_]{2,63})$/;
export const SHARE_ID_REGEX = /^[a-zA-Z0-9]{8,50}$/;
export const DATETIME_REGEX =
/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]{3}(Z|\+[0-9]{2}:[0-9]{2})?)?$/;
/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]{3})?(Z|\+[0-9]{2}:[0-9]{2})?$/;
export const URL_LENGTH = 500;
export const PAGE_TITLE_LENGTH = 500;
+3
View File
@@ -0,0 +1,3 @@
import type { RequestHandler } from 'msw';
export const handlers: RequestHandler[] = [];
+5
View File
@@ -0,0 +1,5 @@
import { setupServer } from 'msw/node';
import { handlers } from './handlers';
export const server = setupServer(...handlers);
export { HttpResponse, http } from 'msw';
+15
View File
@@ -0,0 +1,15 @@
import '@testing-library/jest-dom/vitest';
import { afterAll, afterEach, beforeAll } from 'vitest';
import { server } from './msw/server';
beforeAll(() => {
server.listen({ onUnhandledRequest: 'error' });
});
afterEach(() => {
server.resetHandlers();
});
afterAll(() => {
server.close();
});
+10
View File
@@ -0,0 +1,10 @@
import { type RenderOptions, render } from '@testing-library/react';
import type { ReactElement } from 'react';
const customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'wrapper'>) => {
return render(ui, options);
};
export * from '@testing-library/react';
export { default as userEvent } from '@testing-library/user-event';
export { customRender as render };
+2
View File
@@ -0,0 +1,2 @@
/// <reference types="vitest/globals" />
/// <reference types="@testing-library/jest-dom" />