Add some testing hints

This commit is contained in:
Ingo Oppermann 2022-11-16 16:45:02 +01:00
parent 491124df1f
commit a844bf362d
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E
2 changed files with 27 additions and 1 deletions

View File

@ -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>

View File

@ -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';