vitest-config-silverwind 9.0.6 → 9.1.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/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -44
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { InlineConfig } from 'vitest';
|
|
1
|
+
import { InlineConfig } from 'vitest/node';
|
|
2
2
|
import { UserConfig } from 'vite';
|
|
3
|
-
|
|
4
3
|
type VitestConfig = UserConfig & {
|
|
5
4
|
test?: InlineConfig;
|
|
6
5
|
};
|
|
7
6
|
type CustomConfig = VitestConfig & {
|
|
8
7
|
/** The value of import.meta.url from your config. */
|
|
9
|
-
url
|
|
8
|
+
url: string;
|
|
10
9
|
};
|
|
11
10
|
export declare const frontend: ({ test, ...other }?: CustomConfig) => VitestConfig;
|
|
12
11
|
export declare const backend: ({ test, ...other }?: CustomConfig) => VitestConfig;
|
|
13
12
|
export {};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAS,UAAU,EAAe,MAAM,MAAM,CAAC;AAE3D,KAAK,YAAY,GAAG,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC;AACzD,KAAK,YAAY,GAAG,YAAY,GAAG;IACjC,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAwFF,eAAO,MAAM,QAAQ,wBAA2B,YAAY,KAAmB,YAM7E,CAAC;AAEH,eAAO,MAAM,OAAO,wBAA2B,YAAY,KAAmB,YAM5E,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { dirname, relative, sep, join, basename } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { accessSync, constants } from "node:fs";
|
|
3
4
|
import { stringPlugin } from "vite-string-plugin";
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const defaultConfig = {
|
|
6
|
+
url: ""
|
|
7
|
+
};
|
|
8
|
+
function uniq(arr) {
|
|
9
|
+
return Array.from(new Set(arr));
|
|
10
|
+
}
|
|
11
|
+
function uniquePluginName(plugin) {
|
|
6
12
|
const apply = typeof plugin.apply === "string" ? plugin.apply : "";
|
|
7
13
|
return `${plugin.name}-${apply}-${String(plugin.enforce)}`;
|
|
8
|
-
}
|
|
14
|
+
}
|
|
9
15
|
function dedupePlugins(libPlugins, userPlugins) {
|
|
10
16
|
const seen = /* @__PURE__ */ new Set([]);
|
|
11
17
|
const ret = [];
|
|
@@ -22,54 +28,66 @@ function dedupePlugins(libPlugins, userPlugins) {
|
|
|
22
28
|
}
|
|
23
29
|
return ret;
|
|
24
30
|
}
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
const setupFileJs = "vitest.setup.js";
|
|
32
|
+
const setupFileTs = "vitest.setup.ts";
|
|
33
|
+
function base({ url, test: { setupFiles = [], ...otherTest } = {}, plugins = [], ...other }) {
|
|
34
|
+
let setupFile = "";
|
|
35
|
+
for (const file of [setupFileJs, setupFileTs]) {
|
|
36
|
+
try {
|
|
37
|
+
const path = fileURLToPath(new URL(file, import.meta.url));
|
|
38
|
+
accessSync(path, constants.R_OK);
|
|
39
|
+
setupFile = path;
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
test: {
|
|
45
|
+
include: [
|
|
46
|
+
"**/?(*.)test.?(c|m)[jt]s?(x)"
|
|
47
|
+
],
|
|
48
|
+
exclude: [
|
|
49
|
+
"**/{node_modules,dist,e2e,snapshots}/**",
|
|
50
|
+
"**/.{air,git,github,gitea,swc,ruff_cache,venv,vscode}/**"
|
|
51
|
+
],
|
|
52
|
+
setupFiles: uniq([
|
|
53
|
+
setupFile,
|
|
54
|
+
...setupFiles
|
|
55
|
+
].filter(Boolean)),
|
|
56
|
+
testTimeout: 3e4,
|
|
57
|
+
pool: "forks",
|
|
58
|
+
// https://github.com/vitest-dev/vitest/issues/2008
|
|
59
|
+
cache: false,
|
|
60
|
+
// https://github.com/vitest-dev/vitest/issues/2008
|
|
61
|
+
open: false,
|
|
62
|
+
allowOnly: true,
|
|
63
|
+
passWithNoTests: true,
|
|
64
|
+
globals: true,
|
|
65
|
+
watch: false,
|
|
66
|
+
resolveSnapshotPath: (path, extension) => {
|
|
67
|
+
if (url) {
|
|
68
|
+
const root = dirname(fileURLToPath(new URL(url)));
|
|
69
|
+
const file = `${relative(root, path).replaceAll(sep, ".")}${extension}`;
|
|
70
|
+
return join(root, "snapshots", file);
|
|
71
|
+
} else {
|
|
72
|
+
return join(dirname(path), "snapshots", `${basename(path)}${extension}`);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
...otherTest
|
|
57
76
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})
|
|
65
|
-
const frontend = ({ test = {}, ...other } = {}) => base({
|
|
77
|
+
plugins: dedupePlugins([
|
|
78
|
+
stringPlugin()
|
|
79
|
+
], plugins),
|
|
80
|
+
...other
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const frontend = ({ test = {}, ...other } = defaultConfig) => base({
|
|
66
84
|
test: {
|
|
67
85
|
environment: "happy-dom",
|
|
68
86
|
...test
|
|
69
87
|
},
|
|
70
88
|
...other
|
|
71
89
|
});
|
|
72
|
-
const backend = ({ test = {}, ...other } =
|
|
90
|
+
const backend = ({ test = {}, ...other } = defaultConfig) => base({
|
|
73
91
|
test: {
|
|
74
92
|
environment: "node",
|
|
75
93
|
...test
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-config-silverwind",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "Shared vitest configuration",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/vitest-config-silverwind",
|
|
@@ -18,21 +18,21 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"jest-extended": "4.0.2",
|
|
21
|
-
"vite-string-plugin": "^1.3.
|
|
21
|
+
"vite-string-plugin": "^1.3.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/node": "
|
|
24
|
+
"@types/node": "22.10.0",
|
|
25
25
|
"eslint": "8.57.0",
|
|
26
|
-
"eslint-config-silverwind": "
|
|
27
|
-
"eslint-config-silverwind-typescript": "
|
|
26
|
+
"eslint-config-silverwind": "94.1.2",
|
|
27
|
+
"eslint-config-silverwind-typescript": "9.2.0",
|
|
28
28
|
"js-yaml": "4.1.0",
|
|
29
|
-
"typescript": "5.
|
|
30
|
-
"typescript-config-silverwind": "
|
|
31
|
-
"updates": "16.0
|
|
32
|
-
"versions": "12.
|
|
33
|
-
"vite": "5.
|
|
34
|
-
"vite-plugin-dts": "3.
|
|
35
|
-
"vitest": "1.6
|
|
29
|
+
"typescript": "5.7.2",
|
|
30
|
+
"typescript-config-silverwind": "6.1.0",
|
|
31
|
+
"updates": "16.4.0",
|
|
32
|
+
"versions": "12.1.2",
|
|
33
|
+
"vite": "5.3.3",
|
|
34
|
+
"vite-plugin-dts": "4.3.0",
|
|
35
|
+
"vitest": "2.1.6"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"happy-dom": "*"
|