@websolutespa/test 3.0.1 → 3.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.
@@ -0,0 +1,20 @@
1
+ import { ViteUserConfig } from "vitest/config";
2
+
3
+ //#region src/exports/vitest.d.ts
4
+ /**
5
+ * Node environment, for libraries and server code.
6
+ */
7
+ declare function defineNodeConfig(config?: ViteUserConfig): ViteUserConfig;
8
+ /**
9
+ * jsdom environment with the `@testing-library/jest-dom` matchers, for react components and hooks.
10
+ */
11
+ declare function defineDomConfig(config?: ViteUserConfig): ViteUserConfig;
12
+ /**
13
+ * Node environment for Payload integration suites built with `@websolutespa/test/payload`.
14
+ * Uses the in-memory database by default, `BOM_TEST_DB=mongo` switches to a mongo replica set.
15
+ * Node, not jsdom: jsdom breaks the Payload REST api.
16
+ */
17
+ declare function definePayloadConfig(config?: ViteUserConfig): ViteUserConfig;
18
+ //#endregion
19
+ export { defineDomConfig, defineNodeConfig, definePayloadConfig };
20
+ //# sourceMappingURL=vitest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.d.ts","names":[],"sources":["../../src/exports/vitest.ts"],"mappings":";;;;;AAgCA;iBAAgB,gBAAA,CAAiB,MAAA,GAAQ,cAAA,GAAmB,cAAA;;;;iBAO5C,eAAA,CAAgB,MAAA,GAAQ,cAAA,GAAmB,cAAA;;;;AAA3D;;iBAcgB,mBAAA,CAAoB,MAAA,GAAQ,cAAA,GAAmB,cAAA"}
@@ -0,0 +1,58 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import { configDefaults, defineConfig, mergeConfig } from "vitest/config";
3
+ //#region src/exports/vitest.ts
4
+ /**
5
+ * Shared vitest configurations of the BOM Repository.
6
+ * Each factory takes an optional config, deep merged over the defaults.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // vitest.config.ts
11
+ * import { definePayloadConfig } from '@websolutespa/test/vitest';
12
+ * export default definePayloadConfig();
13
+ * ```
14
+ */
15
+ const baseConfig = {
16
+ plugins: [react()],
17
+ resolve: { tsconfigPaths: true },
18
+ test: {
19
+ environment: "node",
20
+ exclude: [
21
+ ...configDefaults.exclude,
22
+ "**/dist/**",
23
+ "**/.next/**"
24
+ ],
25
+ hookTimeout: 3e4,
26
+ testTimeout: 3e4
27
+ }
28
+ };
29
+ /**
30
+ * Node environment, for libraries and server code.
31
+ */
32
+ function defineNodeConfig(config = {}) {
33
+ return defineConfig(mergeConfig(baseConfig, config));
34
+ }
35
+ /**
36
+ * jsdom environment with the `@testing-library/jest-dom` matchers, for react components and hooks.
37
+ */
38
+ function defineDomConfig(config = {}) {
39
+ return defineConfig(mergeConfig(mergeConfig(baseConfig, { test: {
40
+ environment: "jsdom",
41
+ setupFiles: ["@websolutespa/test/vitest-setup-dom"]
42
+ } }), config));
43
+ }
44
+ /**
45
+ * Node environment for Payload integration suites built with `@websolutespa/test/payload`.
46
+ * Uses the in-memory database by default, `BOM_TEST_DB=mongo` switches to a mongo replica set.
47
+ * Node, not jsdom: jsdom breaks the Payload REST api.
48
+ */
49
+ function definePayloadConfig(config = {}) {
50
+ return defineConfig(mergeConfig(mergeConfig(baseConfig, { test: {
51
+ hookTimeout: 5 * 6e4,
52
+ env: { BOM_TEST_DB: process.env.BOM_TEST_DB || "memory" }
53
+ } }), config));
54
+ }
55
+ //#endregion
56
+ export { defineDomConfig, defineNodeConfig, definePayloadConfig };
57
+
58
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","names":[],"sources":["../../src/exports/vitest.ts"],"sourcesContent":["import react from '@vitejs/plugin-react';\nimport { configDefaults, defineConfig, mergeConfig, type ViteUserConfig } from 'vitest/config';\n\n/**\n * Shared vitest configurations of the BOM Repository.\n * Each factory takes an optional config, deep merged over the defaults.\n *\n * @example\n * ```ts\n * // vitest.config.ts\n * import { definePayloadConfig } from '@websolutespa/test/vitest';\n * export default definePayloadConfig();\n * ```\n */\n\nconst baseConfig: ViteUserConfig = {\n plugins: [react()],\n resolve: {\n tsconfigPaths: true,\n },\n test: {\n environment: 'node',\n // build outputs may contain compiled test files\n exclude: [...configDefaults.exclude, '**/dist/**', '**/.next/**'],\n hookTimeout: 30_000,\n testTimeout: 30_000,\n },\n};\n\n/**\n * Node environment, for libraries and server code.\n */\nexport function defineNodeConfig(config: ViteUserConfig = {}) {\n return defineConfig(mergeConfig(baseConfig, config));\n}\n\n/**\n * jsdom environment with the `@testing-library/jest-dom` matchers, for react components and hooks.\n */\nexport function defineDomConfig(config: ViteUserConfig = {}) {\n return defineConfig(mergeConfig(mergeConfig(baseConfig, {\n test: {\n environment: 'jsdom',\n setupFiles: ['@websolutespa/test/vitest-setup-dom'],\n },\n }), config));\n}\n\n/**\n * Node environment for Payload integration suites built with `@websolutespa/test/payload`.\n * Uses the in-memory database by default, `BOM_TEST_DB=mongo` switches to a mongo replica set.\n * Node, not jsdom: jsdom breaks the Payload REST api.\n */\nexport function definePayloadConfig(config: ViteUserConfig = {}) {\n return defineConfig(mergeConfig(mergeConfig(baseConfig, {\n test: {\n // payload init seeds the database\n hookTimeout: 5 * 60_000,\n env: {\n BOM_TEST_DB: process.env.BOM_TEST_DB || 'memory',\n },\n },\n }), config));\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,aAA6B;CACjC,SAAS,CAAC,OAAO,CAAC;CAClB,SAAS,EACP,eAAe,MAChB;CACD,MAAM;EACJ,aAAa;EAEb,SAAS;GAAC,GAAG,eAAe;GAAS;GAAc;GAAc;EACjE,aAAa;EACb,aAAa;EACd;CACF;;;;AAKD,SAAgB,iBAAiB,SAAyB,EAAE,EAAE;AAC5D,QAAO,aAAa,YAAY,YAAY,OAAO,CAAC;;;;;AAMtD,SAAgB,gBAAgB,SAAyB,EAAE,EAAE;AAC3D,QAAO,aAAa,YAAY,YAAY,YAAY,EACtD,MAAM;EACJ,aAAa;EACb,YAAY,CAAC,sCAAsC;EACpD,EACF,CAAC,EAAE,OAAO,CAAC;;;;;;;AAQd,SAAgB,oBAAoB,SAAyB,EAAE,EAAE;AAC/D,QAAO,aAAa,YAAY,YAAY,YAAY,EACtD,MAAM;EAEJ,aAAa,IAAI;EACjB,KAAK,EACH,aAAa,QAAQ,IAAI,eAAe,UACzC;EACF,EACF,CAAC,EAAE,OAAO,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,2 @@
1
- import { Config } from 'jest';
2
-
3
- declare const baseConfig: Config;
4
- declare function getProjectConfig(): {};
5
- declare function getAppConfig(): {};
6
- declare function getPackageConfig(): {};
7
- declare function getPayloadConfig(): {};
8
-
9
- export { baseConfig, getAppConfig, getPackageConfig, getPayloadConfig, getProjectConfig };
1
+ import { defineDomConfig, defineNodeConfig, definePayloadConfig } from "./exports/vitest.js";
2
+ export { defineDomConfig, defineNodeConfig, definePayloadConfig };
package/dist/index.js CHANGED
@@ -1,214 +1,2 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- // index.ts
9
- import nextJest from "next/jest";
10
- var createJestConfig = nextJest({
11
- // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
12
- dir: "./"
13
- });
14
- var baseConfig = {
15
- verbose: false,
16
- silent: false,
17
- testTimeout: process.env.CI ? 2e4 : 1e4,
18
- // testEnvironment: 'jsdom',
19
- testEnvironment: "jest-environment-jsdom",
20
- // setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
21
- reporters: ["default", "github-actions"],
22
- /*
23
- snapshotFormat: {
24
- printBasicPrototype: false,
25
- },
26
- */
27
- /*
28
- coverageThreshold: {
29
- global: {
30
- branches: 80,
31
- functions: 80,
32
- lines: 80,
33
- statements: 80,
34
- }
35
- },
36
- */
37
- coverageReporters: ["html", "text", "text-summary", "lcov"]
38
- };
39
- function getProjectConfig() {
40
- const cwd = process.cwd();
41
- const config = {
42
- ...baseConfig,
43
- rootDir: ".",
44
- roots: [
45
- `${cwd}`
46
- ],
47
- resetMocks: true,
48
- modulePaths: [
49
- `${cwd}/src/`
50
- ],
51
- moduleDirectories: [
52
- "node_modules"
53
- ],
54
- testMatch: [
55
- "<rootDir>/src/**/*(?<!e2e).test.{js,jsx,ts,tsx}"
56
- ],
57
- coverageDirectory: `${cwd}/coverage`,
58
- collectCoverageFrom: [
59
- "<rootDir>/src/**/*(?<!test).{js,jsx,ts,tsx}"
60
- ],
61
- setupFilesAfterEnv: [`${cwd}/jest.setup.js`],
62
- transform: {
63
- "^.+\\.(js|jsx|ts|tsx)?$": ["@swc/jest", {
64
- jsc: {
65
- transform: {
66
- react: {
67
- runtime: "automatic"
68
- }
69
- }
70
- }
71
- }]
72
- },
73
- // Rewrite Swiper ESM imports as paths (allows them to be transformed w/o errors)
74
- moduleNameMapper: {
75
- "\\.(css|scss)$": "identity-obj-proxy",
76
- "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/packages/test/jest.mock.file.js",
77
- // swiper
78
- "swiper": "<rootDir>/node_modules/swiper/swiper-bundle.js",
79
- "swiper/react": "<rootDir>/node_modules/swiper/react/swiper-react.js"
80
- // 'swiper/css': '<rootDir>/node_modules/swiper/swiper.min.css',
81
- // 'swiper/css/bundle': '<rootDir>/node_modules/swiper/swiper-bundle.min.css',
82
- // 'swiper/css/autoplay': '<rootDir>/node_modules/swiper/modules/autoplay/autoplay.min.css',
83
- // 'swiper/css/free-mode': '<rootDir>/node_modules/swiper/modules/autoplay/free-mode.min.css',
84
- // 'swiper/css/navigation': '<rootDir>/node_modules/swiper/modules/autoplay/navigation.min.css',
85
- // 'swiper/css/pagination': '<rootDir>/node_modules/swiper/modules/autoplay/pagination.min.css',
86
- // Handle module aliases (this will be automatically configured for you soon)
87
- // '^@/components/(.*)$': '<rootDir>/components/$1',
88
- // '^@/pages/(.*)$': '<rootDir>/pages/$1',
89
- },
90
- modulePathIgnorePatterns: [
91
- "<rootDir>/build/",
92
- "<rootDir>/.next/"
93
- ],
94
- transformIgnorePatterns: [
95
- "node_modules",
96
- "node_modules/(?!(swiper|swiper/react|ssr-window|dom7)/)"
97
- ]
98
- };
99
- return config;
100
- }
101
- function getAppConfig() {
102
- const config = getProjectConfig();
103
- config.transform = {
104
- "^.+\\.(js|jsx|ts|tsx)?$": ["@swc/jest", {
105
- jsc: {
106
- transform: {
107
- react: {
108
- runtime: "automatic"
109
- }
110
- }
111
- },
112
- tsconfig: "tsconfig.test.json"
113
- }]
114
- };
115
- return createJestConfig(config);
116
- }
117
- function getPackageConfig() {
118
- const cwd = process.cwd();
119
- const config = {
120
- ...baseConfig,
121
- rootDir: ".",
122
- roots: [
123
- `${cwd}`
124
- ],
125
- modulePaths: [
126
- `${cwd}/src/`
127
- ],
128
- moduleDirectories: [
129
- "node_modules"
130
- ],
131
- testMatch: [
132
- "<rootDir>/src/**/*(?<!e2e).test.{js,jsx,ts,tsx}"
133
- ],
134
- coverageDirectory: `${cwd}/coverage`,
135
- collectCoverageFrom: [
136
- "<rootDir>/src/**/*(?<!test).{js,jsx,ts,tsx}"
137
- ],
138
- transform: {
139
- "^.+\\.(js|jsx|ts|tsx)?$": ["@swc/jest", {
140
- jsc: {
141
- transform: {
142
- react: {
143
- runtime: "automatic"
144
- }
145
- }
146
- }
147
- }]
148
- },
149
- modulePathIgnorePatterns: [
150
- "<rootDir>/build/"
151
- ],
152
- transformIgnorePatterns: ["node_modules/(?!swiper)/"]
153
- };
154
- return config;
155
- }
156
- function getPayloadConfig() {
157
- const cwd = process.cwd();
158
- const config = {
159
- ...baseConfig,
160
- // testEnvironment: '<rootDir>/jest.environment.ts',
161
- testEnvironment: "node",
162
- testTimeout: 2e4,
163
- verbose: true,
164
- silent: true,
165
- rootDir: ".",
166
- roots: [
167
- `${cwd}`
168
- ],
169
- modulePaths: [
170
- `${cwd}/src/`
171
- ],
172
- moduleDirectories: [
173
- "node_modules"
174
- ],
175
- testMatch: [
176
- "<rootDir>/src/**/*(?<!e2e).test.{js,jsx,ts,tsx}"
177
- ],
178
- coverageDirectory: `${cwd}/coverage`,
179
- collectCoverageFrom: [
180
- "<rootDir>/src/**/*(?<!test).{js,jsx,ts,tsx}"
181
- ],
182
- reporters: ["default", "github-actions"],
183
- coverageReporters: ["html", "text", "text-summary", "lcov"],
184
- transform: {
185
- "^.+\\.(js|jsx|ts|tsx)?$": ["@swc/jest", {
186
- jsc: {
187
- transform: {
188
- react: {
189
- runtime: "automatic"
190
- }
191
- }
192
- }
193
- }]
194
- },
195
- modulePathIgnorePatterns: [
196
- "<rootDir>/build/"
197
- ],
198
- transformIgnorePatterns: ["node_modules/(?!swiper)/"],
199
- moduleNameMapper: {
200
- // Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
201
- "uuid": __require.resolve("uuid"),
202
- "\\.(css|scss)$": "identity-obj-proxy",
203
- "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/jest.mock.file.js"
204
- }
205
- };
206
- return config;
207
- }
208
- export {
209
- baseConfig,
210
- getAppConfig,
211
- getPackageConfig,
212
- getPayloadConfig,
213
- getProjectConfig
214
- };
1
+ import { defineDomConfig, defineNodeConfig, definePayloadConfig } from "./exports/vitest.js";
2
+ export { defineDomConfig, defineNodeConfig, definePayloadConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/test",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "Test shared config of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -12,40 +12,42 @@
12
12
  "url": "git://github.com/websolutespa/bom.git"
13
13
  },
14
14
  "scripts": {
15
- "lint": "eslint *.js*",
16
- "compile": "tsup ./index.ts --format esm,cjs --dts",
15
+ "lint": "eslint .",
16
+ "compile": "tsdown",
17
17
  "prepack": "bom prepack",
18
18
  "postpack": "bom postpack",
19
19
  "types": "tsc --noemit"
20
20
  },
21
21
  "peerDependencies": {
22
- "next": "16.1.6",
23
- "payload": "3.74.0",
24
- "uuid": "9.0.1"
22
+ "@payloadcms/db-mongodb": "^3.91.0",
23
+ "@payloadcms/next": "^3.91.0",
24
+ "@payloadcms/richtext-lexical": "^3.91.0",
25
+ "@payloadcms/richtext-slate": "^3.91.0",
26
+ "@websolutespa/bom-core": "^3.0.5",
27
+ "next": "^16.3.3",
28
+ "payload": "^3.91.0",
29
+ "react": "^19.2.1",
30
+ "react-dom": "^19.2.1",
31
+ "vitest": "^5.0.5"
25
32
  },
26
33
  "dependencies": {
27
- "@playwright/test": "1.50.0",
28
- "@testing-library/dom": "10.4.1",
29
- "@testing-library/jest-dom": "6.9.1",
30
- "@testing-library/react": "16.3.0",
31
- "@testing-library/user-event": "14.6.1",
32
- "identity-obj-proxy": "3.0.0",
33
- "jest-environment-jsdom": "30.0.4",
34
- "jest-fail-on-console": "3.3.1",
35
- "jest-matcher-utils": "30.0.4",
36
- "jest-styled-components": "7.2.0",
37
- "jest": "30.0.4",
38
- "vitest": "3.2.3"
34
+ "@testing-library/dom": "10.4.2",
35
+ "@testing-library/jest-dom": "7.0.1",
36
+ "@testing-library/react": "16.3.3",
37
+ "@vitejs/plugin-react": "6.1.2",
38
+ "@websolutespa/payload-db-memory": "^3.1.0",
39
+ "jsdom": "30.1.3",
40
+ "mongodb-memory-server": "11.3.0",
41
+ "qs-esm": "7.0.2",
42
+ "sharp": "0.34.2",
43
+ "vite": "8.3.5"
39
44
  },
40
45
  "devDependencies": {
41
- "@types/jest": "^29.5.14",
42
- "@types/uuid": "^9.0.2",
43
- "@websolutespa/eslint-config": "^3.0.0",
44
- "next": "16.1.6",
45
- "npm-run-all": "4.1.5",
46
- "tsup": "8.5.0",
47
- "typescript": "5.8.3",
48
- "uuid": "9.0.1"
46
+ "@websolutespa/eslint-config": "^3.1.0",
47
+ "eslint": "10.13.0",
48
+ "next": "16.4.2",
49
+ "tsdown": "0.21.0",
50
+ "typescript": "6.0.3"
49
51
  },
50
52
  "publishConfig": {
51
53
  "access": "public"
@@ -65,6 +67,16 @@
65
67
  "import": "./dist/exports/payload.js",
66
68
  "types": "./dist/exports/payload.d.ts",
67
69
  "default": "./dist/exports/payload.js"
70
+ },
71
+ "./vitest": {
72
+ "import": "./dist/exports/vitest.js",
73
+ "types": "./dist/exports/vitest.d.ts",
74
+ "default": "./dist/exports/vitest.js"
75
+ },
76
+ "./vitest-setup-dom": {
77
+ "import": "./dist/exports/vitest-setup-dom.js",
78
+ "types": "./dist/exports/vitest-setup-dom.d.ts",
79
+ "default": "./dist/exports/vitest-setup-dom.js"
68
80
  }
69
81
  }
70
82
  },
