@koslibs/configs 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koslibs/configs",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Tool for api usage within react app",
5
5
  "main": "./index.js",
6
6
  "private": false,
@@ -13,6 +13,7 @@
13
13
  "eslint",
14
14
  "playwright",
15
15
  "prettier",
16
+ "rstest",
16
17
  "shared",
17
18
  "tsconfig",
18
19
  "vite",
@@ -60,6 +61,14 @@
60
61
  "./eslint/react": "./eslint/react.mjs",
61
62
  "./playwright": "./playwright/index.mjs",
62
63
  "./prettier": "./prettier/index.js",
64
+ "./rstest": {
65
+ "types": "./rstest/index.d.ts",
66
+ "default": "./rstest/index.mjs"
67
+ },
68
+ "./rstest/react": {
69
+ "types": "./rstest/react.d.ts",
70
+ "default": "./rstest/react.mjs"
71
+ },
63
72
  "./commitlint": "./commitlint/index.js",
64
73
  "./tsconfig": "./tsconfig/index.json",
65
74
  "./tsconfig/base": "./tsconfig/base.json",
@@ -67,24 +76,27 @@
67
76
  "./vite": "./vite/index.mjs"
68
77
  },
69
78
  "dependencies": {
70
- "@commitlint/cli": "20.3.1",
71
79
  "@commitlint/config-conventional": "20.3.1",
72
- "@eslint/eslintrc": "3.3.1",
73
80
  "@eslint/js": "9.36.0",
81
+ "@rsbuild/plugin-react": "2.1.1",
82
+ "@rstest/core": "0.12.2",
83
+ "@typescript-eslint/parser": "8.44.0",
74
84
  "eslint": "9.36.0",
75
85
  "eslint-config-prettier": "10.1.8",
76
86
  "eslint-plugin-import-helpers": "2.0.1",
77
87
  "eslint-plugin-prettier": "5.5.4",
78
88
  "eslint-plugin-storybook": "0.11.2",
79
89
  "globals": "16.4.0",
80
- "lefthook": "2.0.13",
90
+ "happy-dom": "20.14.5",
81
91
  "prettier": "3.6.2",
82
92
  "typescript": "5.7.2",
83
93
  "typescript-eslint": "8.44.0"
84
94
  },
85
95
  "devDependencies": {
86
- "@changesets/changelog-github": "^0.5.2",
87
- "@changesets/cli": "^2.29.8",
88
- "@types/node": "^24.4.0"
96
+ "@changesets/changelog-github": "0.5.2",
97
+ "@changesets/cli": "2.29.8",
98
+ "@commitlint/cli": "20.3.1",
99
+ "@types/node": "24.10.4",
100
+ "lefthook": "2.0.13"
89
101
  }
90
102
  }
