This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2516 from kcdraidgroup/master
test: migrate tests to React Testing Library
- Loading branch information
Showing
169 changed files
with
5,719 additions
and
8,506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,41 @@ | ||
import { shallow } from 'enzyme' | ||
import { render, screen } from '@testing-library/react' | ||
import React from 'react' | ||
import { Provider } from 'react-redux' | ||
import configureStore from 'redux-mock-store' | ||
import createMockStore from 'redux-mock-store' | ||
import thunk from 'redux-thunk' | ||
|
||
import App from '../App' | ||
import { RootState } from '../shared/store' | ||
|
||
it('renders without crashing', () => { | ||
const mockStore = configureStore()({}) | ||
const mockStore = createMockStore<RootState, any>([thunk]) | ||
|
||
const AppWithStore = () => ( | ||
<Provider store={mockStore}> | ||
it('renders without crashing', async () => { | ||
// Supress the console.log in the test ouput | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
jest.spyOn(console, 'log').mockImplementation(() => {}) | ||
|
||
const store = mockStore({ | ||
components: { | ||
sidebarCollapsed: false, | ||
}, | ||
breadcrumbs: { | ||
breadcrumbs: [], | ||
}, | ||
user: { | ||
permissions: [], | ||
}, | ||
} as any) | ||
|
||
render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider> | ||
</Provider>, | ||
) | ||
|
||
const wrapper = shallow(<AppWithStore />) | ||
expect(wrapper).toBeDefined() | ||
expect( | ||
await screen.findByRole('heading', { name: /dashboard\.label/i }, { timeout: 8000 }), | ||
).toBeInTheDocument() | ||
|
||
// eslint-disable-next-line no-console | ||
;(console.log as jest.Mock).mockRestore() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
660a895
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: