@storybook/addon-vitest 0.0.0-pr-32759-sha-ea80f897 → 0.0.0-pr-32758-sha-3071b498
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-JK72E6FR.js +6 -0
- package/dist/_browser-chunks/chunk-PMYV6BH2.js +76 -0
- package/dist/_node-chunks/chunk-73KHIO2G.js +50 -0
- package/dist/_node-chunks/chunk-A5VL32OL.js +481 -0
- package/dist/_node-chunks/chunk-FC5WEP55.js +37 -0
- package/dist/_node-chunks/chunk-OCDTR3Y3.js +247 -0
- package/dist/_node-chunks/chunk-PWWJLFD4.js +98 -0
- package/dist/_node-chunks/chunk-RQVZMCWV.js +103 -0
- package/dist/_node-chunks/chunk-XRO3IAIY.js +2574 -0
- package/dist/_node-chunks/chunk-YQTNMET7.js +91 -0
- package/dist/index.js +9 -6
- package/dist/manager.js +958 -8
- package/dist/node/coverage-reporter.js +1898 -4
- package/dist/node/vitest.js +892 -17
- package/dist/postinstall.js +2175 -87
- package/dist/preset.js +615 -35
- package/dist/vitest-plugin/global-setup.js +200 -6
- package/dist/vitest-plugin/index.js +3826 -43
- package/dist/vitest-plugin/setup-file.js +30 -8
- package/dist/vitest-plugin/test-utils.js +105 -8
- package/manager.js +1 -1
- package/package.json +18 -91
- 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,108 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "../_browser-chunks/chunk-JK72E6FR.js";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// src/vitest-plugin/test-utils.ts
|
|
6
|
+
import { getStoryChildren, isStory } from "storybook/internal/csf";
|
|
7
|
+
import { server } from "@vitest/browser/context";
|
|
8
|
+
import { composeStory, getCsfFactoryAnnotations } from "storybook/preview-api";
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
// src/vitest-plugin/viewports.ts
|
|
11
|
+
import { UnsupportedViewportDimensionError } from "storybook/internal/preview-errors";
|
|
12
|
+
import { MINIMAL_VIEWPORTS } from "storybook/viewport";
|
|
13
|
+
var DEFAULT_VIEWPORT_DIMENSIONS = {
|
|
14
|
+
width: 1200,
|
|
15
|
+
height: 900
|
|
16
|
+
};
|
|
17
|
+
var validPixelOrNumber = /^\d+(px)?$/;
|
|
18
|
+
var percentagePattern = /^(\d+(\.\d+)?%)$/;
|
|
19
|
+
var vwPattern = /^(\d+(\.\d+)?vw)$/;
|
|
20
|
+
var vhPattern = /^(\d+(\.\d+)?vh)$/;
|
|
21
|
+
var emRemPattern = /^(\d+)(em|rem)$/;
|
|
22
|
+
var parseDimension = /* @__PURE__ */ __name((value, dimension) => {
|
|
23
|
+
if (validPixelOrNumber.test(value)) {
|
|
24
|
+
return Number.parseInt(value, 10);
|
|
25
|
+
} else if (percentagePattern.test(value)) {
|
|
26
|
+
const percentageValue = parseFloat(value) / 100;
|
|
27
|
+
return Math.round(DEFAULT_VIEWPORT_DIMENSIONS[dimension] * percentageValue);
|
|
28
|
+
} else if (vwPattern.test(value)) {
|
|
29
|
+
const vwValue = parseFloat(value) / 100;
|
|
30
|
+
return Math.round(DEFAULT_VIEWPORT_DIMENSIONS.width * vwValue);
|
|
31
|
+
} else if (vhPattern.test(value)) {
|
|
32
|
+
const vhValue = parseFloat(value) / 100;
|
|
33
|
+
return Math.round(DEFAULT_VIEWPORT_DIMENSIONS.height * vhValue);
|
|
34
|
+
} else if (emRemPattern.test(value)) {
|
|
35
|
+
const emRemValue = Number.parseInt(value, 10);
|
|
36
|
+
return emRemValue * 16;
|
|
37
|
+
} else {
|
|
38
|
+
throw new UnsupportedViewportDimensionError({ dimension, value });
|
|
39
|
+
}
|
|
40
|
+
}, "parseDimension");
|
|
41
|
+
var setViewport = /* @__PURE__ */ __name(async (parameters = {}, globals = {}) => {
|
|
42
|
+
let defaultViewport;
|
|
43
|
+
const viewportsParam = parameters.viewport ?? {};
|
|
44
|
+
const viewportsGlobal = globals.viewport ?? {};
|
|
45
|
+
const isDisabled = viewportsParam.disable || viewportsParam.disabled;
|
|
46
|
+
if (viewportsGlobal.value && !isDisabled) {
|
|
47
|
+
defaultViewport = viewportsGlobal.value;
|
|
48
|
+
} else if (!isDisabled) {
|
|
49
|
+
defaultViewport = viewportsParam.defaultViewport;
|
|
50
|
+
}
|
|
51
|
+
const { page } = await import("@vitest/browser/context").catch(() => ({
|
|
52
|
+
page: null
|
|
53
|
+
}));
|
|
54
|
+
if (!page || !globalThis.__vitest_browser__) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const options = {
|
|
58
|
+
...MINIMAL_VIEWPORTS,
|
|
59
|
+
...viewportsParam.viewports,
|
|
60
|
+
...viewportsParam.options
|
|
61
|
+
};
|
|
62
|
+
let viewportWidth = DEFAULT_VIEWPORT_DIMENSIONS.width;
|
|
63
|
+
let viewportHeight = DEFAULT_VIEWPORT_DIMENSIONS.height;
|
|
64
|
+
if (defaultViewport && defaultViewport in options) {
|
|
65
|
+
const { styles } = options[defaultViewport];
|
|
66
|
+
if (styles?.width && styles?.height) {
|
|
67
|
+
const { width, height } = styles;
|
|
68
|
+
viewportWidth = parseDimension(width, "width");
|
|
69
|
+
viewportHeight = parseDimension(height, "height");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
await page.viewport(viewportWidth, viewportHeight);
|
|
73
|
+
}, "setViewport");
|
|
9
74
|
|
|
10
|
-
|
|
11
|
-
|
|
75
|
+
// src/vitest-plugin/test-utils.ts
|
|
76
|
+
var { getInitialGlobals } = server.commands;
|
|
77
|
+
var convertToFilePath = /* @__PURE__ */ __name((url) => {
|
|
78
|
+
const path = url.replace(/^file:\/\//, "");
|
|
79
|
+
const normalizedPath = path.replace(/^\/+([a-zA-Z]:)/, "$1");
|
|
80
|
+
return normalizedPath.replace(/%20/g, " ");
|
|
81
|
+
}, "convertToFilePath");
|
|
82
|
+
var testStory = /* @__PURE__ */ __name((exportName, story, meta, skipTags, storyId, testName) => {
|
|
83
|
+
return async (context) => {
|
|
84
|
+
const annotations = getCsfFactoryAnnotations(story, meta);
|
|
85
|
+
const test = isStory(story) && testName ? getStoryChildren(story).find((child) => child.input.name === testName) : void 0;
|
|
86
|
+
const storyAnnotations = test ? test.input : annotations.story;
|
|
87
|
+
const composedStory = composeStory(
|
|
88
|
+
storyAnnotations,
|
|
89
|
+
annotations.meta,
|
|
90
|
+
{ initialGlobals: await getInitialGlobals?.() ?? {} },
|
|
91
|
+
annotations.preview ?? globalThis.globalProjectAnnotations,
|
|
92
|
+
exportName
|
|
93
|
+
);
|
|
94
|
+
if (composedStory === void 0 || skipTags?.some((tag) => composedStory.tags.includes(tag))) {
|
|
95
|
+
context.skip();
|
|
96
|
+
}
|
|
97
|
+
context.story = composedStory;
|
|
98
|
+
const _task = context.task;
|
|
99
|
+
_task.meta.storyId = storyId;
|
|
100
|
+
await setViewport(composedStory.parameters, composedStory.globals);
|
|
101
|
+
await composedStory.run(void 0);
|
|
102
|
+
_task.meta.reports = composedStory.reporting.reports;
|
|
103
|
+
};
|
|
104
|
+
}, "testStory");
|
|
105
|
+
export {
|
|
106
|
+
convertToFilePath,
|
|
107
|
+
testStory
|
|
108
|
+
};
|
package/manager.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './dist/manager.js';
|
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-32758-sha-3071b498",
|
|
4
4
|
"description": "Storybook Vitest addon: Blazing fast component testing using stories",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"url": "https://opencollective.com/storybook"
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
|
+
"type": "module",
|
|
33
34
|
"imports": {
|
|
34
35
|
"#manager-store": {
|
|
35
36
|
"storybook": "./src/manager-store.mock.ts",
|
|
@@ -39,46 +40,20 @@
|
|
|
39
40
|
"exports": {
|
|
40
41
|
".": {
|
|
41
42
|
"types": "./dist/index.d.ts",
|
|
42
|
-
"
|
|
43
|
-
"require": "./dist/index.js"
|
|
44
|
-
},
|
|
45
|
-
"./vitest-plugin": {
|
|
46
|
-
"types": "./dist/vitest-plugin/index.d.ts",
|
|
47
|
-
"import": "./dist/vitest-plugin/index.mjs",
|
|
48
|
-
"require": "./dist/vitest-plugin/index.js"
|
|
49
|
-
},
|
|
50
|
-
"./internal/global-setup": {
|
|
51
|
-
"types": "./dist/vitest-plugin/global-setup.d.ts",
|
|
52
|
-
"import": "./dist/vitest-plugin/global-setup.mjs",
|
|
53
|
-
"require": "./dist/vitest-plugin/global-setup.js"
|
|
54
|
-
},
|
|
55
|
-
"./internal/setup-file": {
|
|
56
|
-
"types": "./dist/vitest-plugin/setup-file.d.ts",
|
|
57
|
-
"import": "./dist/vitest-plugin/setup-file.mjs"
|
|
58
|
-
},
|
|
59
|
-
"./internal/test-utils": {
|
|
60
|
-
"types": "./dist/vitest-plugin/test-utils.d.ts",
|
|
61
|
-
"import": "./dist/vitest-plugin/test-utils.mjs",
|
|
62
|
-
"require": "./dist/vitest-plugin/test-utils.js"
|
|
63
|
-
},
|
|
64
|
-
"./internal/coverage-reporter": {
|
|
65
|
-
"types": "./dist/node/coverage-reporter.d.ts",
|
|
66
|
-
"import": "./dist/node/coverage-reporter.mjs",
|
|
67
|
-
"require": "./dist/node/coverage-reporter.js"
|
|
43
|
+
"default": "./dist/index.js"
|
|
68
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",
|
|
69
49
|
"./manager": "./dist/manager.js",
|
|
70
|
-
"./
|
|
50
|
+
"./package.json": "./package.json",
|
|
71
51
|
"./postinstall": "./dist/postinstall.js",
|
|
72
|
-
"./
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"typesVersions": {
|
|
78
|
-
"*": {
|
|
79
|
-
"*": [
|
|
80
|
-
"dist/index.d.ts"
|
|
81
|
-
]
|
|
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"
|
|
82
57
|
}
|
|
83
58
|
},
|
|
84
59
|
"files": [
|
|
@@ -93,12 +68,12 @@
|
|
|
93
68
|
"!src/**/*"
|
|
94
69
|
],
|
|
95
70
|
"scripts": {
|
|
96
|
-
"check": "jiti ../../../scripts/
|
|
97
|
-
"prep": "jiti ../../../scripts/
|
|
71
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
72
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
98
73
|
},
|
|
99
74
|
"dependencies": {
|
|
100
75
|
"@storybook/global": "^5.0.0",
|
|
101
|
-
"@storybook/icons": "^1.
|
|
76
|
+
"@storybook/icons": "^1.6.0",
|
|
102
77
|
"prompts": "^2.4.0",
|
|
103
78
|
"ts-dedent": "^2.2.0"
|
|
104
79
|
},
|
|
@@ -110,9 +85,9 @@
|
|
|
110
85
|
"@vitest/browser": "^3.2.4",
|
|
111
86
|
"@vitest/runner": "^3.2.4",
|
|
112
87
|
"boxen": "^8.0.1",
|
|
88
|
+
"empathic": "^2.0.0",
|
|
113
89
|
"es-toolkit": "^1.36.0",
|
|
114
90
|
"execa": "^8.0.1",
|
|
115
|
-
"find-up": "^7.0.0",
|
|
116
91
|
"istanbul-lib-report": "^3.0.1",
|
|
117
92
|
"micromatch": "^4.0.8",
|
|
118
93
|
"pathe": "^1.1.2",
|
|
@@ -131,7 +106,7 @@
|
|
|
131
106
|
"peerDependencies": {
|
|
132
107
|
"@vitest/browser": "^3.0.0",
|
|
133
108
|
"@vitest/runner": "^3.0.0",
|
|
134
|
-
"storybook": "^0.0.0-pr-
|
|
109
|
+
"storybook": "^0.0.0-pr-32758-sha-3071b498",
|
|
135
110
|
"vitest": "^3.0.0"
|
|
136
111
|
},
|
|
137
112
|
"peerDependenciesMeta": {
|
|
@@ -148,54 +123,6 @@
|
|
|
148
123
|
"publishConfig": {
|
|
149
124
|
"access": "public"
|
|
150
125
|
},
|
|
151
|
-
"bundler": {
|
|
152
|
-
"exportEntries": [
|
|
153
|
-
"./src/index.ts",
|
|
154
|
-
"./src/vitest-plugin/test-utils.ts",
|
|
155
|
-
"./src/vitest-plugin/setup-file.ts"
|
|
156
|
-
],
|
|
157
|
-
"managerEntries": [
|
|
158
|
-
"./src/manager.tsx"
|
|
159
|
-
],
|
|
160
|
-
"nodeEntries": [
|
|
161
|
-
"./src/preset.ts",
|
|
162
|
-
"./src/postinstall.ts",
|
|
163
|
-
{
|
|
164
|
-
"file": "./src/dummy.ts",
|
|
165
|
-
"formats": [
|
|
166
|
-
"esm"
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
"file": "./src/node/vitest.ts",
|
|
171
|
-
"formats": [
|
|
172
|
-
"esm",
|
|
173
|
-
"cjs"
|
|
174
|
-
]
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
"file": "./src/node/coverage-reporter.ts",
|
|
178
|
-
"formats": [
|
|
179
|
-
"esm",
|
|
180
|
-
"cjs"
|
|
181
|
-
]
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"file": "./src/vitest-plugin/index.ts",
|
|
185
|
-
"formats": [
|
|
186
|
-
"cjs",
|
|
187
|
-
"esm"
|
|
188
|
-
]
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"file": "./src/vitest-plugin/global-setup.ts",
|
|
192
|
-
"formats": [
|
|
193
|
-
"cjs",
|
|
194
|
-
"esm"
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
]
|
|
198
|
-
},
|
|
199
126
|
"storybook": {
|
|
200
127
|
"displayName": "Test",
|
|
201
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 };
|