From 0c823f934b5e1778d77f91b7ba4e6214652a6973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Rozs=C3=ADval?= Date: Fri, 3 Nov 2023 15:13:02 +0100 Subject: [PATCH] fix: make re-exports from testing library explicit --- .changeset/hungry-geese-destroy.md | 5 +++++ packages/testing-library/README.md | 9 +++------ .../testing-library/src/testing-library.ts | 18 +++++++++--------- packages/vitest-config/README.md | 4 ++-- pnpm-lock.yaml | 14 ++++++++------ 5 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 .changeset/hungry-geese-destroy.md diff --git a/.changeset/hungry-geese-destroy.md b/.changeset/hungry-geese-destroy.md new file mode 100644 index 0000000..b58ddd4 --- /dev/null +++ b/.changeset/hungry-geese-destroy.md @@ -0,0 +1,5 @@ +--- +'@apitree.cz/testing-library': patch +--- + +Make re-exports from Testing Library packages explicit. diff --git a/packages/testing-library/README.md b/packages/testing-library/README.md index 3202035..9b13a7c 100644 --- a/packages/testing-library/README.md +++ b/packages/testing-library/README.md @@ -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`: @@ -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(); ``` diff --git a/packages/testing-library/src/testing-library.ts b/packages/testing-library/src/testing-library.ts index 4b9f7ac..a106bbb 100644 --- a/packages/testing-library/src/testing-library.ts +++ b/packages/testing-library/src/testing-library.ts @@ -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'; @@ -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, >( @@ -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, >( @@ -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'; diff --git a/packages/vitest-config/README.md b/packages/vitest-config/README.md index 867c40a..2d2ccab 100644 --- a/packages/vitest-config/README.md +++ b/packages/vitest-config/README.md @@ -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'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9188d9e..da0ed6f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -118,7 +118,7 @@ importers: version: 3.0.0(@typescript-eslint/eslint-plugin@6.9.1)(eslint@8.52.0) eslint-plugin-vitest: specifier: ^0.3.8 - version: 0.3.8(@typescript-eslint/eslint-plugin@6.9.1)(eslint@8.52.0)(typescript@5.2.2)(vitest@0.34.6) + version: 0.3.9(@typescript-eslint/eslint-plugin@6.9.1)(eslint@8.52.0)(typescript@5.2.2)(vitest@0.34.6) vitest: specifier: ^0.34.6 version: 0.34.6(jsdom@22.1.0) @@ -2022,7 +2022,7 @@ packages: hasBin: true dependencies: caniuse-lite: 1.0.30001559 - electron-to-chromium: 1.4.574 + electron-to-chromium: 1.4.575 node-releases: 2.0.13 update-browserslist-db: 1.0.13(browserslist@4.22.1) @@ -2584,8 +2584,8 @@ packages: w-json: 1.3.10 dev: true - /electron-to-chromium@1.4.574: - resolution: {integrity: sha512-bg1m8L0n02xRzx4LsTTMbBPiUd9yIR+74iPtS/Ao65CuXvhVZHP0ym1kSdDG3yHFDXqHQQBKujlN1AQ8qZnyFg==} + /electron-to-chromium@1.4.575: + resolution: {integrity: sha512-kY2BGyvgAHiX899oF6xLXSIf99bAvvdPhDoJwG77nxCSyWYuRH6e9a9a3gpXBvCs6lj4dQZJkfnW2hdKWHEISg==} /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -3082,8 +3082,8 @@ packages: eslint-rule-composer: 0.3.0 dev: false - /eslint-plugin-vitest@0.3.8(@typescript-eslint/eslint-plugin@6.9.1)(eslint@8.52.0)(typescript@5.2.2)(vitest@0.34.6): - resolution: {integrity: sha512-MYQJzg3i+nLkaIQgjnOhtqHYIt0W6nErqAOKI3LTSQ2aOgcNHGYTwOhpnwGC1IXTvGWjKgAwb7rHwLpcHWHSAQ==} + /eslint-plugin-vitest@0.3.9(@typescript-eslint/eslint-plugin@6.9.1)(eslint@8.52.0)(typescript@5.2.2)(vitest@0.34.6): + resolution: {integrity: sha512-ZGrz8dWFlotM5dwrsMLP4VcY5MizwKNV4JTnY0VKdnuCZ+qeEUMHf1qd8kRGQA3tqLvXcV929wt2ANkduq2Pgw==} engines: {node: 14.x || >= 16} peerDependencies: '@typescript-eslint/eslint-plugin': '*' @@ -3092,6 +3092,8 @@ packages: peerDependenciesMeta: '@typescript-eslint/eslint-plugin': optional: true + vitest: + optional: true dependencies: '@typescript-eslint/eslint-plugin': 6.9.1(@typescript-eslint/parser@6.9.1)(eslint@8.52.0)(typescript@5.2.2) '@typescript-eslint/utils': 6.9.1(eslint@8.52.0)(typescript@5.2.2)