@cosyte/vitest-config 0.0.1
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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/index.d.ts +19 -0
- package/index.js +45 -0
- package/package.json +41 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@cosyte/vitest-config` are documented here, following
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions are managed with Changesets;
|
|
5
|
+
this file is hand-maintained. The package stays on the **`0.0.x`-until-first-alpha** ladder.
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Initial release: `cosyteVitest(opts)` — v8 coverage, standard excludes, and enabled, gating
|
|
12
|
+
per-directory thresholds at >= 90.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cosyte
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @cosyte/vitest-config
|
|
2
|
+
|
|
3
|
+
Shared [Vitest](https://vitest.dev) config for the `@cosyte/*` packages: v8 coverage with
|
|
4
|
+
`text` / `html` / `lcov` reporters, the standard excludes (barrels, fixtures, generated code,
|
|
5
|
+
declarations), and **enabled, gating** per-directory thresholds at **>= 90**.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add -D @cosyte/vitest-config vitest @vitest/coverage-v8
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`vitest` and `@vitest/coverage-v8` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
`vitest.config.ts`:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { cosyteVitest } from "@cosyte/vitest-config";
|
|
21
|
+
|
|
22
|
+
export default cosyteVitest({
|
|
23
|
+
coverageDirs: ["parser", "model", "serialize", "helpers"],
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Each entry in `coverageDirs` adds a per-directory `src/<dir>/**` gate at >= 90 on top of the global
|
|
28
|
+
gate. Use `coverageThresholds` to add or override specific keys, and `test` for any other Vitest
|
|
29
|
+
options.
|
|
30
|
+
|
|
31
|
+
Part of [cosyte/config](https://github.com/cosyte/config) — one enforced toolchain for the `@cosyte/*`
|
|
32
|
+
suite.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UserConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
/** Options for {@link cosyteVitest}. */
|
|
4
|
+
export interface CosyteVitestOptions {
|
|
5
|
+
/** `src/<dir>` subdirectories to gate per-directory at >= 90 (e.g. `["parser", "model"]`). */
|
|
6
|
+
coverageDirs?: string[];
|
|
7
|
+
/** Extra or overriding `coverage.thresholds` keys, merged over the defaults. */
|
|
8
|
+
coverageThresholds?: Record<string, unknown>;
|
|
9
|
+
/** Extra Vitest `test` options, merged last. */
|
|
10
|
+
test?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Standard Vitest config for `@cosyte/*` packages (v8 coverage, per-directory >= 90 gates).
|
|
15
|
+
*
|
|
16
|
+
* @param opts - Options.
|
|
17
|
+
* @returns The Vitest config.
|
|
18
|
+
*/
|
|
19
|
+
export declare function cosyteVitest(opts?: CosyteVitestOptions): UserConfig;
|
package/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
const GATE = { lines: 90, branches: 90, functions: 90, statements: 90 };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Standard Vitest config for `@cosyte/*` packages: v8 coverage with `text`/`html`/`lcov` reporters,
|
|
7
|
+
* the standard excludes (barrels, fixtures, generated, declarations), and **enabled, gating**
|
|
8
|
+
* per-directory thresholds at >= 90. List your source subdirectories in `coverageDirs` to get a
|
|
9
|
+
* per-directory gate on each (on top of the global gate).
|
|
10
|
+
*
|
|
11
|
+
* @param {object} [opts] - Options.
|
|
12
|
+
* @param {string[]} [opts.coverageDirs] - `src/<dir>` subdirs to gate per-directory (e.g. `["parser"]`).
|
|
13
|
+
* @param {Record<string, unknown>} [opts.coverageThresholds] - Extra/override `coverage.thresholds` keys.
|
|
14
|
+
* @param {Record<string, unknown>} [opts.test] - Extra Vitest `test` options, merged last.
|
|
15
|
+
* @returns {import("vitest/config").UserConfig} The Vitest config.
|
|
16
|
+
* @example
|
|
17
|
+
* // vitest.config.ts
|
|
18
|
+
* import { cosyteVitest } from "@cosyte/vitest-config";
|
|
19
|
+
* export default cosyteVitest({ coverageDirs: ["parser", "model", "serialize", "helpers"] });
|
|
20
|
+
*/
|
|
21
|
+
export function cosyteVitest(opts = {}) {
|
|
22
|
+
const perDir = Object.fromEntries(
|
|
23
|
+
(opts.coverageDirs ?? []).map((dir) => [`src/${dir}/**`, { ...GATE }]),
|
|
24
|
+
);
|
|
25
|
+
return defineConfig({
|
|
26
|
+
test: {
|
|
27
|
+
coverage: {
|
|
28
|
+
provider: "v8",
|
|
29
|
+
reporter: ["text", "html", "lcov"],
|
|
30
|
+
reportsDirectory: "./coverage",
|
|
31
|
+
include: ["src/**/*.ts"],
|
|
32
|
+
exclude: [
|
|
33
|
+
"**/*.test.ts",
|
|
34
|
+
"**/*.spec.ts",
|
|
35
|
+
"**/index.ts",
|
|
36
|
+
"**/*.d.ts",
|
|
37
|
+
"**/__fixtures__/**",
|
|
38
|
+
"**/generated/**",
|
|
39
|
+
],
|
|
40
|
+
thresholds: { ...GATE, ...perDir, ...(opts.coverageThresholds ?? {}) },
|
|
41
|
+
},
|
|
42
|
+
...(opts.test ?? {}),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cosyte/vitest-config",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Shared Vitest config (v8 coverage, per-directory >=90 gates) for @cosyte/* packages.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vitest",
|
|
7
|
+
"coverage",
|
|
8
|
+
"test",
|
|
9
|
+
"cosyte"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/cosyte/config/tree/main/packages/vitest-config#readme",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/cosyte/config.git",
|
|
15
|
+
"directory": "packages/vitest-config"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Cosyte <hello@cosyte.com> (https://cosyte.com)",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "index.js",
|
|
21
|
+
"types": "index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./index.d.ts",
|
|
25
|
+
"default": "./index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"index.js",
|
|
30
|
+
"index.d.ts",
|
|
31
|
+
"README.md",
|
|
32
|
+
"CHANGELOG.md"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
39
|
+
"vitest": "^4.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|