Skip to content

Commit

Permalink
fix: make re-exports from testing library explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
rozsival committed Nov 3, 2023
1 parent dcad4a0 commit 0c823f9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-geese-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@apitree.cz/testing-library': patch
---

Make re-exports from Testing Library packages explicit.
9 changes: 3 additions & 6 deletions packages/testing-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@
## Installation

```bash
pnpm add --save-dev @apitree.cz/testing-library @apitree.cz/vitest-config vitest
pnpm add --save-dev @apitree.cz/testing-library @testing-library/react vitest
```

## Usage

1. Create `vitest.config.ts` in your project root:

```typescript
export { config as default } from '@apitree.cz/vitest-config/react';
```
1. Setup [Vitest for React](../vitest-config/README.md#react) with `@apitree.cz/vitest-config`.

2. Create `tests/setup.ts`:

Expand All @@ -34,6 +30,7 @@ pnpm add --save-dev @apitree.cz/testing-library @apitree.cz/vitest-config vitest

```typescript jsx
import { createRenderers } from '@apitree.cz/testing-library';
export * from '@apitree.cz/testing-library';
export const { render, renderHook } = createRenderers();
```
Expand Down
18 changes: 9 additions & 9 deletions packages/testing-library/src/testing-library.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type {
Queries,
RenderHookOptions,
RenderOptions,
} from '@testing-library/react';
import type { Queries } from '@testing-library/dom';
import type { RenderHookOptions, RenderOptions } from '@testing-library/react';
import { render, renderHook } from '@testing-library/react';
import type { ReactElement } from 'react';

Expand All @@ -19,7 +16,7 @@ export const createRenderers = ({
},
}: CreateRenderersProps = {}) => {
const customRender = <
Q extends Queries,
Q extends Queries = Queries,
Container extends DocumentFragment | Element = HTMLElement,
BaseElement extends DocumentFragment | Element = Container,
>(
Expand All @@ -32,7 +29,7 @@ export const createRenderers = ({
const customRenderHook = <
Result,
Props,
Q extends Queries,
Q extends Queries = Queries,
Container extends DocumentFragment | Element = HTMLElement,
BaseElement extends DocumentFragment | Element = Container,
>(
Expand All @@ -48,5 +45,8 @@ export const createRenderers = ({
return { render: customRender, renderHook: customRenderHook };
};

export * from '@testing-library/react';
export * from '@testing-library/user-event';
export { render, renderHook } from '@testing-library/react';
export { screen, queries } from '@testing-library/dom';
export type { Screen, Queries } from '@testing-library/dom';
export { userEvent } from '@testing-library/user-event';
export type { UserEvent } from '@testing-library/user-event';
4 changes: 2 additions & 2 deletions packages/vitest-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export { react as default } from '@apitree.cz/vitest-config';

### Nest.js

⚠️ Nest.js projects are CJS by default, this configuration needs to be placed in `vitest.config.mjs` to interpret it as
ESM.
⚠️ _Nest.js projects are CJS by default. This configuration needs to be placed in `vitest.config.mjs` to interpret it as
ESM._

```typescript
export { nestjs as default } from '@apitree.cz/vitest-config';
Expand Down
14 changes: 8 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0c823f9

Please sign in to comment.