Download react-testing-library/src/__tests__/debug.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/debug.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/debug.js
-
curl -L -o debug.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/debug.js
1.34 kB
| import * as React from 'react' | |
| import {render, screen} from '../' | |
| beforeEach(() => { | |
| jest.spyOn(console, 'log').mockImplementation(() => {}) | |
| }) | |
| afterEach(() => { | |
| console.log.mockRestore() | |
| }) | |
| test('debug pretty prints the container', () => { | |
| const HelloWorld = () => <h1>Hello World</h1> | |
| const {debug} = render(<HelloWorld />) | |
| debug() | |
| expect(console.log).toHaveBeenCalledTimes(1) | |
| expect(console.log).toHaveBeenCalledWith( | |
| expect.stringContaining('Hello World'), | |
| ) | |
| }) | |
| test('debug pretty prints multiple containers', () => { | |
| const HelloWorld = () => ( | |
| <> | |
| <h1 data-testid="testId">Hello World</h1> | |
| <h1 data-testid="testId">Hello World</h1> | |
| </> | |
| ) | |
| const {debug} = render(<HelloWorld />) | |
| const multipleElements = screen.getAllByTestId('testId') | |
| debug(multipleElements) | |
| expect(console.log).toHaveBeenCalledTimes(2) | |
| expect(console.log).toHaveBeenCalledWith( | |
| expect.stringContaining('Hello World'), | |
| ) | |
| }) | |
| test('allows same arguments as prettyDOM', () => { | |
| const HelloWorld = () => <h1>Hello World</h1> | |
| const {debug, container} = render(<HelloWorld />) | |
| debug(container, 6, {highlight: false}) | |
| expect(console.log).toHaveBeenCalledTimes(1) | |
| expect(console.log.mock.calls[0]).toMatchInlineSnapshot(` | |
| [ | |
| <div> | |
| ..., | |
| ] | |
| `) | |
| }) | |
| /* | |
| eslint | |
| no-console: "off", | |
| */ | |