test: Update test files to work with Vitest

This updates the files to be compatible with Vitest. Changes include:
- adding `@testing-library/jest-dom` import to enable custom jest matchers
- renaming `jest.` to `vi.`
- setting flags to false as default where needed
This commit is contained in:
regexowl 2024-06-24 08:46:16 +02:00 committed by Ondřej Ezr
parent da16a42128
commit 2a48966bba
23 changed files with 196 additions and 63 deletions

View file

@ -11,6 +11,7 @@ import {
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { rest } from 'msw';
import nodeFetch, { Request, Response } from 'node-fetch';
import {
enterBlueprintName,
@ -29,6 +30,8 @@ import {
verifyCancelButton,
} from '../../testUtils';
Object.assign(global, { fetch: nodeFetch, Request, Response });
const routes = [
{
path: 'insights/image-builder/*',
@ -46,7 +49,7 @@ const routes = [
let router: RemixRouter | undefined = undefined;
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
useChrome: () => ({
auth: {
getUser: () => {
@ -65,6 +68,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
}),
}));
vi.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => vi.fn(),
useFlag: vi.fn(() => false),
}));
const switchToAWSManual = async () => {
const user = userEvent.setup();
const manualRadio = await screen.findByRole('radio', {
@ -96,7 +104,7 @@ beforeAll(() => {
});
afterEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
router = undefined;
server.resetHandlers();
});