Download react-testing-library/src/__tests__/multi-base.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/multi-base.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/multi-base.js
-
curl -L -o multi-base.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/multi-base.js
1.23 kB
| import * as React from 'react' | |
| import {render} from '../' | |
| // these are created once per test suite and reused for each case | |
| let treeA, treeB | |
| beforeAll(() => { | |
| treeA = document.createElement('div') | |
| treeB = document.createElement('div') | |
| document.body.appendChild(treeA) | |
| document.body.appendChild(treeB) | |
| }) | |
| afterAll(() => { | |
| treeA.parentNode.removeChild(treeA) | |
| treeB.parentNode.removeChild(treeB) | |
| }) | |
| test('baseElement isolates trees from one another', () => { | |
| const {getByText: getByTextInA} = render(<div>Jekyll</div>, { | |
| baseElement: treeA, | |
| }) | |
| const {getByText: getByTextInB} = render(<div>Hyde</div>, { | |
| baseElement: treeB, | |
| }) | |
| expect(() => getByTextInA('Jekyll')).not.toThrow( | |
| 'Unable to find an element with the text: Jekyll.', | |
| ) | |
| expect(() => getByTextInB('Jekyll')).toThrow( | |
| 'Unable to find an element with the text: Jekyll.', | |
| ) | |
| expect(() => getByTextInA('Hyde')).toThrow( | |
| 'Unable to find an element with the text: Hyde.', | |
| ) | |
| expect(() => getByTextInB('Hyde')).not.toThrow( | |
| 'Unable to find an element with the text: Hyde.', | |
| ) | |
| }) | |
| // https://github.com/testing-library/eslint-plugin-testing-library/issues/188 | |
| /* | |
| eslint | |
| testing-library/prefer-screen-queries: "off", | |
| */ | |