@@ -81,9 +93,48 @@
81
93
  "import": "./src/exports/payload.ts",
82
94
  "types": "./src/exports/payload.ts",
83
95
  "default": "./src/exports/payload.ts"
96
+ },
97
+ "./vitest": {
98
+ "import": "./src/exports/vitest.ts",
99
+ "types": "./src/exports/vitest.ts",
100
+ "default": "./src/exports/vitest.ts"
101
+ },
102
+ "./vitest-setup-dom": {
103
+ "import": "./src/exports/vitest-setup-dom.ts",
104
+ "types": "./src/exports/vitest-setup-dom.ts",
105
+ "default": "./src/exports/vitest-setup-dom.ts"
84
106
  }
85
107
  }
86
108
  },
109
+ "peerDependenciesMeta": {
110
+ "@payloadcms/db-mongodb": {
111
+ "optional": true
112
+ },
113
+ "@payloadcms/next": {
114
+ "optional": true
115
+ },
116
+ "@payloadcms/richtext-lexical": {
117
+ "optional": true
118
+ },
119
+ "@payloadcms/richtext-slate": {
120
+ "optional": true
121
+ },
122
+ "@websolutespa/bom-core": {
123
+ "optional": true
124
+ },
125
+ "next": {
126
+ "optional": true
127
+ },
128
+ "payload": {
129
+ "optional": true
130
+ },
131
+ "react": {
132
+ "optional": true
133
+ },
134
+ "react-dom": {
135
+ "optional": true
136
+ }
137
+ },
87
138
  "main": "./dist/index.js",
88
139
  "types": "./dist/index.d.ts",
89
140
  "exports": {
@@ -96,6 +147,16 @@
96
147
  "import": "./dist/exports/payload.js",
97
148
  "types": "./dist/exports/payload.d.ts",
98
149
  "default": "./dist/exports/payload.js"
150
+ },
151
+ "./vitest": {
152
+ "import": "./dist/exports/vitest.js",
153
+ "types": "./dist/exports/vitest.d.ts",
154
+ "default": "./dist/exports/vitest.js"
155
+ },
156
+ "./vitest-setup-dom": {
157
+ "import": "./dist/exports/vitest-setup-dom.js",
158
+ "types": "./dist/exports/vitest-setup-dom.d.ts",
159
+ "default": "./dist/exports/vitest-setup-dom.js"
99
160
  }
100
161
  }
101
162
  }