@storybook/addon-vitest 0.0.0-pr-30601-sha-d70f67e1 → 0.0.0-pr-31819-sha-b1c88d51
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/_browser-chunks/chunk-A47P2DCZ.js +11 -0
- package/dist/_browser-chunks/chunk-VMSW5DPM.js +60 -0
- package/dist/_node-chunks/chunk-C4NXJJA3.js +324 -0
- package/dist/_node-chunks/chunk-CIKGVIS6.js +223 -0
- package/dist/_node-chunks/chunk-FMQIQP6D.js +96 -0
- package/dist/_node-chunks/chunk-KVKHJ5OL.js +46 -0
- package/dist/_node-chunks/chunk-N3OFRDD3.js +80 -0
- package/dist/_node-chunks/chunk-VFT2PRGV.js +5002 -0
- package/dist/_node-chunks/chunk-W26ZMSD3.js +143 -0
- package/dist/_node-chunks/chunk-XWQZZ2C3.js +1586 -0
- package/dist/index.js +9 -6
- package/dist/manager.js +5571 -8
- package/dist/node/coverage-reporter.js +1395 -4
- package/dist/node/vitest.js +564 -17
- package/dist/postinstall.js +1179 -124
- package/dist/preset.js +268 -32
- package/dist/vitest-plugin/global-setup.js +146 -6
- package/dist/vitest-plugin/index.js +2589 -43
- package/dist/vitest-plugin/setup-file.js +28 -9
- package/dist/vitest-plugin/test-utils.js +68 -8
- package/package.json +20 -92
- package/static/coverage-reporter.cjs +10 -0
- package/templates/vitest.config.3.2.template.ts +30 -0
- package/dist/chunk-55WZLVGN.mjs +0 -11
- package/dist/chunk-JKRQGT2U.mjs +0 -10
- package/dist/index.mjs +0 -5
- package/dist/node/coverage-reporter.d.ts +0 -184
- package/dist/node/coverage-reporter.mjs +0 -12
- package/dist/node/vitest.d.ts +0 -2
- package/dist/node/vitest.mjs +0 -19
- package/dist/vitest-plugin/global-setup.d.ts +0 -6
- package/dist/vitest-plugin/global-setup.mjs +0 -13
- package/dist/vitest-plugin/index.mjs +0 -28
- package/dist/vitest-plugin/setup-file.d.ts +0 -14
- package/dist/vitest-plugin/setup-file.mjs +0 -9
- package/dist/vitest-plugin/test-utils.d.ts +0 -20
- package/dist/vitest-plugin/test-utils.mjs +0 -8
- package/manager.js +0 -1
- package/manager.mjs +0 -1
- package/postinstall.js +0 -1
- package/postinstall.mjs +0 -1
- package/preset.js +0 -1
- package/preset.mjs +0 -1
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
a as n
|
|
3
|
+
} from "../_browser-chunks/chunk-VMSW5DPM.js";
|
|
4
|
+
import {
|
|
5
|
+
a as e
|
|
6
|
+
} from "../_browser-chunks/chunk-A47P2DCZ.js";
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
// src/vitest-plugin/setup-file.ts
|
|
9
|
+
import { afterEach as l, beforeAll as i, vi as s } from "vitest";
|
|
10
|
+
import { Channel as _ } from "storybook/internal/channels";
|
|
11
|
+
var m = { setHandler: s.fn(), send: s.fn() };
|
|
12
|
+
globalThis.__STORYBOOK_ADDONS_CHANNEL__ ??= new _({ transport: m });
|
|
13
|
+
var c = /* @__PURE__ */ e(({ task: r }) => {
|
|
14
|
+
let o = r.meta;
|
|
15
|
+
if (r.type === "test" && r.result?.state === "fail" && o.storyId && r.result.errors?.[0]) {
|
|
16
|
+
let t = r.result.errors[0], a = `${import.meta.env.__STORYBOOK_URL__}/?path=/story/${o.storyId}&addonPanel=${n}`;
|
|
17
|
+
t.message = `
|
|
18
|
+
\x1B[34mClick to debug the error directly in Storybook: ${a}\x1B[39m
|
|
5
19
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
${t.message}`;
|
|
21
|
+
}
|
|
22
|
+
}, "modifyErrorMessage");
|
|
23
|
+
i(() => {
|
|
24
|
+
if (globalThis.globalProjectAnnotations)
|
|
25
|
+
return globalThis.globalProjectAnnotations.beforeAll();
|
|
26
|
+
});
|
|
27
|
+
l(c);
|
|
28
|
+
export {
|
|
29
|
+
c as modifyErrorMessage
|
|
30
|
+
};
|
|
@@ -1,11 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
a as n
|
|
3
|
+
} from "../_browser-chunks/chunk-A47P2DCZ.js";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var viewport = require('storybook/viewport');
|
|
5
|
+
// src/vitest-plugin/test-utils.ts
|
|
6
|
+
import { server as I } from "@vitest/browser/context";
|
|
7
|
+
import { composeStory as T, getCsfFactoryAnnotations as M } from "storybook/preview-api";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// src/vitest-plugin/viewports.ts
|
|
10
|
+
import { UnsupportedViewportDimensionError as f } from "storybook/internal/preview-errors";
|
|
11
|
+
import { MINIMAL_VIEWPORTS as y } from "storybook/viewport";
|
|
12
|
+
var l = {
|
|
13
|
+
width: 1200,
|
|
14
|
+
height: 900
|
|
15
|
+
}, u = /^\d+(px)?$/, V = /^(\d+(\.\d+)?%)$/, v = /^(\d+(\.\d+)?vw)$/, P = /^(\d+(\.\d+)?vh)$/, _ = /^(\d+)(em|rem)$/, w = /* @__PURE__ */ n((t, r) => {
|
|
16
|
+
if (u.test(t))
|
|
17
|
+
return Number.parseInt(t, 10);
|
|
18
|
+
if (V.test(t)) {
|
|
19
|
+
let e = parseFloat(t) / 100;
|
|
20
|
+
return Math.round(l[r] * e);
|
|
21
|
+
} else if (v.test(t)) {
|
|
22
|
+
let e = parseFloat(t) / 100;
|
|
23
|
+
return Math.round(l.width * e);
|
|
24
|
+
} else if (P.test(t)) {
|
|
25
|
+
let e = parseFloat(t) / 100;
|
|
26
|
+
return Math.round(l.height * e);
|
|
27
|
+
} else {
|
|
28
|
+
if (_.test(t))
|
|
29
|
+
return Number.parseInt(t, 10) * 16;
|
|
30
|
+
throw new f({ dimension: r, value: t });
|
|
31
|
+
}
|
|
32
|
+
}, "parseDimension"), h = /* @__PURE__ */ n(async (t = {}, r = {}) => {
|
|
33
|
+
let e, s = t.viewport ?? {}, i = r.viewport ?? {}, a = s.disable || s.disabled;
|
|
34
|
+
i.value && !a ? e = i.value : a || (e = s.defaultViewport);
|
|
35
|
+
let { page: o } = await import("@vitest/browser/context").catch(() => ({
|
|
36
|
+
page: null
|
|
37
|
+
}));
|
|
38
|
+
if (!o || !globalThis.__vitest_browser__)
|
|
39
|
+
return;
|
|
40
|
+
let p = {
|
|
41
|
+
...y,
|
|
42
|
+
...s.viewports,
|
|
43
|
+
...s.options
|
|
44
|
+
}, m = l.width, d = l.height;
|
|
45
|
+
if (e && e in p) {
|
|
46
|
+
let c = p[e].styles;
|
|
47
|
+
if (c?.width && c?.height) {
|
|
48
|
+
let { width: b, height: g } = c;
|
|
49
|
+
m = w(b, "width"), d = w(g, "height");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
await o.viewport(m, d);
|
|
53
|
+
}, "setViewport");
|
|
9
54
|
|
|
10
|
-
|
|
11
|
-
|
|
55
|
+
// src/vitest-plugin/test-utils.ts
|
|
56
|
+
var { getInitialGlobals: S } = I.commands, N = /* @__PURE__ */ n((t) => t.replace(/^file:\/\//, "").replace(/^\/+([a-zA-Z]:)/, "$1").replace(/%20/g, " "), "convertToFilePath"), $ = /* @__PURE__ */ n((t, r, e, s) => async (i) => {
|
|
57
|
+
let a = M(r, e), o = T(
|
|
58
|
+
a.story,
|
|
59
|
+
a.meta,
|
|
60
|
+
{ initialGlobals: await S?.() ?? {} },
|
|
61
|
+
a.preview ?? globalThis.globalProjectAnnotations,
|
|
62
|
+
t
|
|
63
|
+
);
|
|
64
|
+
(o === void 0 || s?.some((m) => o.tags.includes(m))) && i.skip(), i.story = o;
|
|
65
|
+
let p = i.task;
|
|
66
|
+
p.meta.storyId = o.id, await h(o.parameters, o.globals), await o.run(), p.meta.reports = o.reporting.reports;
|
|
67
|
+
}, "testStory");
|
|
68
|
+
export {
|
|
69
|
+
N as convertToFilePath,
|
|
70
|
+
$ as testStory
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-vitest",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-31819-sha-b1c88d51",
|
|
4
4
|
"description": "Storybook addon for testing components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook-addons",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"url": "https://opencollective.com/storybook"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
|
+
"type": "module",
|
|
26
27
|
"imports": {
|
|
27
28
|
"#manager-store": {
|
|
28
29
|
"storybook": "./src/manager-store.mock.ts",
|
|
@@ -32,46 +33,21 @@
|
|
|
32
33
|
"exports": {
|
|
33
34
|
".": {
|
|
34
35
|
"types": "./dist/index.d.ts",
|
|
35
|
-
"
|
|
36
|
-
"require": "./dist/index.js"
|
|
37
|
-
},
|
|
38
|
-
"./vitest-plugin": {
|
|
39
|
-
"types": "./dist/vitest-plugin/index.d.ts",
|
|
40
|
-
"import": "./dist/vitest-plugin/index.mjs",
|
|
41
|
-
"require": "./dist/vitest-plugin/index.js"
|
|
42
|
-
},
|
|
43
|
-
"./internal/global-setup": {
|
|
44
|
-
"types": "./dist/vitest-plugin/global-setup.d.ts",
|
|
45
|
-
"import": "./dist/vitest-plugin/global-setup.mjs",
|
|
46
|
-
"require": "./dist/vitest-plugin/global-setup.js"
|
|
47
|
-
},
|
|
48
|
-
"./internal/setup-file": {
|
|
49
|
-
"types": "./dist/vitest-plugin/setup-file.d.ts",
|
|
50
|
-
"import": "./dist/vitest-plugin/setup-file.mjs"
|
|
51
|
-
},
|
|
52
|
-
"./internal/test-utils": {
|
|
53
|
-
"types": "./dist/vitest-plugin/test-utils.d.ts",
|
|
54
|
-
"import": "./dist/vitest-plugin/test-utils.mjs",
|
|
55
|
-
"require": "./dist/vitest-plugin/test-utils.js"
|
|
56
|
-
},
|
|
57
|
-
"./internal/coverage-reporter": {
|
|
58
|
-
"types": "./dist/node/coverage-reporter.d.ts",
|
|
59
|
-
"import": "./dist/node/coverage-reporter.mjs",
|
|
60
|
-
"require": "./dist/node/coverage-reporter.js"
|
|
36
|
+
"default": "./dist/index.js"
|
|
61
37
|
},
|
|
38
|
+
"./internal/coverage-reporter": "./dist/node/coverage-reporter.js",
|
|
39
|
+
"./internal/global-setup": "./dist/vitest-plugin/global-setup.js",
|
|
40
|
+
"./internal/setup-file": "./dist/vitest-plugin/setup-file.js",
|
|
41
|
+
"./internal/test-utils": "./dist/vitest-plugin/test-utils.js",
|
|
62
42
|
"./manager": "./dist/manager.js",
|
|
63
|
-
"./
|
|
43
|
+
"./package.json": "./package.json",
|
|
64
44
|
"./postinstall": "./dist/postinstall.js",
|
|
65
|
-
"./
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"*": {
|
|
72
|
-
"*": [
|
|
73
|
-
"dist/index.d.ts"
|
|
74
|
-
]
|
|
45
|
+
"./preset": "./dist/preset.js",
|
|
46
|
+
"./static/coverage-reporter.cjs": "./static/coverage-reporter.cjs",
|
|
47
|
+
"./vitest": "./dist/node/vitest.js",
|
|
48
|
+
"./vitest-plugin": {
|
|
49
|
+
"types": "./dist/vitest-plugin/index.d.ts",
|
|
50
|
+
"default": "./dist/vitest-plugin/index.js"
|
|
75
51
|
}
|
|
76
52
|
},
|
|
77
53
|
"files": [
|
|
@@ -86,8 +62,8 @@
|
|
|
86
62
|
"!src/**/*"
|
|
87
63
|
],
|
|
88
64
|
"scripts": {
|
|
89
|
-
"check": "jiti ../../../scripts/
|
|
90
|
-
"prep": "jiti ../../../scripts/
|
|
65
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
66
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
91
67
|
},
|
|
92
68
|
"dependencies": {
|
|
93
69
|
"@storybook/global": "^5.0.0",
|
|
@@ -100,8 +76,8 @@
|
|
|
100
76
|
"@types/micromatch": "^4.0.0",
|
|
101
77
|
"@types/node": "^22.0.0",
|
|
102
78
|
"@types/semver": "^7",
|
|
103
|
-
"@vitest/browser": "^3.
|
|
104
|
-
"@vitest/runner": "^3.
|
|
79
|
+
"@vitest/browser": "^3.2.4",
|
|
80
|
+
"@vitest/runner": "^3.2.4",
|
|
105
81
|
"boxen": "^8.0.1",
|
|
106
82
|
"es-toolkit": "^1.36.0",
|
|
107
83
|
"execa": "^8.0.1",
|
|
@@ -119,12 +95,12 @@
|
|
|
119
95
|
"tree-kill": "^1.2.2",
|
|
120
96
|
"ts-dedent": "^2.2.0",
|
|
121
97
|
"typescript": "^5.8.3",
|
|
122
|
-
"vitest": "^3.
|
|
98
|
+
"vitest": "^3.2.4"
|
|
123
99
|
},
|
|
124
100
|
"peerDependencies": {
|
|
125
101
|
"@vitest/browser": "^3.0.0",
|
|
126
102
|
"@vitest/runner": "^3.0.0",
|
|
127
|
-
"storybook": "^0.0.0-pr-
|
|
103
|
+
"storybook": "^0.0.0-pr-31819-sha-b1c88d51",
|
|
128
104
|
"vitest": "^3.0.0"
|
|
129
105
|
},
|
|
130
106
|
"peerDependenciesMeta": {
|
|
@@ -141,54 +117,6 @@
|
|
|
141
117
|
"publishConfig": {
|
|
142
118
|
"access": "public"
|
|
143
119
|
},
|
|
144
|
-
"bundler": {
|
|
145
|
-
"exportEntries": [
|
|
146
|
-
"./src/index.ts",
|
|
147
|
-
"./src/vitest-plugin/test-utils.ts",
|
|
148
|
-
"./src/vitest-plugin/setup-file.ts"
|
|
149
|
-
],
|
|
150
|
-
"managerEntries": [
|
|
151
|
-
"./src/manager.tsx"
|
|
152
|
-
],
|
|
153
|
-
"nodeEntries": [
|
|
154
|
-
"./src/preset.ts",
|
|
155
|
-
"./src/postinstall.ts",
|
|
156
|
-
{
|
|
157
|
-
"file": "./src/dummy.ts",
|
|
158
|
-
"formats": [
|
|
159
|
-
"esm"
|
|
160
|
-
]
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"file": "./src/node/vitest.ts",
|
|
164
|
-
"formats": [
|
|
165
|
-
"esm",
|
|
166
|
-
"cjs"
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
"file": "./src/node/coverage-reporter.ts",
|
|
171
|
-
"formats": [
|
|
172
|
-
"esm",
|
|
173
|
-
"cjs"
|
|
174
|
-
]
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
"file": "./src/vitest-plugin/index.ts",
|
|
178
|
-
"formats": [
|
|
179
|
-
"cjs",
|
|
180
|
-
"esm"
|
|
181
|
-
]
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"file": "./src/vitest-plugin/global-setup.ts",
|
|
185
|
-
"formats": [
|
|
186
|
-
"cjs",
|
|
187
|
-
"esm"
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
]
|
|
191
|
-
},
|
|
192
120
|
"storybook": {
|
|
193
121
|
"displayName": "Test",
|
|
194
122
|
"unsupportedFrameworks": [
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This exists because the code loading this uses `Cont = require(name)`.
|
|
3
|
+
*
|
|
4
|
+
* That code is in node_modules/../ some istanbul util file, which we cannot change.
|
|
5
|
+
*
|
|
6
|
+
* So we have to create a CJS file that requires the ESM file.
|
|
7
|
+
*
|
|
8
|
+
* The key compatibility that we're doing here, is the `.default` at the end.
|
|
9
|
+
*/
|
|
10
|
+
module.exports = require('@storybook/addon-vitest/internal/coverage-reporter').default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
import { defineConfig } from 'vitest/config';
|
|
5
|
+
|
|
6
|
+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
7
|
+
|
|
8
|
+
const dirname =
|
|
9
|
+
typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
test: {
|
|
14
|
+
projects: [
|
|
15
|
+
{
|
|
16
|
+
extends: true,
|
|
17
|
+
plugins: [
|
|
18
|
+
// The plugin will run tests for the stories defined in your Storybook config
|
|
19
|
+
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
|
20
|
+
storybookTest({ configDir: path.join(dirname, 'CONFIG_DIR') }),
|
|
21
|
+
],
|
|
22
|
+
test: {
|
|
23
|
+
name: 'storybook',
|
|
24
|
+
browser: BROWSER_CONFIG,
|
|
25
|
+
setupFiles: ['SETUP_FILE'],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
});
|
package/dist/chunk-55WZLVGN.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ESM_COMPAT_Module from 'node:module';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as dirname$1 } from 'node:path';
|
|
4
|
-
import { __commonJS } from './chunk-JKRQGT2U.mjs';
|
|
5
|
-
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
dirname$1(__filename);
|
|
8
|
-
ESM_COMPAT_Module.createRequire(import.meta.url);
|
|
9
|
-
var require_picocolors=__commonJS({"../../node_modules/picocolors/picocolors.js"(exports,module){var p=process||{},argv=p.argv||[],env=p.env||{},isColorSupported=!(env.NO_COLOR||argv.includes("--no-color"))&&(!!env.FORCE_COLOR||argv.includes("--color")||p.platform==="win32"||(p.stdout||{}).isTTY&&env.TERM!=="dumb"||!!env.CI),formatter=(open,close,replace=open)=>input=>{let string=""+input,index=string.indexOf(close,open.length);return ~index?open+replaceClose(string,close,replace,index)+close:open+string+close},replaceClose=(string,close,replace,index)=>{let result="",cursor=0;do result+=string.substring(cursor,index)+replace,cursor=index+close.length,index=string.indexOf(close,cursor);while(~index);return result+string.substring(cursor)},createColors=(enabled=isColorSupported)=>{let f=enabled?formatter:()=>String;return {isColorSupported:enabled,reset:f("\x1B[0m","\x1B[0m"),bold:f("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:f("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:f("\x1B[3m","\x1B[23m"),underline:f("\x1B[4m","\x1B[24m"),inverse:f("\x1B[7m","\x1B[27m"),hidden:f("\x1B[8m","\x1B[28m"),strikethrough:f("\x1B[9m","\x1B[29m"),black:f("\x1B[30m","\x1B[39m"),red:f("\x1B[31m","\x1B[39m"),green:f("\x1B[32m","\x1B[39m"),yellow:f("\x1B[33m","\x1B[39m"),blue:f("\x1B[34m","\x1B[39m"),magenta:f("\x1B[35m","\x1B[39m"),cyan:f("\x1B[36m","\x1B[39m"),white:f("\x1B[37m","\x1B[39m"),gray:f("\x1B[90m","\x1B[39m"),bgBlack:f("\x1B[40m","\x1B[49m"),bgRed:f("\x1B[41m","\x1B[49m"),bgGreen:f("\x1B[42m","\x1B[49m"),bgYellow:f("\x1B[43m","\x1B[49m"),bgBlue:f("\x1B[44m","\x1B[49m"),bgMagenta:f("\x1B[45m","\x1B[49m"),bgCyan:f("\x1B[46m","\x1B[49m"),bgWhite:f("\x1B[47m","\x1B[49m"),blackBright:f("\x1B[90m","\x1B[39m"),redBright:f("\x1B[91m","\x1B[39m"),greenBright:f("\x1B[92m","\x1B[39m"),yellowBright:f("\x1B[93m","\x1B[39m"),blueBright:f("\x1B[94m","\x1B[39m"),magentaBright:f("\x1B[95m","\x1B[39m"),cyanBright:f("\x1B[96m","\x1B[39m"),whiteBright:f("\x1B[97m","\x1B[39m"),bgBlackBright:f("\x1B[100m","\x1B[49m"),bgRedBright:f("\x1B[101m","\x1B[49m"),bgGreenBright:f("\x1B[102m","\x1B[49m"),bgYellowBright:f("\x1B[103m","\x1B[49m"),bgBlueBright:f("\x1B[104m","\x1B[49m"),bgMagentaBright:f("\x1B[105m","\x1B[49m"),bgCyanBright:f("\x1B[106m","\x1B[49m"),bgWhiteBright:f("\x1B[107m","\x1B[49m")}};module.exports=createColors();module.exports.createColors=createColors;}});var _DRIVE_LETTER_START_RE=/^[A-Za-z]:\//;function normalizeWindowsPath(input=""){return input&&input.replace(/\\/g,"/").replace(_DRIVE_LETTER_START_RE,r=>r.toUpperCase())}var _UNC_REGEX=/^[/\\]{2}/,_IS_ABSOLUTE_RE=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,_DRIVE_LETTER_RE=/^[A-Za-z]:$/,_ROOT_FOLDER_RE=/^\/([A-Za-z]:)?$/,sep="/",delimiter=":",normalize=function(path2){if(path2.length===0)return ".";path2=normalizeWindowsPath(path2);let isUNCPath=path2.match(_UNC_REGEX),isPathAbsolute=isAbsolute(path2),trailingSeparator=path2[path2.length-1]==="/";return path2=normalizeString(path2,!isPathAbsolute),path2.length===0?isPathAbsolute?"/":trailingSeparator?"./":".":(trailingSeparator&&(path2+="/"),_DRIVE_LETTER_RE.test(path2)&&(path2+="/"),isUNCPath?isPathAbsolute?`//${path2}`:`//./${path2}`:isPathAbsolute&&!isAbsolute(path2)?`/${path2}`:path2)},join=function(...arguments_){if(arguments_.length===0)return ".";let joined;for(let argument of arguments_)argument&&argument.length>0&&(joined===void 0?joined=argument:joined+=`/${argument}`);return joined===void 0?".":normalize(joined.replace(/\/\/+/g,"/"))};function cwd(){return typeof process<"u"&&typeof process.cwd=="function"?process.cwd().replace(/\\/g,"/"):"/"}var resolve=function(...arguments_){arguments_=arguments_.map(argument=>normalizeWindowsPath(argument));let resolvedPath="",resolvedAbsolute=!1;for(let index=arguments_.length-1;index>=-1&&!resolvedAbsolute;index--){let path2=index>=0?arguments_[index]:cwd();!path2||path2.length===0||(resolvedPath=`${path2}/${resolvedPath}`,resolvedAbsolute=isAbsolute(path2));}return resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute),resolvedAbsolute&&!isAbsolute(resolvedPath)?`/${resolvedPath}`:resolvedPath.length>0?resolvedPath:"."};function normalizeString(path2,allowAboveRoot){let res="",lastSegmentLength=0,lastSlash=-1,dots=0,char=null;for(let index=0;index<=path2.length;++index){if(index<path2.length)char=path2[index];else {if(char==="/")break;char="/";}if(char==="/"){if(!(lastSlash===index-1||dots===1))if(dots===2){if(res.length<2||lastSegmentLength!==2||res[res.length-1]!=="."||res[res.length-2]!=="."){if(res.length>2){let lastSlashIndex=res.lastIndexOf("/");lastSlashIndex===-1?(res="",lastSegmentLength=0):(res=res.slice(0,lastSlashIndex),lastSegmentLength=res.length-1-res.lastIndexOf("/")),lastSlash=index,dots=0;continue}else if(res.length>0){res="",lastSegmentLength=0,lastSlash=index,dots=0;continue}}allowAboveRoot&&(res+=res.length>0?"/..":"..",lastSegmentLength=2);}else res.length>0?res+=`/${path2.slice(lastSlash+1,index)}`:res=path2.slice(lastSlash+1,index),lastSegmentLength=index-lastSlash-1;lastSlash=index,dots=0;}else char==="."&&dots!==-1?++dots:dots=-1;}return res}var isAbsolute=function(p){return _IS_ABSOLUTE_RE.test(p)},toNamespacedPath=function(p){return normalizeWindowsPath(p)},_EXTNAME_RE=/.(\.[^./]+)$/,extname=function(p){let match=_EXTNAME_RE.exec(normalizeWindowsPath(p));return match&&match[1]||""},relative=function(from,to){let _from=resolve(from).replace(_ROOT_FOLDER_RE,"$1").split("/"),_to=resolve(to).replace(_ROOT_FOLDER_RE,"$1").split("/");if(_to[0][1]===":"&&_from[0][1]===":"&&_from[0]!==_to[0])return _to.join("/");let _fromCopy=[..._from];for(let segment of _fromCopy){if(_to[0]!==segment)break;_from.shift(),_to.shift();}return [..._from.map(()=>".."),..._to].join("/")},dirname=function(p){let segments=normalizeWindowsPath(p).replace(/\/$/,"").split("/").slice(0,-1);return segments.length===1&&_DRIVE_LETTER_RE.test(segments[0])&&(segments[0]+="/"),segments.join("/")||(isAbsolute(p)?"/":".")},format=function(p){let segments=[p.root,p.dir,p.base??p.name+p.ext].filter(Boolean);return normalizeWindowsPath(p.root?resolve(...segments):segments.join("/"))},basename=function(p,extension){let lastSegment=normalizeWindowsPath(p).split("/").pop();return extension&&lastSegment.endsWith(extension)?lastSegment.slice(0,-extension.length):lastSegment},parse=function(p){let root=normalizeWindowsPath(p).split("/").shift()||"/",base=basename(p),extension=extname(base);return {root,dir:dirname(p),base,ext:extension,name:base.slice(0,base.length-extension.length)}},path={__proto__:null,basename,delimiter,dirname,extname,format,isAbsolute,join,normalize,normalizeString,parse,relative,resolve,sep,toNamespacedPath};
|
|
10
|
-
|
|
11
|
-
export { dirname, join, normalize, path, relative, require_picocolors, resolve, sep };
|
package/dist/chunk-JKRQGT2U.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import ESM_COMPAT_Module from 'node:module';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname } from 'node:path';
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
dirname(__filename);
|
|
7
|
-
const require = ESM_COMPAT_Module.createRequire(import.meta.url);
|
|
8
|
-
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var __esm=(fn,res)=>function(){return fn&&(res=(0, fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __commonJS=(cb,mod)=>function(){return mod||(0, cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0});},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);
|
|
9
|
-
|
|
10
|
-
export { __commonJS, __esm, __export, __require, __toCommonJS, __toESM };
|
package/dist/index.mjs
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { Vitest, TestSpecification, TestProject, WorkspaceProject, ResolvedCoverageOptions } from 'vitest/node';
|
|
2
|
-
import { ReportBase, Visitor, ReportNode } from 'istanbul-lib-report';
|
|
3
|
-
import { ThrottledFunction } from './function/throttle.js';
|
|
4
|
-
import { TestResult } from 'vitest/dist/node.js';
|
|
5
|
-
import { experimental_UniversalStore } from 'storybook/internal/core-server';
|
|
6
|
-
import { API_HashEntry, PreviewAnnotation, StoryId, Options, StatusStoreByTypeId, TestProviderStoreById } from 'storybook/internal/types';
|
|
7
|
-
import { Report } from 'storybook/preview-api';
|
|
8
|
-
|
|
9
|
-
interface VitestError extends Error {
|
|
10
|
-
VITEST_TEST_PATH?: string;
|
|
11
|
-
VITEST_TEST_NAME?: string;
|
|
12
|
-
stacks?: Array<{
|
|
13
|
-
line: number;
|
|
14
|
-
column: number;
|
|
15
|
-
file: string;
|
|
16
|
-
method: string;
|
|
17
|
-
}>;
|
|
18
|
-
}
|
|
19
|
-
type ErrorLike = {
|
|
20
|
-
message: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
stack?: string;
|
|
23
|
-
cause?: ErrorLike;
|
|
24
|
-
};
|
|
25
|
-
type RunTrigger = 'run-all' | 'global' | 'watch' | Extract<API_HashEntry['type'], string>;
|
|
26
|
-
type StoreState = {
|
|
27
|
-
config: {
|
|
28
|
-
coverage: boolean;
|
|
29
|
-
a11y: boolean;
|
|
30
|
-
};
|
|
31
|
-
watching: boolean;
|
|
32
|
-
cancelling: boolean;
|
|
33
|
-
indexUrl: string | undefined;
|
|
34
|
-
previewAnnotations: PreviewAnnotation[];
|
|
35
|
-
fatalError: {
|
|
36
|
-
message: string | undefined;
|
|
37
|
-
error: ErrorLike;
|
|
38
|
-
} | undefined;
|
|
39
|
-
currentRun: {
|
|
40
|
-
triggeredBy: RunTrigger | undefined;
|
|
41
|
-
config: StoreState['config'];
|
|
42
|
-
componentTestCount: {
|
|
43
|
-
success: number;
|
|
44
|
-
error: number;
|
|
45
|
-
};
|
|
46
|
-
a11yCount: {
|
|
47
|
-
success: number;
|
|
48
|
-
warning: number;
|
|
49
|
-
error: number;
|
|
50
|
-
};
|
|
51
|
-
totalTestCount: number | undefined;
|
|
52
|
-
storyIds: StoryId[] | undefined;
|
|
53
|
-
startedAt: number | undefined;
|
|
54
|
-
finishedAt: number | undefined;
|
|
55
|
-
unhandledErrors: VitestError[];
|
|
56
|
-
coverageSummary: {
|
|
57
|
-
status: 'positive' | 'warning' | 'negative' | 'unknown';
|
|
58
|
-
percentage: number;
|
|
59
|
-
} | undefined;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
type TriggerRunEvent = {
|
|
63
|
-
type: 'TRIGGER_RUN';
|
|
64
|
-
payload: {
|
|
65
|
-
storyIds?: string[] | undefined;
|
|
66
|
-
triggeredBy: RunTrigger;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
type CancelRunEvent = {
|
|
70
|
-
type: 'CANCEL_RUN';
|
|
71
|
-
};
|
|
72
|
-
type ToggleWatchingEvent = {
|
|
73
|
-
type: 'TOGGLE_WATCHING';
|
|
74
|
-
payload: {
|
|
75
|
-
to: boolean;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
type FatalErrorEvent = {
|
|
79
|
-
type: 'FATAL_ERROR';
|
|
80
|
-
payload: {
|
|
81
|
-
message: string;
|
|
82
|
-
error: ErrorLike;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
type TestRunCompletedEvent = {
|
|
86
|
-
type: 'TEST_RUN_COMPLETED';
|
|
87
|
-
payload: StoreState['currentRun'];
|
|
88
|
-
};
|
|
89
|
-
type StoreEvent = TriggerRunEvent | CancelRunEvent | FatalErrorEvent | ToggleWatchingEvent | TestRunCompletedEvent;
|
|
90
|
-
|
|
91
|
-
declare class VitestManager {
|
|
92
|
-
private testManager;
|
|
93
|
-
vitest: Vitest | null;
|
|
94
|
-
vitestStartupCounter: number;
|
|
95
|
-
vitestRestartPromise: Promise<void> | null;
|
|
96
|
-
runningPromise: Promise<any> | null;
|
|
97
|
-
constructor(testManager: TestManager);
|
|
98
|
-
startVitest({ coverage }: {
|
|
99
|
-
coverage: boolean;
|
|
100
|
-
}): Promise<void>;
|
|
101
|
-
restartVitest({ coverage }: {
|
|
102
|
-
coverage: boolean;
|
|
103
|
-
}): Promise<void>;
|
|
104
|
-
private resetGlobalTestNamePattern;
|
|
105
|
-
private updateLastChanged;
|
|
106
|
-
private fetchStories;
|
|
107
|
-
private filterTestSpecifications;
|
|
108
|
-
runTests(runPayload: TriggerRunEvent['payload']): Promise<void>;
|
|
109
|
-
cancelCurrentRun(): Promise<void>;
|
|
110
|
-
getStorybookTestSpecifications(): Promise<TestSpecification[]>;
|
|
111
|
-
runAffectedTestsAfterChange(changedFilePath: string, event: 'change' | 'add'): Promise<void>;
|
|
112
|
-
private getTestDependencies;
|
|
113
|
-
registerVitestConfigListener(): Promise<void>;
|
|
114
|
-
setupWatchers(): Promise<void>;
|
|
115
|
-
isStorybookProject(project: TestProject | WorkspaceProject): boolean;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
type TestManagerOptions = {
|
|
119
|
-
storybookOptions: Options;
|
|
120
|
-
store: experimental_UniversalStore<StoreState, StoreEvent>;
|
|
121
|
-
componentTestStatusStore: StatusStoreByTypeId;
|
|
122
|
-
a11yStatusStore: StatusStoreByTypeId;
|
|
123
|
-
testProviderStore: TestProviderStoreById;
|
|
124
|
-
onError?: (message: string, error: Error) => void;
|
|
125
|
-
onReady?: () => void;
|
|
126
|
-
};
|
|
127
|
-
declare class TestManager {
|
|
128
|
-
store: TestManagerOptions['store'];
|
|
129
|
-
vitestManager: VitestManager;
|
|
130
|
-
private componentTestStatusStore;
|
|
131
|
-
private a11yStatusStore;
|
|
132
|
-
private testProviderStore;
|
|
133
|
-
private onReady?;
|
|
134
|
-
storybookOptions: Options;
|
|
135
|
-
private batchedTestCaseResults;
|
|
136
|
-
constructor(options: TestManagerOptions);
|
|
137
|
-
handleTriggerRunEvent(event: TriggerRunEvent): Promise<void>;
|
|
138
|
-
handleCancelEvent(): Promise<void>;
|
|
139
|
-
runTestsWithState({ storyIds, triggeredBy, callback, }: {
|
|
140
|
-
storyIds?: string[];
|
|
141
|
-
triggeredBy: RunTrigger;
|
|
142
|
-
callback: () => Promise<void>;
|
|
143
|
-
}): Promise<void>;
|
|
144
|
-
onTestModuleCollected(collectedTestCount: number): void;
|
|
145
|
-
onTestCaseResult(result: {
|
|
146
|
-
storyId?: string;
|
|
147
|
-
testResult: TestResult;
|
|
148
|
-
reports?: Report[];
|
|
149
|
-
}): void;
|
|
150
|
-
/**
|
|
151
|
-
* Throttled function to process batched test case results.
|
|
152
|
-
*
|
|
153
|
-
* This function:
|
|
154
|
-
*
|
|
155
|
-
* 1. Takes all batched test case results and clears the batch
|
|
156
|
-
* 2. Updates the store state with new test counts (component tests and a11y tests)
|
|
157
|
-
* 3. Adjusts the totalTestCount if more tests were run than initially anticipated
|
|
158
|
-
* 4. Creates status objects for component tests and updates the component test status store
|
|
159
|
-
* 5. Creates status objects for a11y tests (if any) and updates the a11y status store
|
|
160
|
-
*
|
|
161
|
-
* The throttling (500ms) is necessary as the channel would otherwise get overwhelmed with events,
|
|
162
|
-
* eventually causing the manager and dev server to lose connection.
|
|
163
|
-
*/
|
|
164
|
-
throttledFlushTestCaseResults: ThrottledFunction<() => void>;
|
|
165
|
-
onTestRunEnd(endResult: {
|
|
166
|
-
totalTestCount: number;
|
|
167
|
-
unhandledErrors: VitestError[];
|
|
168
|
-
}): void;
|
|
169
|
-
onCoverageCollected(coverageSummary: StoreState['currentRun']['coverageSummary']): void;
|
|
170
|
-
reportFatalError(message: string, error: Error | any): Promise<void>;
|
|
171
|
-
static start(options: TestManagerOptions): Promise<TestManager>;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
type StorybookCoverageReporterOptions = {
|
|
175
|
-
testManager: TestManager;
|
|
176
|
-
coverageOptions: ResolvedCoverageOptions<'v8'> | undefined;
|
|
177
|
-
};
|
|
178
|
-
declare class StorybookCoverageReporter extends ReportBase implements Partial<Visitor> {
|
|
179
|
-
#private;
|
|
180
|
-
constructor(opts: StorybookCoverageReporterOptions);
|
|
181
|
-
onSummary(node: ReportNode): void;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export { StorybookCoverageReporterOptions, StorybookCoverageReporter as default };
|