Releases: 42BV/react-flash-messages
Releases · 42BV/react-flash-messages
v2.0.2
v2.0.1
- chore: update dependencies 81f2d1c
v2.0.0
🚨🚨🚨Breaking Changes 🚨🚨🚨
Because of updates to the build process it is no longer possible to use jest to spyOn
the flash messages. This will no longer work jest.spyOn(reactFlashMessages, 'addSuccess');
and will give the following error: TypeError during Jest's spyOn: Cannot set property getRequest of #<Object> which has only a getter
.
A simple solution is to mock the entire library.
When using Jest you can add the following in the setupTests.ts
file:
// Mock @42.nl/react-flash-messages
jest.mock('@42.nl/react-flash-messages', () => {
const originalModule = jest.requireActual('@42.nl/react-flash-messages');
return {
...originalModule,
addError: jest.fn(),
addWarning: jest.fn(),
addSuccess: jest.fn(),
addInfo: jest.fn(),
addApocalypse: jest.fn(),
removeFlashMessage: jest.fn()
}
});
This way by default all flash messages actions are mocked, and there is no need
to do jest.spyOn(reactFlashMessages, 'addSuccess');
ever again.
Other changes: