Skip to content

Commit 4f419ec

Browse files
committed
Merge branch 'main' into improve-render-options-jsdocs
2 parents 6a14455 + 071a6fd commit 4f419ec

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

.github/workflows/validate.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
if: ${{ !contains(github.head_ref, 'all-contributors') }}
1818
strategy:
1919
matrix:
20-
node: [12, 14, 16]
20+
# TODO: relax `'16.9.1'` to `16` once GitHub has 16.9.1 cached. 16.9.0 is broken due to https://github.com/nodejs/node/issues/40030
21+
node: [12, 14, '16.9.1']
2122
react: [latest, next, experimental]
2223
runs-on: ubuntu-latest
2324
steps:
@@ -37,6 +38,10 @@ jobs:
3738
with:
3839
useLockFile: false
3940

41+
# TODO: Can be removed if https://github.com/kentcdodds/kcd-scripts/pull/146 is released
42+
- name: Verify format (`npm run format` committed?)
43+
run: npm run format -- --check --no-write
44+
4045
# as requested by the React team :)
4146
# https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
4247
- name: ⚛️ Setup react

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"build:bundle:main": "dotenv -e .bundle.main.env kcd-scripts build -- --bundle --no-clean",
1515
"build:bundle:pure": "dotenv -e .bundle.main.env -e .bundle.pure.env kcd-scripts build -- --bundle --no-clean",
1616
"build:main": "kcd-scripts build --no-clean",
17+
"format": "kcd-scripts format",
1718
"lint": "kcd-scripts lint",
1819
"setup": "npm install && npm run validate -s",
1920
"test": "kcd-scripts test",

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {cleanup} from './pure'
55
// this ensures that tests run in isolation from each other
66
// if you don't like this then either import the `pure` module
77
// or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'.
8-
if (typeof process === "undefined" || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
8+
if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
99
// ignore teardown() in code coverage because Jest does not support it
1010
/* istanbul ignore else */
1111
if (typeof afterEach === 'function') {

types/index.d.ts

+18-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export * from '@testing-library/dom'
1313

1414
export type RenderResult<
1515
Q extends Queries = typeof queries,
16-
Container extends Element | DocumentFragment = HTMLElement
16+
Container extends Element | DocumentFragment = HTMLElement,
1717
> = {
1818
container: Container
1919
baseElement: Element
@@ -32,37 +32,42 @@ export type RenderResult<
3232

3333
export interface RenderOptions<
3434
Q extends Queries = typeof queries,
35-
Container extends Element | DocumentFragment = HTMLElement
35+
Container extends Element | DocumentFragment = HTMLElement,
3636
> {
37-
/** By default, React Testing Library will create a div and append that div to the document.body. Your React component will be rendered in the created div. If you provide your own HTMLElement container via this option,
37+
/**
38+
* By default, React Testing Library will create a div and append that div to the document.body. Your React component will be rendered in the created div. If you provide your own HTMLElement container via this option,
3839
* it will not be appended to the document.body automatically.
3940
*
4041
* For example: If you are unit testing a `<tbody>` element, it cannot be a child of a div. In this case, you can
4142
* specify a table as the render container.
42-
*
43+
*
4344
* @see https://testing-library.com/docs/react-testing-library/api/#container
4445
*/
4546
container?: Container
46-
/** Defaults to the container if the container is specified. Otherwise `document.body` is used for the default. This is used as
47+
/**
48+
* Defaults to the container if the container is specified. Otherwise `document.body` is used for the default. This is used as
4749
* the base element for the queries as well as what is printed when you use `debug()`.
48-
*
50+
*
4951
* @see https://testing-library.com/docs/react-testing-library/api/#baseelement
5052
*/
5153
baseElement?: Element
52-
/** If `hydrate` is set to `true`, then it will render with `ReactDOM.hydrate`. This may be useful if you are using server-side
54+
/**
55+
* If `hydrate` is set to `true`, then it will render with `ReactDOM.hydrate`. This may be useful if you are using server-side
5356
* rendering and use ReactDOM.hydrate to mount your components.
54-
*
57+
*
5558
* @see https://testing-library.com/docs/react-testing-library/api/#hydrate)
5659
*/
5760
hydrate?: boolean
58-
/** Queries to bind. Overrides the default set from DOM Testing Library unless merged.
59-
*
61+
/**
62+
* Queries to bind. Overrides the default set from DOM Testing Library unless merged.
63+
*
6064
* @see https://testing-library.com/docs/react-testing-library/api/#queries
6165
*/
6266
queries?: Q
63-
/** Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
67+
/**
68+
* Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
6469
* reusable custom render functions for common data providers. See setup for examples.
65-
*
70+
*
6671
* @see https://testing-library.com/docs/react-testing-library/api/#wrapper
6772
*/
6873
wrapper?: React.ComponentType
@@ -75,7 +80,7 @@ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
7580
*/
7681
export function render<
7782
Q extends Queries = typeof queries,
78-
Container extends Element | DocumentFragment = HTMLElement
83+
Container extends Element | DocumentFragment = HTMLElement,
7984
>(
8085
ui: React.ReactElement,
8186
options: RenderOptions<Q, Container>,

0 commit comments

Comments
 (0)