@@ -0,0 +1,67 @@
1
+ # Rstest presets
2
+
3
+ ## Libraries (Node environment)
4
+
5
+ Install `@koslibs/configs` as a development dependency, then create `rstest.config.mjs`.
6
+ The package installs pinned versions of Rstest and its preset dependencies:
7
+
8
+ ```js
9
+ import { createRstestConfig } from '@koslibs/configs/rstest';
10
+
11
+ export default createRstestConfig({
12
+ include: ['src/**/*.test.ts'],
13
+ });
14
+ ```
15
+
16
+ ## React applications and component libraries
17
+
18
+ The React plugin and `happy-dom` are included in `@koslibs/configs` dependencies.
19
+ React and React DOM belong to the consuming project.
20
+
21
+ ```js
22
+ import { createReactRstestConfig } from '@koslibs/configs/rstest/react';
23
+
24
+ export default createReactRstestConfig({
25
+ include: ['src/**/*.test.{ts,tsx}'],
26
+ setupFiles: ['./rstest.setup.ts'],
27
+ });
28
+ ```
29
+
30
+ The React preset enables JSX through the React plugin and uses a simulated DOM.
31
+ It does not run browser, screenshot or Playwright tests. Keep their file patterns
32
+ separate from unit tests using `include` / `exclude` in the consuming project.
33
+
34
+ For Testing Library, install `@testing-library/react` and
35
+ `@testing-library/jest-dom` and create the optional setup file:
36
+
37
+ ```ts
38
+ import { afterEach, expect } from '@rstest/core';
39
+ import { cleanup } from '@testing-library/react';
40
+ import * as matchers from '@testing-library/jest-dom/matchers';
41
+
42
+ expect.extend(matchers);
43
+ afterEach(() => cleanup());
44
+ ```
45
+
46
+ ## Defaults and overrides
47
+
48
+ Both presets use explicit test imports (`globals: false`), clear mock histories,
49
+ restore spies between tests and fail when no tests are found. Coverage is opt-in
50
+ with `rstest run --coverage`; reports use text, HTML and LCOV. No coverage threshold
51
+ or automatic retry is imposed. Use `rstest run` in CI and `rstest` locally.
52
+
53
+ Factories follow the shared configuration merge convention: nested objects merge,
54
+ arrays append, and scalar values override. Additional React plugins append after
55
+ the built-in React plugin. Paths are relative to the consuming project. Configure
56
+ aliases, setup files, test patterns and coverage thresholds locally.
57
+
58
+ Rstest, the React plugin and `happy-dom` are installed for every consumer, with
59
+ exact versions managed by `@koslibs/configs`. Import the React preset through
60
+ `/rstest/react` explicitly. Package managers with strict dependency isolation may
61
+ still require a direct `@rstest/core` dependency when tests import from it or
62
+ project scripts invoke its CLI; use the same version declared by this package.
63
+
64
+ Types are verified with TypeScript's `moduleResolution: "Bundler"`. With the tested
65
+ Rstest 0.12.2 dependency tree, `NodeNext` and `skipLibCheck: false` report TS1479 in
66
+ Rsbuild's bundled plugin declarations. For configuration files using NodeNext,
67
+ `skipLibCheck: true` avoids checking those third-party declarations.
@@ -0,0 +1,5 @@
1
+ import type { RstestConfig } from '@rstest/core';
2
+
3
+ export declare const rstestConfig: RstestConfig;
4
+ export declare const createRstestConfig: (overrides?: RstestConfig) => RstestConfig;
5
+ export default rstestConfig;
@@ -0,0 +1,16 @@
1
+ import mergeConfig from '../shared/merge-config.mjs';
2
+
3
+ export const rstestConfig = {
4
+ testEnvironment: 'node',
5
+ globals: false,
6
+ clearMocks: true,
7
+ restoreMocks: true,
8
+ passWithNoTests: false,
9
+ coverage: {
10
+ reporters: ['text', 'html', 'lcov'],
11
+ },
12
+ };
13
+
14
+ export const createRstestConfig = (overrides = {}) => mergeConfig(rstestConfig, overrides);
15
+
16
+ export default rstestConfig;
@@ -0,0 +1,5 @@
1
+ import type { RstestConfig } from '@rstest/core';
2
+
3
+ export declare const reactRstestConfig: RstestConfig;
4
+ export declare const createReactRstestConfig: (overrides?: RstestConfig) => RstestConfig;
5
+ export default reactRstestConfig;
@@ -0,0 +1,14 @@
1
+ import { pluginReact } from '@rsbuild/plugin-react';
2
+
3
+ import { createRstestConfig } from './index.mjs';
4
+
5
+ export const createReactRstestConfig = (overrides = {}) =>
6
+ createRstestConfig({
7
+ testEnvironment: 'happy-dom',
8
+ ...overrides,
9
+ plugins: [pluginReact(), ...(overrides.plugins ?? [])],
10
+ });
11
+
12
+ export const reactRstestConfig = createReactRstestConfig();
13
+
14
+ export default reactRstestConfig;