@storybook/addon-vitest 9.2.0-alpha.2 → 10.0.0-beta.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 +2 -0
- package/dist/_browser-chunks/chunk-JK72E6FR.js +6 -0
- package/dist/_browser-chunks/chunk-PMYV6BH2.js +76 -0
- package/dist/_node-chunks/chunk-2LKDLHP2.js +91 -0
- package/dist/_node-chunks/chunk-75PF53UG.js +103 -0
- package/dist/_node-chunks/chunk-EZERIZC2.js +481 -0
- package/dist/_node-chunks/chunk-FJO43W6J.js +37 -0
- package/dist/_node-chunks/chunk-HIDBMPI3.js +247 -0
- package/dist/_node-chunks/chunk-MHHQUJAV.js +50 -0
- package/dist/_node-chunks/chunk-MJKNSUFZ.js +295 -0
- package/dist/_node-chunks/chunk-T7EST64K.js +2264 -0
- package/dist/index.js +9 -6
- package/dist/manager.js +955 -8
- package/dist/node/coverage-reporter.js +1898 -4
- package/dist/node/vitest.js +871 -17
- package/dist/postinstall.js +2076 -88
- package/dist/preset.js +615 -35
- package/dist/vitest-plugin/global-setup.js +200 -6
- package/dist/vitest-plugin/index.js +3823 -43
- package/dist/vitest-plugin/setup-file.js +30 -8
- package/dist/vitest-plugin/test-utils.js +102 -8
- package/manager.js +1 -1
- package/package.json +27 -93
- package/preset.js +1 -1
- 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.mjs +0 -1
- package/postinstall.js +0 -1
- package/postinstall.mjs +0 -1
- package/preset.mjs +0 -1
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
PANEL_ID
|
|
3
|
+
} from "../_browser-chunks/chunk-PMYV6BH2.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "../_browser-chunks/chunk-JK72E6FR.js";
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
8
|
+
// src/vitest-plugin/setup-file.ts
|
|
9
|
+
import { afterEach, beforeAll, vi } from "vitest";
|
|
10
|
+
import { Channel } from "storybook/internal/channels";
|
|
11
|
+
var transport = { setHandler: vi.fn(), send: vi.fn() };
|
|
12
|
+
globalThis.__STORYBOOK_ADDONS_CHANNEL__ ??= new Channel({ transport });
|
|
13
|
+
var modifyErrorMessage = /* @__PURE__ */ __name(({ task }) => {
|
|
14
|
+
const meta = task.meta;
|
|
15
|
+
if (task.type === "test" && task.result?.state === "fail" && meta.storyId && task.result.errors?.[0]) {
|
|
16
|
+
const currentError = task.result.errors[0];
|
|
17
|
+
const storybookUrl = import.meta.env.__STORYBOOK_URL__;
|
|
18
|
+
const storyUrl = `${storybookUrl}/?path=/story/${meta.storyId}&addonPanel=${PANEL_ID}`;
|
|
19
|
+
currentError.message = `
|
|
7
20
|
\x1B[34mClick to debug the error directly in Storybook: ${storyUrl}\x1B[39m
|
|
8
21
|
|
|
9
|
-
${currentError.message}`;
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
${currentError.message}`;
|
|
23
|
+
}
|
|
24
|
+
}, "modifyErrorMessage");
|
|
25
|
+
beforeAll(() => {
|
|
26
|
+
if (globalThis.globalProjectAnnotations) {
|
|
27
|
+
return globalThis.globalProjectAnnotations.beforeAll();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
afterEach(modifyErrorMessage);
|
|
31
|
+
export {
|
|
32
|
+
modifyErrorMessage
|
|
33
|
+
};
|
|
@@ -1,11 +1,105 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "../_browser-chunks/chunk-JK72E6FR.js";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var viewport = require('storybook/viewport');
|
|
5
|
+
// src/vitest-plugin/test-utils.ts
|
|
6
|
+
import { server } from "@vitest/browser/context";
|
|
7
|
+
import { composeStory, getCsfFactoryAnnotations } from "storybook/preview-api";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// src/vitest-plugin/viewports.ts
|
|
10
|
+
import { UnsupportedViewportDimensionError } from "storybook/internal/preview-errors";
|
|
11
|
+
import { MINIMAL_VIEWPORTS } from "storybook/viewport";
|
|
12
|
+
var DEFAULT_VIEWPORT_DIMENSIONS = {
|
|
13
|
+
width: 1200,
|
|
14
|
+
height: 900
|
|
15
|
+
};
|
|
16
|
+
var validPixelOrNumber = /^\d+(px)?$/;
|
|
17
|
+
var percentagePattern = /^(\d+(\.\d+)?%)$/;
|
|
18
|
+
var vwPattern = /^(\d+(\.\d+)?vw)$/;
|
|
19
|
+
var vhPattern = /^(\d+(\.\d+)?vh)$/;
|
|
20
|
+
var emRemPattern = /^(\d+)(em|rem)$/;
|
|
21
|
+
var parseDimension = /* @__PURE__ */ __name((value, dimension) => {
|
|
22
|
+
if (validPixelOrNumber.test(value)) {
|
|
23
|
+
return Number.parseInt(value, 10);
|
|
24
|
+
} else if (percentagePattern.test(value)) {
|
|
25
|
+
const percentageValue = parseFloat(value) / 100;
|
|
26
|
+
return Math.round(DEFAULT_VIEWPORT_DIMENSIONS[dimension] * percentageValue);
|
|
27
|
+
} else if (vwPattern.test(value)) {
|
|
28
|
+
const vwValue = parseFloat(value) / 100;
|
|
29
|
+
return Math.round(DEFAULT_VIEWPORT_DIMENSIONS.width * vwValue);
|
|
30
|
+
} else if (vhPattern.test(value)) {
|
|
31
|
+
const vhValue = parseFloat(value) / 100;
|
|
32
|
+
return Math.round(DEFAULT_VIEWPORT_DIMENSIONS.height * vhValue);
|
|
33
|
+
} else if (emRemPattern.test(value)) {
|
|
34
|
+
const emRemValue = Number.parseInt(value, 10);
|
|
35
|
+
return emRemValue * 16;
|
|
36
|
+
} else {
|
|
37
|
+
throw new UnsupportedViewportDimensionError({ dimension, value });
|
|
38
|
+
}
|
|
39
|
+
}, "parseDimension");
|
|
40
|
+
var setViewport = /* @__PURE__ */ __name(async (parameters = {}, globals = {}) => {
|
|
41
|
+
let defaultViewport;
|
|
42
|
+
const viewportsParam = parameters.viewport ?? {};
|
|
43
|
+
const viewportsGlobal = globals.viewport ?? {};
|
|
44
|
+
const isDisabled = viewportsParam.disable || viewportsParam.disabled;
|
|
45
|
+
if (viewportsGlobal.value && !isDisabled) {
|
|
46
|
+
defaultViewport = viewportsGlobal.value;
|
|
47
|
+
} else if (!isDisabled) {
|
|
48
|
+
defaultViewport = viewportsParam.defaultViewport;
|
|
49
|
+
}
|
|
50
|
+
const { page } = await import("@vitest/browser/context").catch(() => ({
|
|
51
|
+
page: null
|
|
52
|
+
}));
|
|
53
|
+
if (!page || !globalThis.__vitest_browser__) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const viewports = {
|
|
57
|
+
...MINIMAL_VIEWPORTS,
|
|
58
|
+
...viewportsParam.viewports,
|
|
59
|
+
...viewportsParam.options
|
|
60
|
+
};
|
|
61
|
+
let viewportWidth = DEFAULT_VIEWPORT_DIMENSIONS.width;
|
|
62
|
+
let viewportHeight = DEFAULT_VIEWPORT_DIMENSIONS.height;
|
|
63
|
+
if (defaultViewport && defaultViewport in viewports) {
|
|
64
|
+
const styles = viewports[defaultViewport].styles;
|
|
65
|
+
if (styles?.width && styles?.height) {
|
|
66
|
+
const { width, height } = styles;
|
|
67
|
+
viewportWidth = parseDimension(width, "width");
|
|
68
|
+
viewportHeight = parseDimension(height, "height");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
await page.viewport(viewportWidth, viewportHeight);
|
|
72
|
+
}, "setViewport");
|
|
9
73
|
|
|
10
|
-
|
|
11
|
-
|
|
74
|
+
// src/vitest-plugin/test-utils.ts
|
|
75
|
+
var { getInitialGlobals } = server.commands;
|
|
76
|
+
var convertToFilePath = /* @__PURE__ */ __name((url) => {
|
|
77
|
+
const path = url.replace(/^file:\/\//, "");
|
|
78
|
+
const normalizedPath = path.replace(/^\/+([a-zA-Z]:)/, "$1");
|
|
79
|
+
return normalizedPath.replace(/%20/g, " ");
|
|
80
|
+
}, "convertToFilePath");
|
|
81
|
+
var testStory = /* @__PURE__ */ __name((exportName, story, meta, skipTags) => {
|
|
82
|
+
return async (context) => {
|
|
83
|
+
const annotations = getCsfFactoryAnnotations(story, meta);
|
|
84
|
+
const composedStory = composeStory(
|
|
85
|
+
annotations.story,
|
|
86
|
+
annotations.meta,
|
|
87
|
+
{ initialGlobals: await getInitialGlobals?.() ?? {} },
|
|
88
|
+
annotations.preview ?? globalThis.globalProjectAnnotations,
|
|
89
|
+
exportName
|
|
90
|
+
);
|
|
91
|
+
if (composedStory === void 0 || skipTags?.some((tag) => composedStory.tags.includes(tag))) {
|
|
92
|
+
context.skip();
|
|
93
|
+
}
|
|
94
|
+
context.story = composedStory;
|
|
95
|
+
const _task = context.task;
|
|
96
|
+
_task.meta.storyId = composedStory.id;
|
|
97
|
+
await setViewport(composedStory.parameters, composedStory.globals);
|
|
98
|
+
await composedStory.run();
|
|
99
|
+
_task.meta.reports = composedStory.reporting.reports;
|
|
100
|
+
};
|
|
101
|
+
}, "testStory");
|
|
102
|
+
export {
|
|
103
|
+
convertToFilePath,
|
|
104
|
+
testStory
|
|
105
|
+
};
|
package/manager.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './dist/manager.js';
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-vitest",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Storybook addon
|
|
3
|
+
"version": "10.0.0-beta.0",
|
|
4
|
+
"description": "Storybook Vitest addon: Blazing fast component testing using stories",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"storybook
|
|
7
|
-
"addon
|
|
6
|
+
"storybook",
|
|
7
|
+
"storybook-addon",
|
|
8
8
|
"vitest",
|
|
9
9
|
"testing",
|
|
10
|
-
"test"
|
|
10
|
+
"test",
|
|
11
|
+
"component",
|
|
12
|
+
"components",
|
|
13
|
+
"component-testing",
|
|
14
|
+
"react",
|
|
15
|
+
"vue",
|
|
16
|
+
"svelte",
|
|
17
|
+
"web-components"
|
|
11
18
|
],
|
|
12
19
|
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/addons/vitest",
|
|
13
20
|
"bugs": {
|
|
@@ -23,6 +30,7 @@
|
|
|
23
30
|
"url": "https://opencollective.com/storybook"
|
|
24
31
|
},
|
|
25
32
|
"license": "MIT",
|
|
33
|
+
"type": "module",
|
|
26
34
|
"imports": {
|
|
27
35
|
"#manager-store": {
|
|
28
36
|
"storybook": "./src/manager-store.mock.ts",
|
|
@@ -32,46 +40,20 @@
|
|
|
32
40
|
"exports": {
|
|
33
41
|
".": {
|
|
34
42
|
"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"
|
|
43
|
+
"default": "./dist/index.js"
|
|
61
44
|
},
|
|
45
|
+
"./internal/coverage-reporter": "./dist/node/coverage-reporter.js",
|
|
46
|
+
"./internal/global-setup": "./dist/vitest-plugin/global-setup.js",
|
|
47
|
+
"./internal/setup-file": "./dist/vitest-plugin/setup-file.js",
|
|
48
|
+
"./internal/test-utils": "./dist/vitest-plugin/test-utils.js",
|
|
62
49
|
"./manager": "./dist/manager.js",
|
|
63
|
-
"./
|
|
50
|
+
"./package.json": "./package.json",
|
|
64
51
|
"./postinstall": "./dist/postinstall.js",
|
|
65
|
-
"./
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"typesVersions": {
|
|
71
|
-
"*": {
|
|
72
|
-
"*": [
|
|
73
|
-
"dist/index.d.ts"
|
|
74
|
-
]
|
|
52
|
+
"./preset": "./dist/preset.js",
|
|
53
|
+
"./vitest": "./dist/node/vitest.js",
|
|
54
|
+
"./vitest-plugin": {
|
|
55
|
+
"types": "./dist/vitest-plugin/index.d.ts",
|
|
56
|
+
"default": "./dist/vitest-plugin/index.js"
|
|
75
57
|
}
|
|
76
58
|
},
|
|
77
59
|
"files": [
|
|
@@ -86,8 +68,8 @@
|
|
|
86
68
|
"!src/**/*"
|
|
87
69
|
],
|
|
88
70
|
"scripts": {
|
|
89
|
-
"check": "jiti ../../../scripts/
|
|
90
|
-
"prep": "jiti ../../../scripts/
|
|
71
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
72
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
91
73
|
},
|
|
92
74
|
"dependencies": {
|
|
93
75
|
"@storybook/global": "^5.0.0",
|
|
@@ -124,7 +106,7 @@
|
|
|
124
106
|
"peerDependencies": {
|
|
125
107
|
"@vitest/browser": "^3.0.0",
|
|
126
108
|
"@vitest/runner": "^3.0.0",
|
|
127
|
-
"storybook": "^
|
|
109
|
+
"storybook": "^10.0.0-beta.0",
|
|
128
110
|
"vitest": "^3.0.0"
|
|
129
111
|
},
|
|
130
112
|
"peerDependenciesMeta": {
|
|
@@ -141,54 +123,6 @@
|
|
|
141
123
|
"publishConfig": {
|
|
142
124
|
"access": "public"
|
|
143
125
|
},
|
|
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
126
|
"storybook": {
|
|
193
127
|
"displayName": "Test",
|
|
194
128
|
"unsupportedFrameworks": [
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './dist/preset.js';
|
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 };
|