Add some testing hints
This commit is contained in:
parent
491124df1f
commit
a844bf362d
@ -6,6 +6,32 @@ import { HashRouter as DOMRouter } from 'react-router-dom';
|
||||
import theme from '../theme';
|
||||
import I18n from '../I18n';
|
||||
|
||||
/*
|
||||
This is wrapper for the render method in order to provide all required providers and
|
||||
not to repeat them for each test.
|
||||
|
||||
If you want to debug a test by having a look at the current output of the component,
|
||||
simply import the "screen" object from this file and use the "debug()" method:
|
||||
|
||||
test('displays the header and paragraph text', () => {
|
||||
render(<Travel />)
|
||||
screen.debug()
|
||||
})
|
||||
|
||||
or of a specific element in the component:
|
||||
|
||||
test('displays the header and paragraph text', () => {
|
||||
render(<Travel />)
|
||||
const header = screen.getByRole('heading', { name: /travel anywhere/i })
|
||||
screen.debug(header)
|
||||
})
|
||||
|
||||
More about "render" and "screen" on https://testing-library.com/docs
|
||||
|
||||
For testing certain conditions, check out https://jestjs.io/docs/expect and for
|
||||
running tests, check out https://jestjs.io/docs/api.
|
||||
*/
|
||||
|
||||
const AllTheProviders = ({ children }) => {
|
||||
return (
|
||||
<StyledEngineProvider injectFirst>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { render, fireEvent, screen } from '../../../utils/testing';
|
||||
import { render, fireEvent } from '../../../utils/testing';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
import * as Network from './Network';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user