@deot/dev-tester 2.0.0 → 2.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/shared.config.ts +59 -0
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@deot/dev-tester",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "main": "dist/index.es.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist",
10
- "vitest.config.ts"
10
+ "shared.config.ts"
11
11
  ],
12
12
  "license": "MIT",
13
13
  "publishConfig": {
@@ -0,0 +1,59 @@
1
+ import { defineConfig, configDefaults } from 'vitest/config';
2
+ import * as path from 'node:path';
3
+ import { createRequire } from "node:module";
4
+ import type { UserConfig } from 'vite';
5
+
6
+ const cwd = process.cwd();
7
+
8
+ // options
9
+ const options = JSON.parse(decodeURIComponent(process.env.TEST_OPTIONS || '{}'));
10
+ const { workspace, packageFolderName } = options;
11
+
12
+ const testDirPrefix = workspace
13
+ ? `${workspace}/${packageFolderName || '*'}/__tests__`
14
+ : `__tests__`;
15
+
16
+ const collectDirPrefix = workspace
17
+ ? `${workspace}/${packageFolderName || '*'}/src`
18
+ : `src`;
19
+
20
+ // alias
21
+ const replacement = (name: string) => path.resolve(cwd, `./packages/${name}/src`);
22
+ const { name } = createRequire(cwd)(path.resolve(cwd, workspace ? `${workspace}/index` : '', 'package.json'));
23
+
24
+ export default defineConfig({
25
+ resolve: workspace
26
+ ? {
27
+ alias: [
28
+ {
29
+ find: new RegExp(`^${name}$`),
30
+ replacement: replacement('index')
31
+ },
32
+ {
33
+
34
+ find: new RegExp(`^${name}-(.*?)$`),
35
+ replacement: replacement('$1')
36
+ }
37
+ ]
38
+ }
39
+ : {},
40
+ test: {
41
+ globals: true,
42
+ include: [
43
+ `${testDirPrefix}/**.(spec|test).[jt]s?(x)`
44
+ ],
45
+ coverage: {
46
+ enabled: true,
47
+ provider: 'istanbul',
48
+ reporter: ['text', 'html'],
49
+ branches: 85,
50
+ statements: 95,
51
+ functions: 95,
52
+ lines: 95,
53
+ include: [
54
+ `${collectDirPrefix}/**/*.ts`
55
+ ],
56
+ exclude: configDefaults.coverage.exclude
57
+ }
58
+ }
59
+ }) as UserConfig;