diff --git a/src/courseware/course/sequence/Unit.test.jsx b/src/courseware/course/sequence/Unit.test.jsx index 02ec4998..f91734cd 100644 --- a/src/courseware/course/sequence/Unit.test.jsx +++ b/src/courseware/course/sequence/Unit.test.jsx @@ -72,9 +72,11 @@ describe('Unit', () => { window.postMessage(testMessageWithUnhandledType, '*'); // HACK: We don't have a function we could reliably await here, so this test relies on the timeout of `waitFor`. + // FIXME: After the last updates `toThrowErrorMatchingSnapshot` (due to a bug) started returning DOM + // after the error, so we had to fall back to `toThrowError` assertion for better readability. await expect(waitFor( () => expect(screen.getByTitle(mockData.id)).toHaveAttribute('height', String(testMessageWithUnhandledType.payload.height)), { timeout: 100 }, - )).rejects.toThrowErrorMatchingSnapshot(); + )).rejects.toThrowError(/Expected the element to have attribute/); }); }); diff --git a/src/courseware/course/sequence/__snapshots__/Unit.test.jsx.snap b/src/courseware/course/sequence/__snapshots__/Unit.test.jsx.snap index cf09688c..d1667750 100644 --- a/src/courseware/course/sequence/__snapshots__/Unit.test.jsx.snap +++ b/src/courseware/course/sequence/__snapshots__/Unit.test.jsx.snap @@ -42,15 +42,6 @@ exports[`Unit handles receiving MessageEvent 1`] = ` title=\\"3\\"" `; -exports[`Unit ignores MessageEvent with unhandled type 1`] = ` -"expect(element).toHaveAttribute(\\"height\\", \\"300\\") // element.getAttribute(\\"height\\") === \\"300\\" - -Expected the element to have attribute: - height=\\"300\\" -Received: - height=\\"0\\"" -`; - exports[`Unit renders correctly 1`] = `
{ const types = { - video: 'fa-film', + video: 'fa-video', other: 'fa-book', vertical: 'fa-tasks', problem: 'fa-edit', @@ -20,7 +20,7 @@ describe('Unit Icon', () => { } const { asFragment } = render(); - expect(screen.getByAltText(value)).toBeInTheDocument(); + expect(screen.getByTestId('icon')).toHaveClass(value); expect(asFragment()).toMatchSnapshot(); }); }); diff --git a/src/courseware/course/sequence/sequence-navigation/__snapshots__/UnitIcon.test.jsx.snap b/src/courseware/course/sequence/sequence-navigation/__snapshots__/UnitIcon.test.jsx.snap index 31ed98ba..49aeec72 100644 --- a/src/courseware/course/sequence/sequence-navigation/__snapshots__/UnitIcon.test.jsx.snap +++ b/src/courseware/course/sequence/sequence-navigation/__snapshots__/UnitIcon.test.jsx.snap @@ -53,8 +53,8 @@ exports[`Unit Icon renders correct icon for vertical unit 1`] = ` exports[`Unit Icon renders correct icon for video unit 1`] = ` fa-film diff --git a/src/setupTest.js b/src/setupTest.js index a76bb918..ab9e880c 100755 --- a/src/setupTest.js +++ b/src/setupTest.js @@ -50,7 +50,8 @@ import PropTypes from 'prop-types'; import { render as rtlRender, screen } from '@testing-library/react'; import { Provider } from 'react-redux'; import { configureStore } from '@reduxjs/toolkit'; -import { IntlProvider } from '@edx/frontend-platform/node_modules/react-intl'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { IntlProvider } from 'react-intl'; import { reducer as modelsReducer } from './model-store'; import { reducer as coursewareReducer } from './data'; import { UserMessagesProvider } from './user-messages';