@pam-ai/pam-vitest-config 0.0.0-stage → 2.0.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 CHANGED
@@ -1,3 +1,161 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <h1>@pam-ai/pam-vitest-config</h1>
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ <p>This package provides the shareable Pam AI vitest configuration with Vitest 4.0</p>
5
+ </div>
6
+
7
+ ## Table of Contents
8
+
9
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
10
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
11
+
12
+ - [Installation](#installation)
13
+ - [Usage](#usage)
14
+ - [Vitest Configuration](#vitest-configuration)
15
+ - [ESLint Configuration](#eslint-configuration)
16
+ - [Prettier Configuration](#prettier-configuration)
17
+ - [Other configs](#other-configs)
18
+ - [Configuration Examples](#configuration-examples)
19
+ - [Versioning](#versioning)
20
+
21
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
22
+
23
+ ## Develop
24
+
25
+ ### Pre Requisites
26
+
27
+ To install dependencies and activate pre commit hooks
28
+
29
+ ```bash
30
+ npm install
31
+ npx husky install
32
+ ```
33
+
34
+ ### Debug
35
+
36
+ To run index.js and test the code in there
37
+
38
+ ```bash
39
+ npm run debug
40
+ ```
41
+
42
+ ## Prerequisites
43
+
44
+ **Node.js**: >=22 (tested on v22.14.0)
45
+
46
+ **Required peer dependencies**:
47
+
48
+ - `vitest` >= 4.0.0
49
+
50
+ This package and its dependencies are installed directly from GitHub repositories. No special npm configuration is required.
51
+
52
+ ## Installation
53
+
54
+ Add this package to your `package.json` as a `dependency`:
55
+
56
+ ```json
57
+ {
58
+ "dependencies": {
59
+ "@pam-ai/pam-vitest-config": "2.0.0"
60
+ }
61
+ }
62
+ ```
63
+
64
+ Or reference a specific version/tag:
65
+
66
+ ```json
67
+ {
68
+ "dependencies": {
69
+ "@pam-ai/pam-vitest-config": "2.0.0"
70
+ }
71
+ }
72
+ ```
73
+
74
+ Then run `npm install`.
75
+
76
+ This package also includes linting and formatting configurations from `@pam-ai/pam-eslint-config`.
77
+
78
+ ## Usage
79
+
80
+ ### Vitest Configuration
81
+
82
+ Create a vitest.config.ts file with following contents in the root folder of your project.
83
+
84
+ ```javascript
85
+ /// <reference types="vitest" />
86
+
87
+ import { defineConfig } from 'vitest/config';
88
+ import pamVitestConfig from '@pam-ai/pam-vitest-config';
89
+
90
+ // This configuration should be enough for most of the cases
91
+ // it will automatically detect if react is installed,
92
+ // and return an object configured for react testing library to be used as the testing suite
93
+
94
+ // Create an excludes array, to exclude folders from being tested and from coverage to be collected from them
95
+ const excludes = [
96
+ '**/node_modules/**',
97
+ '**/dist/**',
98
+ '**/target/**',
99
+ '**/build/**',
100
+ './.husky/**',
101
+ './.github/**',
102
+ ];
103
+
104
+ export default defineConfig({
105
+ ...pamVitestConfig,
106
+ test: {
107
+ ...pamVitestConfig.test,
108
+ exclude: excludes,
109
+ coverage: {
110
+ ...pamVitestConfig.test.coverage,
111
+ exclude: excludes,
112
+ },
113
+ },
114
+ });
115
+ ```
116
+
117
+ ### ESLint Configuration
118
+
119
+ This package uses ESLint 9 with flat config format. Create an `eslint.config.js` file in your project root:
120
+
121
+ ```javascript
122
+ module.exports = require('@pam-ai/pam-eslint-config');
123
+ ```
124
+
125
+ ### Prettier Configuration
126
+
127
+ Create a `.prettierrc.js` file in your project root:
128
+
129
+ ```javascript
130
+ module.exports = {
131
+ ...require('@pam-ai/pam-eslint-config/prettierConfig'),
132
+ };
133
+ ```
134
+
135
+ ## Other configs
136
+
137
+ **React** project are automatically detected by the base config, which also contains relevant rules and parameters.
138
+
139
+ This preset also exposes a few other configs that could be used separately.
140
+
141
+ - vitestBaseConfig
142
+ - vitestReactTestingLibraryConfig
143
+
144
+ You can use them standalone.
145
+
146
+ ## Configuration Examples
147
+
148
+ Please check the examples section of this repository to find each type of possible configuration.
149
+
150
+ ## Versioning
151
+
152
+ This package is published to npm by hand. Follow [docs/PUBLISHING.md](docs/PUBLISHING.md) to
153
+ publish a new version and its matching Git tag. Consumers pin the exact version:
154
+
155
+ ```json
156
+ {
157
+ "devDependencies": {
158
+ "@pam-ai/pam-vitest-config": "2.0.0"
159
+ }
160
+ }
161
+ ```
package/index.js ADDED
@@ -0,0 +1,21 @@
1
+ const fs = require('fs');
2
+ const merge = require('lodash.merge');
3
+
4
+ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
5
+ const dependencies = packageJson.dependencies || {};
6
+
7
+ const insertIf = (condition, ...configs) => condition && configs;
8
+
9
+ const pamVitestConfig = [
10
+ 'vitestBaseConfig',
11
+ insertIf(
12
+ Object.prototype.hasOwnProperty.call(dependencies, 'react'),
13
+ 'vitestReactTestingLibraryConfig'
14
+ ),
15
+ ]
16
+ .filter(Boolean)
17
+ .map((link) => `./presets/${link}`)
18
+ .map(require)
19
+ .reduce(merge);
20
+
21
+ module.exports = pamVitestConfig;
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "@pam-ai/pam-vitest-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0",
4
+ "author": "Pam AI",
5
+ "description": "Pam AI vitest preset configuration",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/dream-lab-ai/pam-vitest-config.git"
9
+ },
10
+ "main": "index.js",
11
+ "exports": {
12
+ ".": "./index.js",
13
+ "./vitestBaseConfig": "./presets/vitestBaseConfig.js",
14
+ "./vitestReactTestingLibraryConfig": "./presets/vitestReactTestingLibraryConfig.js",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "scripts": {
18
+ "debug": "node index.js",
19
+ "build": "exit",
20
+ "test": "vitest",
21
+ "test:ui": "vitest --ui",
22
+ "coverage": "vitest run --coverage",
23
+ "lint": "eslint . --fix",
24
+ "format": "prettier --write .",
25
+ "npm-audit": "npm audit --audit-level=high",
26
+ "prepare": "husky"
27
+ },
28
+ "engines": {
29
+ "node": ">=22"
30
+ },
31
+ "lint-staged": {
32
+ "*": [
33
+ "npm run lint",
34
+ "npm run format"
35
+ ]
36
+ },
37
+ "peerDependencies": {
38
+ "vitest": "^5.0.0"
39
+ },
40
+ "dependencies": {
41
+ "@pam-ai/pam-eslint-config": "3.0.0",
42
+ "@testing-library/jest-dom": "^7.0.1",
43
+ "@vitest/coverage-v8": "^5.0.5",
44
+ "@vitest/ui": "^5.0.5",
45
+ "lodash.merge": "^4.6.2"
46
+ },
47
+ "devDependencies": {
48
+ "eslint": "^9.0.0",
49
+ "husky": "^9.0.11",
50
+ "lint-staged": "^17.6.0",
51
+ "vitest": "^5.0.5"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "files": [
57
+ "index.js",
58
+ "presets",
59
+ "README.md"
60
+ ],
61
+ "overrides": {
62
+ "brace-expansion": "5.0.12"
63
+ }
64
+ }
@@ -0,0 +1,17 @@
1
+ const vitestBaseConfig = {
2
+ test: {
3
+ testTimeout: 30000,
4
+ globals: true,
5
+ useAtomics: true,
6
+ passWithNoTests: true,
7
+ coverage: {
8
+ reporter: ['json-summary', 'html', 'text', 'json'],
9
+ },
10
+ },
11
+ logLevel: 'info',
12
+ esbuild: {
13
+ sourcemap: 'both',
14
+ },
15
+ };
16
+
17
+ module.exports = vitestBaseConfig;
@@ -0,0 +1,11 @@
1
+ const react = require('@vitejs/plugin-react');
2
+
3
+ const vitestReactTestingLibraryConfig = {
4
+ plugins: [react()],
5
+ test: {
6
+ globals: true,
7
+ environment: 'jsdom',
8
+ },
9
+ };
10
+
11
+ module.exports = vitestReactTestingLibraryConfig;