@regardio/dev 2.0.1 → 2.1.0
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/README.md +37 -45
- package/docs/en/README.md +12 -17
- package/docs/en/standards/api.md +1 -1
- package/docs/en/standards/coding.md +1 -1
- package/docs/en/standards/naming.md +1 -1
- package/docs/en/standards/react.md +1 -1
- package/docs/en/standards/sql.md +2 -2
- package/docs/en/standards/testing.md +1 -1
- package/docs/en/tools/biome.md +34 -31
- package/docs/en/tools/commitlint.md +23 -27
- package/docs/en/tools/dependencies.md +43 -46
- package/docs/en/tools/husky.md +24 -26
- package/docs/en/tools/markdownlint.md +19 -22
- package/docs/en/tools/playwright.md +25 -25
- package/docs/en/tools/releases.md +19 -11
- package/docs/en/tools/typescript.md +23 -25
- package/docs/en/tools/vitest.md +30 -30
- package/package.json +6 -7
- package/docs/en/agents.md +0 -57
- package/docs/en/standards/documentation.md +0 -173
- package/docs/en/standards/principles.md +0 -84
- package/docs/en/standards/writing.md +0 -119
package/docs/en/tools/husky.md
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
|
|
3
|
-
title: Husky
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
title: "Husky"
|
|
4
|
+
description: "Git hooks for quality gates — the last chance to catch something before it lands in history."
|
|
5
|
+
publishedAt: 2026-04-17
|
|
6
|
+
language: "en"
|
|
7
|
+
status: "published"
|
|
8
|
+
kind: "guide"
|
|
9
|
+
area: "dev"
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Husky
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Husky runs quality checks at commit time through git hooks. The configuration comes from `@regardio/dev`; bypass is available, but saved for real emergencies.
|
|
14
15
|
|
|
15
16
|
## Setup
|
|
16
17
|
|
|
17
|
-
Husky
|
|
18
|
+
Husky configures itself through the `prepare` script:
|
|
18
19
|
|
|
19
20
|
```json
|
|
20
21
|
{
|
|
@@ -28,63 +29,60 @@ This runs after `pnpm install` and sets up the `.husky` directory.
|
|
|
28
29
|
|
|
29
30
|
## Hooks
|
|
30
31
|
|
|
31
|
-
### commit-msg
|
|
32
|
+
### `commit-msg`
|
|
32
33
|
|
|
33
|
-
Validates commit messages against conventional
|
|
34
|
+
Validates commit messages against the conventional-commit format:
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
37
|
#!/bin/sh
|
|
37
38
|
pnpm lint-commit --edit $1
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
### pre-commit (optional)
|
|
41
|
+
### `pre-commit` (optional)
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
Runs linting before a commit lands:
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
46
|
#!/bin/sh
|
|
46
47
|
pnpm lint
|
|
47
48
|
```
|
|
48
49
|
|
|
49
|
-
## CLI
|
|
50
|
+
## CLI wrapper
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
`exec-husky` takes the place of `husky` directly — the wrapper handles monorepo scenarios that bare Husky doesn't.
|
|
52
53
|
|
|
53
|
-
## Bypassing
|
|
54
|
+
## Bypassing hooks
|
|
54
55
|
|
|
55
|
-
In rare
|
|
56
|
+
In the rare case where a hook truly has to be skipped:
|
|
56
57
|
|
|
57
58
|
```bash
|
|
58
59
|
git commit --no-verify -m "emergency fix"
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
Use sparingly
|
|
62
|
+
Use sparingly. A bypass that becomes habit stops being a bypass.
|
|
62
63
|
|
|
63
64
|
## Troubleshooting
|
|
64
65
|
|
|
65
66
|
### Hooks not running
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
Make sure Husky is installed:
|
|
68
69
|
|
|
69
70
|
```bash
|
|
70
71
|
pnpm install
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
Check that `.husky
|
|
74
|
+
Check that `.husky/` exists and carries the hook files.
|
|
74
75
|
|
|
75
76
|
### Permission denied
|
|
76
77
|
|
|
77
|
-
Make hooks executable:
|
|
78
|
+
Make the hooks executable:
|
|
78
79
|
|
|
79
80
|
```bash
|
|
80
81
|
chmod +x .husky/*
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
Related
|
|
84
|
-
|
|
85
|
-
- [Commitlint](./commitlint.md) — Commit message validation
|
|
86
|
-
- [Biome](./biome.md) — Linting and formatting
|
|
87
|
-
|
|
88
|
-
### Resources
|
|
84
|
+
## Related
|
|
89
85
|
|
|
86
|
+
- [Commitlint](./commitlint.md) — commit-message validation
|
|
87
|
+
- [Biome](./biome.md) — linting and formatting
|
|
90
88
|
- [Husky Documentation](https://typicode.github.io/husky/)
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
|
|
3
|
-
title: Markdownlint
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
title: "Markdownlint"
|
|
4
|
+
description: "Linting and light formatting for Markdown, so prose stays as consistent as the code alongside it."
|
|
5
|
+
publishedAt: 2026-04-17
|
|
6
|
+
language: "en"
|
|
7
|
+
status: "published"
|
|
8
|
+
kind: "guide"
|
|
9
|
+
area: "dev"
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Markdownlint
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Markdownlint checks Markdown structure and formatting. The rules live in `@regardio/dev`; projects reach for the `lint-md` wrapper rather than calling the tool directly.
|
|
14
15
|
|
|
15
16
|
## Configuration
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
A `.markdownlint.json` at the package root:
|
|
18
19
|
|
|
19
20
|
```json
|
|
20
21
|
{
|
|
@@ -33,16 +34,16 @@ Create `.markdownlint.json` in your package root:
|
|
|
33
34
|
}
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
## CLI
|
|
37
|
+
## CLI wrapper
|
|
37
38
|
|
|
38
|
-
Use `lint-md`
|
|
39
|
+
Use `lint-md` rather than `markdownlint-cli2` directly:
|
|
39
40
|
|
|
40
41
|
```bash
|
|
41
42
|
lint-md "**/*.md" # Check all Markdown files
|
|
42
|
-
lint-md --fix "**/*.md" # Auto-fix
|
|
43
|
+
lint-md --fix "**/*.md" # Auto-fix what can be auto-fixed
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
## Key
|
|
46
|
+
## Key rules
|
|
46
47
|
|
|
47
48
|
| Rule | Description |
|
|
48
49
|
|------|-------------|
|
|
@@ -52,11 +53,11 @@ lint-md --fix "**/*.md" # Auto-fix issues
|
|
|
52
53
|
| MD012 | No multiple consecutive blank lines |
|
|
53
54
|
| MD022 | Headings surrounded by blank lines |
|
|
54
55
|
| MD032 | Lists surrounded by blank lines |
|
|
55
|
-
| MD041 | First line
|
|
56
|
+
| MD041 | First line is a top-level heading |
|
|
56
57
|
|
|
57
|
-
## Ignoring
|
|
58
|
+
## Ignoring rules
|
|
58
59
|
|
|
59
|
-
For specific
|
|
60
|
+
For a specific file or section, inline comments do the job:
|
|
60
61
|
|
|
61
62
|
```markdown
|
|
62
63
|
<!-- markdownlint-disable MD013 -->
|
|
@@ -64,7 +65,7 @@ This line can be very long without triggering a warning.
|
|
|
64
65
|
<!-- markdownlint-enable MD013 -->
|
|
65
66
|
```
|
|
66
67
|
|
|
67
|
-
Or
|
|
68
|
+
Or, per-file, through the config:
|
|
68
69
|
|
|
69
70
|
```json
|
|
70
71
|
{
|
|
@@ -73,12 +74,8 @@ Or in config for specific files:
|
|
|
73
74
|
}
|
|
74
75
|
```
|
|
75
76
|
|
|
76
|
-
Related
|
|
77
|
-
|
|
78
|
-
- [Documentation](../standards/documentation.md) — Structure and conventions
|
|
79
|
-
- [Biome](./biome.md) — Fast, unified linting and formatting
|
|
80
|
-
|
|
81
|
-
### Resources
|
|
77
|
+
## Related
|
|
82
78
|
|
|
79
|
+
- [Biome](./biome.md) — linting and formatting on the code side
|
|
83
80
|
- [Markdownlint Rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md)
|
|
84
81
|
- [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2)
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
|
|
3
|
-
title: Playwright
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
title: "Playwright"
|
|
4
|
+
description: "End-to-end testing for web applications — for the flows users actually feel."
|
|
5
|
+
publishedAt: 2026-04-17
|
|
6
|
+
language: "en"
|
|
7
|
+
status: "published"
|
|
8
|
+
kind: "guide"
|
|
9
|
+
area: "dev"
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Playwright
|
|
12
13
|
|
|
13
|
-
End-to-end testing for web applications.
|
|
14
|
+
End-to-end testing for web applications. Playwright covers the flows a user actually moves through; it isn't a stand-in for unit or integration tests, and tests read best when they reach for accessible, role-based selectors.
|
|
14
15
|
|
|
15
16
|
## Configuration
|
|
16
17
|
|
|
@@ -39,16 +40,16 @@ export default defineConfig(
|
|
|
39
40
|
}
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
## Running
|
|
43
|
+
## Running tests
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
46
|
pnpm test:e2e # Run all E2E tests
|
|
46
47
|
pnpm playwright test --ui # Interactive UI mode
|
|
47
|
-
pnpm playwright test --debug # Debug mode with inspector
|
|
48
|
-
pnpm playwright show-report # View HTML report
|
|
48
|
+
pnpm playwright test --debug # Debug mode with the inspector
|
|
49
|
+
pnpm playwright show-report # View the HTML report
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
## Writing
|
|
52
|
+
## Writing tests
|
|
52
53
|
|
|
53
54
|
```typescript
|
|
54
55
|
import { test, expect } from '@playwright/test';
|
|
@@ -64,23 +65,25 @@ test('user can submit contact form', async ({ page }) => {
|
|
|
64
65
|
});
|
|
65
66
|
```
|
|
66
67
|
|
|
67
|
-
##
|
|
68
|
+
## Patterns that hold up
|
|
68
69
|
|
|
69
|
-
###
|
|
70
|
+
### Role-based selectors
|
|
71
|
+
|
|
72
|
+
Selectors that match roles and labels survive UI tidying — selectors that pin to CSS classes don't.
|
|
70
73
|
|
|
71
74
|
```typescript
|
|
72
|
-
//
|
|
75
|
+
// reads well — accessible and resilient
|
|
73
76
|
await page.getByRole('button', { name: 'Submit' });
|
|
74
77
|
await page.getByLabel('Email');
|
|
75
78
|
|
|
76
|
-
//
|
|
79
|
+
// brittle — breaks on any class rename
|
|
77
80
|
await page.locator('.submit-btn');
|
|
78
81
|
await page.locator('#email-input');
|
|
79
82
|
```
|
|
80
83
|
|
|
81
|
-
###
|
|
84
|
+
### `data-test` attributes
|
|
82
85
|
|
|
83
|
-
For elements without accessible
|
|
86
|
+
For elements without a natural accessible name:
|
|
84
87
|
|
|
85
88
|
```tsx
|
|
86
89
|
<div data-test="user-avatar">{avatar}</div>
|
|
@@ -90,9 +93,9 @@ For elements without accessible names:
|
|
|
90
93
|
await page.getByTestId('user-avatar');
|
|
91
94
|
```
|
|
92
95
|
|
|
93
|
-
### Page
|
|
96
|
+
### Page objects for larger flows
|
|
94
97
|
|
|
95
|
-
|
|
98
|
+
When a page has a handful of interactions worth naming, a small page object keeps tests readable:
|
|
96
99
|
|
|
97
100
|
```typescript
|
|
98
101
|
class LoginPage {
|
|
@@ -106,12 +109,9 @@ class LoginPage {
|
|
|
106
109
|
}
|
|
107
110
|
```
|
|
108
111
|
|
|
109
|
-
Related
|
|
110
|
-
|
|
111
|
-
- [Testing Approach](../standards/testing.md) — Testing philosophy and patterns for Regardio projects
|
|
112
|
-
- [Vitest](./vitest.md) — Unit and integration testing for TypeScript projects
|
|
113
|
-
|
|
114
|
-
### Resources
|
|
112
|
+
## Related
|
|
115
113
|
|
|
114
|
+
- [Testing](../standards/testing.md) — testing philosophy and layers
|
|
115
|
+
- [Vitest](./vitest.md) — unit and integration testing
|
|
116
116
|
- [Playwright Documentation](https://playwright.dev/)
|
|
117
117
|
- [Best Practices](https://playwright.dev/docs/best-practices)
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
|
|
3
|
-
title: Release Workflow
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
title: "Release Workflow"
|
|
4
|
+
description: "Branch-based release workflow for Regardio packages — main → staging → production, driven by Changesets."
|
|
5
|
+
publishedAt: 2026-04-17
|
|
6
|
+
language: "en"
|
|
7
|
+
status: "published"
|
|
8
|
+
kind: "guide"
|
|
9
|
+
area: "dev"
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Release Workflow
|
|
12
13
|
|
|
13
|
-
Branch-based release workflow for Regardio packages. `main` → `staging` → `production`.
|
|
14
|
+
Branch-based release workflow for Regardio packages. `main` → `staging` → `production`. Changesets carry the version bumps; quality gates run locally before any branch promotion. Nothing broken reaches a shared branch.
|
|
14
15
|
|
|
15
16
|
## Overview
|
|
16
17
|
|
|
@@ -209,13 +210,20 @@ Install `@regardio/dev` and:
|
|
|
209
210
|
git checkout main
|
|
210
211
|
```
|
|
211
212
|
|
|
212
|
-
4. **Copy the release workflow** for your forge
|
|
213
|
+
4. **Copy the release workflow** for your forge. A GitHub Actions template ships with `@regardio/dev`; Forgejo Actions accepts the same workflow syntax with minimal changes.
|
|
213
214
|
|
|
214
215
|
```bash
|
|
216
|
+
# GitHub
|
|
215
217
|
mkdir -p .github/workflows
|
|
216
218
|
cp node_modules/@regardio/dev/templates/github/release.yml .github/workflows/release.yml
|
|
219
|
+
|
|
220
|
+
# Forgejo / Codeberg
|
|
221
|
+
mkdir -p .forgejo/workflows
|
|
222
|
+
cp node_modules/@regardio/dev/templates/github/release.yml .forgejo/workflows/release.yml
|
|
217
223
|
```
|
|
218
224
|
|
|
225
|
+
For other CI systems, treat the template as a reference: the workflow installs dependencies, builds, runs `pnpm changeset publish`, and pushes tags on every push to `production`.
|
|
226
|
+
|
|
219
227
|
5. **First publish of any new package must be done locally**:
|
|
220
228
|
|
|
221
229
|
```bash
|
|
@@ -236,7 +244,7 @@ pnpm test # Must succeed
|
|
|
236
244
|
|
|
237
245
|
Packages that should never be published to npm must set `"private": true` in `package.json`. `changeset publish` skips them automatically. The git flow (`ship-staging`, `ship-production`, `ship-hotfix`) works identically for private packages — changesets, version bumps, and branch promotion all continue as normal; only the npm publish step is skipped.
|
|
238
246
|
|
|
239
|
-
Related
|
|
247
|
+
## Related
|
|
240
248
|
|
|
241
|
-
- [
|
|
242
|
-
- [Commitlint](./commitlint.md) —
|
|
249
|
+
- [Commits](../standards/commits.md) — conventional commits and changelog generation
|
|
250
|
+
- [Commitlint](./commitlint.md) — commit-message validation
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
|
|
3
|
-
title: TypeScript Configuration
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
title: "TypeScript Configuration"
|
|
4
|
+
description: "Shared, strict TypeScript presets for Regardio projects, with enough knobs for each shape of project."
|
|
5
|
+
publishedAt: 2026-04-17
|
|
6
|
+
language: "en"
|
|
7
|
+
status: "published"
|
|
8
|
+
kind: "guide"
|
|
9
|
+
area: "dev"
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# TypeScript Configuration
|
|
12
13
|
|
|
13
|
-
Strict shared TypeScript presets for Regardio projects.
|
|
14
|
+
Strict, shared TypeScript presets for Regardio projects. Extending from `@regardio/dev` is the well-worn path; rebuilding a config from scratch is usually a path to drift.
|
|
14
15
|
|
|
15
16
|
## Presets
|
|
16
17
|
|
|
17
|
-
| Preset | Use
|
|
18
|
+
| Preset | Use case |
|
|
18
19
|
|--------|----------|
|
|
19
20
|
| `@regardio/dev/typescript/base` | Node.js packages, libraries |
|
|
20
21
|
| `@regardio/dev/typescript/react` | React applications and components |
|
|
@@ -22,7 +23,7 @@ Strict shared TypeScript presets for Regardio projects. Extend from `@regardio/d
|
|
|
22
23
|
|
|
23
24
|
## Configuration
|
|
24
25
|
|
|
25
|
-
### tsconfig.json
|
|
26
|
+
### `tsconfig.json`
|
|
26
27
|
|
|
27
28
|
```json
|
|
28
29
|
{
|
|
@@ -40,9 +41,9 @@ For React projects:
|
|
|
40
41
|
}
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
### tsconfig.build.json
|
|
44
|
+
### `tsconfig.build.json`
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
A separate build config for production output:
|
|
46
47
|
|
|
47
48
|
```json
|
|
48
49
|
{
|
|
@@ -55,15 +56,15 @@ Separate build config for production output:
|
|
|
55
56
|
}
|
|
56
57
|
```
|
|
57
58
|
|
|
58
|
-
## Strict
|
|
59
|
+
## Strict settings
|
|
59
60
|
|
|
60
|
-
The base config
|
|
61
|
+
The base config turns on strict type-checking across the board:
|
|
61
62
|
|
|
62
|
-
- `strict: true`
|
|
63
|
-
- `noUncheckedIndexedAccess: true`
|
|
64
|
-
- `exactOptionalPropertyTypes: true`
|
|
65
|
-
- `noImplicitReturns: true`
|
|
66
|
-
- `noFallthroughCasesInSwitch: true`
|
|
63
|
+
- `strict: true` — every strict type-checking option
|
|
64
|
+
- `noUncheckedIndexedAccess: true` — adds `undefined` to index signatures
|
|
65
|
+
- `exactOptionalPropertyTypes: true` — distinguishes `undefined` from missing
|
|
66
|
+
- `noImplicitReturns: true` — every code path returns a value
|
|
67
|
+
- `noFallthroughCasesInSwitch: true` — prevents switch-fallthrough surprises
|
|
67
68
|
|
|
68
69
|
## Scripts
|
|
69
70
|
|
|
@@ -76,14 +77,11 @@ The base config enables strict TypeScript checking:
|
|
|
76
77
|
}
|
|
77
78
|
```
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
Running `typecheck` during development catches type errors at the moment they appear, rather than at the moment they break something.
|
|
80
81
|
|
|
81
|
-
Related
|
|
82
|
-
|
|
83
|
-
- [Biome](./biome.md) — Linting and formatting
|
|
84
|
-
- [Vitest](./vitest.md) — Unit and integration testing for TypeScript projects
|
|
85
|
-
|
|
86
|
-
### Resources
|
|
82
|
+
## Related
|
|
87
83
|
|
|
84
|
+
- [Biome](./biome.md) — linting and formatting
|
|
85
|
+
- [Vitest](./vitest.md) — unit and integration testing
|
|
88
86
|
- [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/)
|
|
89
87
|
- [tsconfig Reference](https://www.typescriptlang.org/tsconfig)
|
package/docs/en/tools/vitest.md
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
|
|
3
|
-
title: Vitest
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
title: "Vitest"
|
|
4
|
+
description: "Unit and integration testing for TypeScript projects — Vite-native, TypeScript-first."
|
|
5
|
+
publishedAt: 2026-04-17
|
|
6
|
+
language: "en"
|
|
7
|
+
status: "published"
|
|
8
|
+
kind: "guide"
|
|
9
|
+
area: "dev"
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Vitest
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Vitest runs unit and integration tests across Regardio's TypeScript projects. It's Vite-native, TypeScript-first, and configured centrally through `@regardio/dev`.
|
|
14
15
|
|
|
15
|
-
## Coverage
|
|
16
|
+
## Coverage thresholds
|
|
16
17
|
|
|
17
|
-
Library packages
|
|
18
|
+
Library packages meet a minimum coverage floor before publishing:
|
|
18
19
|
|
|
19
20
|
| Metric | Minimum |
|
|
20
21
|
|--------|---------|
|
|
@@ -23,11 +24,11 @@ Library packages must meet minimum coverage thresholds before publishing:
|
|
|
23
24
|
| **Functions** | 80% |
|
|
24
25
|
| **Lines** | 80% |
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
The floor is enforced at three gates:
|
|
27
28
|
|
|
28
|
-
1. **`pnpm report`**
|
|
29
|
-
2. **`ship-staging`**
|
|
30
|
-
3. **GitHub Actions**
|
|
29
|
+
1. **`pnpm report`** — fails if coverage drops below the floor
|
|
30
|
+
2. **`ship-staging`** — runs the coverage check before deploying to staging
|
|
31
|
+
3. **GitHub Actions** — runs the coverage check before publishing to npm
|
|
31
32
|
|
|
32
33
|
To check coverage locally:
|
|
33
34
|
|
|
@@ -35,9 +36,11 @@ To check coverage locally:
|
|
|
35
36
|
pnpm report
|
|
36
37
|
```
|
|
37
38
|
|
|
39
|
+
The floor is a minimum, not a target — the aim is meaningful tests, not arithmetic.
|
|
40
|
+
|
|
38
41
|
## Configuration
|
|
39
42
|
|
|
40
|
-
### Node.js
|
|
43
|
+
### Node.js packages
|
|
41
44
|
|
|
42
45
|
```typescript
|
|
43
46
|
// vitest.config.ts
|
|
@@ -47,7 +50,7 @@ import { vitestNodeConfig } from '@regardio/dev/vitest/node';
|
|
|
47
50
|
export default defineConfig({ test: vitestNodeConfig });
|
|
48
51
|
```
|
|
49
52
|
|
|
50
|
-
### React
|
|
53
|
+
### React packages
|
|
51
54
|
|
|
52
55
|
```typescript
|
|
53
56
|
// vitest.config.ts
|
|
@@ -74,14 +77,14 @@ Required devDependencies:
|
|
|
74
77
|
```json
|
|
75
78
|
{
|
|
76
79
|
"devDependencies": {
|
|
77
|
-
"@regardio/dev": "^
|
|
80
|
+
"@regardio/dev": "^2.0.0",
|
|
78
81
|
"@vitest/coverage-v8": "^4.0.0",
|
|
79
82
|
"vitest": "^4.0.0"
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
```
|
|
83
86
|
|
|
84
|
-
## Running
|
|
87
|
+
## Running tests
|
|
85
88
|
|
|
86
89
|
```bash
|
|
87
90
|
pnpm test:unit # Run all tests once
|
|
@@ -90,20 +93,20 @@ pnpm vitest --ui # Visual UI
|
|
|
90
93
|
pnpm vitest --coverage # With coverage report
|
|
91
94
|
```
|
|
92
95
|
|
|
93
|
-
## Test
|
|
96
|
+
## Test file naming
|
|
94
97
|
|
|
95
98
|
- Unit tests: `*.test.ts` or `*.test.tsx`
|
|
96
|
-
- Place tests next to source
|
|
99
|
+
- Place tests next to the source file, or in a `__tests__` directory
|
|
97
100
|
|
|
98
|
-
## Writing
|
|
101
|
+
## Writing tests
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
Arrange, Act, Assert — a rhythm that reads well in almost every test:
|
|
101
104
|
|
|
102
105
|
```typescript
|
|
103
106
|
import { describe, it, expect } from 'vitest';
|
|
104
107
|
|
|
105
108
|
describe('calculateTotal', () => {
|
|
106
|
-
it('
|
|
109
|
+
it('applies the discount correctly', () => {
|
|
107
110
|
// Arrange
|
|
108
111
|
const items = [{ price: 100 }, { price: 50 }];
|
|
109
112
|
const discount = 0.1;
|
|
@@ -117,7 +120,7 @@ describe('calculateTotal', () => {
|
|
|
117
120
|
});
|
|
118
121
|
```
|
|
119
122
|
|
|
120
|
-
## React
|
|
123
|
+
## React component testing
|
|
121
124
|
|
|
122
125
|
```typescript
|
|
123
126
|
import { render, screen } from '@testing-library/react';
|
|
@@ -134,13 +137,10 @@ it('calls onClick when clicked', async () => {
|
|
|
134
137
|
});
|
|
135
138
|
```
|
|
136
139
|
|
|
137
|
-
Related
|
|
138
|
-
|
|
139
|
-
- [Testing Approach](../standards/testing.md) — Testing philosophy and patterns for Regardio projects
|
|
140
|
-
- [Playwright](./playwright.md) — End-to-end testing for web applications
|
|
141
|
-
- [TypeScript Configuration](./typescript.md) — TypeScript setup and configuration for Regardio projects
|
|
142
|
-
|
|
143
|
-
### Resources
|
|
140
|
+
## Related
|
|
144
141
|
|
|
142
|
+
- [Testing](../standards/testing.md) — testing philosophy and layers
|
|
143
|
+
- [Playwright](./playwright.md) — end-to-end testing
|
|
144
|
+
- [TypeScript](./typescript.md) — TypeScript configuration
|
|
145
145
|
- [Vitest Documentation](https://vitest.dev/)
|
|
146
146
|
- [Testing Library](https://testing-library.com/)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "@regardio/dev",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Regardio development presets: biome, typescript, commitlint, markdownlint, vitest, playwright, sqlfluff, husky, and GitLab-flow ship tooling",
|
|
7
7
|
"keywords": [
|
|
@@ -71,10 +71,9 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@total-typescript/ts-reset": "0.6.1",
|
|
73
73
|
"@types/node": "25.6.0",
|
|
74
|
-
"@vitest/coverage-v8": "4.1.
|
|
75
|
-
"tsdown": "0.21.
|
|
76
|
-
"vitest": "4.1.
|
|
77
|
-
"@regardio/dev": "2.0.1"
|
|
74
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
75
|
+
"tsdown": "0.21.10",
|
|
76
|
+
"vitest": "4.1.5"
|
|
78
77
|
},
|
|
79
78
|
"peerDependencies": {
|
|
80
79
|
"@biomejs/biome": ">=2",
|
|
@@ -100,11 +99,11 @@
|
|
|
100
99
|
"dev": "tsdown --watch",
|
|
101
100
|
"fix": "run-s fix:pkg fix:md fix:biome",
|
|
102
101
|
"fix:biome": "biome check --write --unsafe .",
|
|
103
|
-
"fix:md": "markdownlint-cli2 --fix",
|
|
102
|
+
"fix:md": "markdownlint-cli2 --config ../../.markdownlint-cli2.jsonc --fix",
|
|
104
103
|
"fix:pkg": "sort-package-json",
|
|
105
104
|
"lint": "run-s lint:md lint:biome",
|
|
106
105
|
"lint:biome": "biome check .",
|
|
107
|
-
"lint:md": "markdownlint-cli2",
|
|
106
|
+
"lint:md": "markdownlint-cli2 --config ../../.markdownlint-cli2.jsonc",
|
|
108
107
|
"lint:pkg": "sort-package-json --check",
|
|
109
108
|
"test": "run-p test:*",
|
|
110
109
|
"test:e2e": "echo 'no e2e tests'",
|