mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
bdfa37cd4d
This example show how you can test Next.js apps with [react-testing-library](https://github.com/kentcdodds/react-testing-library). This library encourages your applications to be more accessible and allows you to get your tests closer to using your components the way a user will, which allows your tests to give you more confidence that your application will work when a real user uses it. And also, is a replacement for enzyme. <img width="733" alt="Image showing the words next.js + react testing library" src="https://user-images.githubusercontent.com/4689228/50387208-40223200-06de-11e9-9358-607092eb25a0.png">
15 lines
322 B
JavaScript
15 lines
322 B
JavaScript
/* eslint-env jest */
|
|
|
|
import React from 'react'
|
|
import { render } from 'react-testing-library'
|
|
|
|
import App from '../pages/index.js'
|
|
|
|
describe('With React Testing Library', () => {
|
|
it('Shows "Hello world!"', () => {
|
|
const { getByText } = render(<App />)
|
|
|
|
expect(getByText('Hello World!')).not.toBeNull()
|
|
})
|
|
})
|