import React from 'react'; import { render, screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import AlertError from '.'; const RootWrapper = ({ error }: { error: unknown }) => ( ); describe('', () => { test('render using a string', () => { const error = 'This is a string error message'; const { getByText } = render(); expect(getByText('This is a string error message')).toBeInTheDocument(); }); test('render using an error', () => { const error = new Error('This is an error message'); const { getByText } = render(); expect(getByText('This is an error message')).toBeInTheDocument(); }); test('render using an error with response', () => { const error = { message: 'This is an error message', response: { data: { message: 'This is a response body', }, }, }; const { getByText } = render(); screen.logTestingPlaygroundURL(); expect(getByText(/this is an error message/i)).toBeInTheDocument(); expect(getByText(/\{ "message": "this is a response body" \}/i)).toBeInTheDocument(); }); });