storybook 10.0.0-beta.6 → 10.0.0-beta.8
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-YQV3EGQ5.js → chunk-OQ6NCFPL.js} +38 -15
- package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
- package/dist/_node-chunks/{builder-manager-V33CQT2M.js → builder-manager-Y34L3HC4.js} +30 -15
- package/dist/_node-chunks/camelcase-W6EWLMZP.js +18 -0
- package/dist/_node-chunks/{chunk-A7CUP23N.js → chunk-3VCGPS3V.js} +7 -7
- package/dist/_node-chunks/{chunk-EAOPWIKA.js → chunk-4QSDBUYK.js} +8 -8
- package/dist/_node-chunks/{chunk-UYKQJMQY.js → chunk-4SIVISOF.js} +21 -27
- package/dist/_node-chunks/{chunk-MLBTKECD.js → chunk-5SPDSTWP.js} +7 -7
- package/dist/_node-chunks/{chunk-VQH4ZFTS.js → chunk-6NAUDAPE.js} +8 -8
- package/dist/_node-chunks/{chunk-NUVGSFQI.js → chunk-6SXRGPL6.js} +7 -7
- package/dist/_node-chunks/{chunk-2DMFI367.js → chunk-7JZFWQN4.js} +72 -8
- package/dist/_node-chunks/{chunk-IINJT47N.js → chunk-7Q5EKYUL.js} +7 -7
- package/dist/_node-chunks/{chunk-B3AMFGAL.js → chunk-AND2M2X5.js} +7 -7
- package/dist/_node-chunks/{chunk-RIPA4LFD.js → chunk-AZWKFSEJ.js} +108 -76
- package/dist/_node-chunks/{chunk-7NJGTQ3W.js → chunk-CL53RP5L.js} +8 -8
- package/dist/_node-chunks/{chunk-BNOZ3EKF.js → chunk-CZLW5B2W.js} +7 -7
- package/dist/_node-chunks/{chunk-DC7OWBHB.js → chunk-DRNU7FEF.js} +12 -12
- package/dist/_node-chunks/{chunk-VSC6LSCQ.js → chunk-EMCS3ZKS.js} +6 -6
- package/dist/_node-chunks/{chunk-EY5PTUZL.js → chunk-F43CI3CD.js} +10 -10
- package/dist/_node-chunks/{chunk-XZTBG2TG.js → chunk-FRTUAT3V.js} +6 -6
- package/dist/_node-chunks/{chunk-JNHUDBJL.js → chunk-HRBWZFVH.js} +7 -7
- package/dist/_node-chunks/{chunk-55VWKF63.js → chunk-IE2VBA4V.js} +9 -9
- package/dist/_node-chunks/{chunk-5IEY46LQ.js → chunk-JEIQPNWQ.js} +7 -7
- package/dist/_node-chunks/{chunk-NKZ4UPPV.js → chunk-JG7IEUS3.js} +7 -7
- package/dist/_node-chunks/{chunk-HEBHWRWL.js → chunk-LKGWQEHR.js} +7 -7
- package/dist/_node-chunks/{chunk-6PTV7XGR.js → chunk-MIJKYKSO.js} +264 -109
- package/dist/_node-chunks/{chunk-F3PO67U3.js → chunk-O33XSHQE.js} +7 -7
- package/dist/_node-chunks/{chunk-HPFXREVG.js → chunk-SOIRRZYG.js} +7 -7
- package/dist/_node-chunks/chunk-T46D5USU.js +18 -0
- package/dist/_node-chunks/{chunk-NJXBURX7.js → chunk-T5VNV7FG.js} +7 -7
- package/dist/_node-chunks/{chunk-E6TLN2J2.js → chunk-TL5UYDH2.js} +7 -7
- package/dist/_node-chunks/{chunk-JOXYGIZK.js → chunk-UORO6DG4.js} +9 -9
- package/dist/_node-chunks/chunk-USP6T4QU.js +62 -0
- package/dist/_node-chunks/{chunk-7WH7AGOR.js → chunk-WS3L7DA7.js} +7 -7
- package/dist/_node-chunks/{chunk-4TOI4VSK.js → chunk-YMZK6547.js} +7 -7
- package/dist/_node-chunks/{dist-CGGAYWME.js → dist-RINWIIFC.js} +9 -9
- package/dist/_node-chunks/{globby-3IFB7BJC.js → globby-G3CLKE4Y.js} +9 -9
- package/dist/_node-chunks/{lib-IT6OBSID.js → lib-67I574Z7.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-WM36SSZ6.js → mdx-N42X6CFJ-6DP2YFMY.js} +8 -8
- package/dist/_node-chunks/{p-limit-3V5XIKA7.js → p-limit-JBOY5PGK.js} +7 -7
- package/dist/_node-chunks/{plugin-3YREMMJJ.js → plugin-2IR6AOYP.js} +10 -10
- package/dist/_node-chunks/{plugin-GJUBUKCT.js → plugin-5XCSTKS6.js} +10 -10
- package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-DCJQFJQ5.js → webpack-inject-mocker-runtime-plugin-5FUND5HJ.js} +10 -10
- package/dist/_node-chunks/{webpack-mock-plugin-XJNFAHBI.js → webpack-mock-plugin-JVWSZ2PI.js} +9 -9
- package/dist/babel/index.js +11 -11
- package/dist/bin/core.js +11 -11
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +8 -8
- package/dist/cli/index.js +20 -20
- package/dist/common/index.js +20 -21
- package/dist/components/index.js +7 -3
- package/dist/core-server/index.js +90 -63
- package/dist/core-server/presets/common-manager.js +575 -531
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +22 -22
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -9
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -10
- package/dist/csf/index.d.ts +9 -4
- package/dist/csf/index.js +37 -8
- package/dist/csf-tools/index.d.ts +13 -6
- package/dist/csf-tools/index.js +9 -9
- package/dist/manager/globals-runtime.js +73 -34
- package/dist/manager/runtime.js +501 -257
- package/dist/manager-api/index.d.ts +11 -6
- package/dist/manager-api/index.js +69 -34
- package/dist/node-logger/index.js +14 -14
- package/dist/preview/globals.js +1 -1
- package/dist/preview/runtime.js +97 -63
- package/dist/preview-api/index.d.ts +70 -71
- package/dist/preview-api/index.js +1 -1
- package/dist/server-errors.js +10 -10
- package/dist/telemetry/index.js +23 -24
- package/dist/types/index.d.ts +24 -7
- package/dist/viewport/index.d.ts +36 -4
- package/dist/viewport/index.js +1 -1
- package/package.json +1 -33
- package/dist/_node-chunks/camelcase-BZ55OCHI.js +0 -18
- package/dist/_node-chunks/chunk-FDDJHDCE.js +0 -62
- package/dist/_node-chunks/chunk-R5DIBOM6.js +0 -18
- package/dist/_node-chunks/chunk-TJIMCNYJ.js +0 -80
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_7kszd2fgfzq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_7kszd2fgfzq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_7kszd2fgfzq from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_7kszd2fgfzq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_7kszd2fgfzq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_7kszd2fgfzq.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
require_dist
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-5SPDSTWP.js";
|
|
15
15
|
import {
|
|
16
16
|
__name,
|
|
17
17
|
__toESM
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FRTUAT3V.js";
|
|
19
19
|
|
|
20
20
|
// src/csf-tools/CsfFile.ts
|
|
21
21
|
var import_ts_dedent = __toESM(require_dist(), 1);
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
types as t2,
|
|
29
29
|
traverse
|
|
30
30
|
} from "storybook/internal/babel";
|
|
31
|
-
import { isExportStory, storyNameFromExport, toId } from "storybook/internal/csf";
|
|
31
|
+
import { isExportStory, storyNameFromExport, toId, toTestId } from "storybook/internal/csf";
|
|
32
32
|
import { logger } from "storybook/internal/node-logger";
|
|
33
33
|
|
|
34
34
|
// src/csf-tools/findVarInitialization.ts
|
|
@@ -86,6 +86,29 @@ function parseTags(prop) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
__name(parseTags, "parseTags");
|
|
89
|
+
function parseTestTags(optionsNode, program) {
|
|
90
|
+
if (!optionsNode) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
let node = optionsNode;
|
|
94
|
+
if (t2.isIdentifier(node)) {
|
|
95
|
+
node = findVarInitialization(node.name, program);
|
|
96
|
+
}
|
|
97
|
+
if (t2.isObjectExpression(node)) {
|
|
98
|
+
const tagsProp = node.properties.find(
|
|
99
|
+
(property) => t2.isObjectProperty(property) && t2.isIdentifier(property.key) && property.key.name === "tags"
|
|
100
|
+
);
|
|
101
|
+
if (tagsProp) {
|
|
102
|
+
let tagsNode = tagsProp.value;
|
|
103
|
+
if (t2.isIdentifier(tagsNode)) {
|
|
104
|
+
tagsNode = findVarInitialization(tagsNode.name, program);
|
|
105
|
+
}
|
|
106
|
+
return parseTags(tagsNode);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
__name(parseTestTags, "parseTestTags");
|
|
89
112
|
var formatLocation = /* @__PURE__ */ __name((node, fileName) => {
|
|
90
113
|
let loc = "";
|
|
91
114
|
if (node.loc) {
|
|
@@ -221,6 +244,7 @@ var CsfFile = class {
|
|
|
221
244
|
this._storyStatements = {};
|
|
222
245
|
this._storyAnnotations = {};
|
|
223
246
|
this._templates = {};
|
|
247
|
+
this._tests = [];
|
|
224
248
|
this._ast = ast;
|
|
225
249
|
this._file = file;
|
|
226
250
|
this._options = options;
|
|
@@ -547,6 +571,24 @@ var CsfFile = class {
|
|
|
547
571
|
story.name = storyName;
|
|
548
572
|
}
|
|
549
573
|
}
|
|
574
|
+
if (t2.isCallExpression(expression) && t2.isMemberExpression(expression.callee) && t2.isIdentifier(expression.callee.object) && t2.isIdentifier(expression.callee.property) && expression.callee.property.name === "test" && expression.arguments.length >= 2 && t2.isStringLiteral(expression.arguments[0])) {
|
|
575
|
+
const exportName = expression.callee.object.name;
|
|
576
|
+
const testName = expression.arguments[0].value;
|
|
577
|
+
const testFunction = expression.arguments.length === 2 ? expression.arguments[1] : expression.arguments[2];
|
|
578
|
+
const testArguments = expression.arguments.length === 2 ? null : expression.arguments[1];
|
|
579
|
+
const tags = parseTestTags(testArguments, self._ast.program);
|
|
580
|
+
self._tests.push({
|
|
581
|
+
function: testFunction,
|
|
582
|
+
name: testName,
|
|
583
|
+
node: expression,
|
|
584
|
+
// can't set id because meta title isn't available yet
|
|
585
|
+
// so it's set later on
|
|
586
|
+
id: "FIXME",
|
|
587
|
+
tags,
|
|
588
|
+
parent: { node: self._storyStatements[exportName] }
|
|
589
|
+
});
|
|
590
|
+
self._stories[exportName].__stats.tests = true;
|
|
591
|
+
}
|
|
550
592
|
}
|
|
551
593
|
},
|
|
552
594
|
CallExpression: {
|
|
@@ -565,9 +607,12 @@ var CsfFile = class {
|
|
|
565
607
|
const configParent = configCandidate?.path?.parentPath?.node;
|
|
566
608
|
if (t2.isImportDeclaration(configParent)) {
|
|
567
609
|
if (isValidPreviewPath(configParent.source.value)) {
|
|
568
|
-
const metaNode = node.arguments[0];
|
|
569
|
-
self._metaVariableName = callee.property.name;
|
|
570
610
|
self._metaIsFactory = true;
|
|
611
|
+
const metaDeclarator = path.findParent(
|
|
612
|
+
(p) => p.isVariableDeclarator()
|
|
613
|
+
);
|
|
614
|
+
self._metaVariableName = t2.isIdentifier(metaDeclarator.node.id) ? metaDeclarator.node.id.name : callee.property.name;
|
|
615
|
+
const metaNode = node.arguments[0];
|
|
571
616
|
self._parseMeta(metaNode, self._ast.program);
|
|
572
617
|
} else {
|
|
573
618
|
throw new BadMetaError(
|
|
@@ -628,6 +673,14 @@ var CsfFile = class {
|
|
|
628
673
|
stats.storyFn = !!(t2.isArrowFunctionExpression(storyExport) || t2.isFunctionDeclaration(storyExport));
|
|
629
674
|
stats.mount = hasMount(storyAnnotations.play ?? self._metaAnnotations.play);
|
|
630
675
|
stats.moduleMock = !!self.imports.find((fname) => isModuleMock(fname));
|
|
676
|
+
const storyNode = self._storyStatements[key];
|
|
677
|
+
const storyTests = self._tests.filter((t7) => t7.parent.node === storyNode);
|
|
678
|
+
if (storyTests.length > 0) {
|
|
679
|
+
stats.tests = true;
|
|
680
|
+
storyTests.forEach((test) => {
|
|
681
|
+
test.id = toTestId(id, test.name);
|
|
682
|
+
});
|
|
683
|
+
}
|
|
631
684
|
return acc;
|
|
632
685
|
},
|
|
633
686
|
{}
|
|
@@ -660,6 +713,13 @@ var CsfFile = class {
|
|
|
660
713
|
get stories() {
|
|
661
714
|
return Object.values(this._stories);
|
|
662
715
|
}
|
|
716
|
+
getStoryTests(story) {
|
|
717
|
+
const storyNode = typeof story === "string" ? this._storyStatements[story] : story;
|
|
718
|
+
if (!storyNode) {
|
|
719
|
+
return [];
|
|
720
|
+
}
|
|
721
|
+
return this._tests.filter((t7) => t7.parent.node === storyNode);
|
|
722
|
+
}
|
|
663
723
|
get indexInputs() {
|
|
664
724
|
const { fileName } = this._options;
|
|
665
725
|
if (!fileName) {
|
|
@@ -668,21 +728,52 @@ var CsfFile = class {
|
|
|
668
728
|
Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
|
|
669
729
|
);
|
|
670
730
|
}
|
|
671
|
-
|
|
731
|
+
const index = [];
|
|
732
|
+
Object.entries(this._stories).map(([exportName, story]) => {
|
|
672
733
|
const tags = [...this._meta?.tags ?? [], ...story.tags ?? []];
|
|
673
|
-
|
|
674
|
-
type: "story",
|
|
734
|
+
const storyInput = {
|
|
675
735
|
importPath: fileName,
|
|
676
736
|
rawComponentPath: this._rawComponentPath,
|
|
677
737
|
exportName,
|
|
678
|
-
name: story.name,
|
|
679
738
|
title: this.meta?.title,
|
|
680
739
|
metaId: this.meta?.id,
|
|
681
740
|
tags,
|
|
682
741
|
__id: story.id,
|
|
683
742
|
__stats: story.__stats
|
|
684
743
|
};
|
|
744
|
+
const tests = this.getStoryTests(exportName);
|
|
745
|
+
const hasTests = tests.length > 0;
|
|
746
|
+
index.push({
|
|
747
|
+
...storyInput,
|
|
748
|
+
type: "story",
|
|
749
|
+
subtype: "story",
|
|
750
|
+
name: story.name
|
|
751
|
+
});
|
|
752
|
+
if (hasTests) {
|
|
753
|
+
tests.forEach((test) => {
|
|
754
|
+
index.push({
|
|
755
|
+
...storyInput,
|
|
756
|
+
// TODO implementent proper title => path behavior in `transformStoryIndexToStoriesHash`
|
|
757
|
+
// title: `${storyInput.title}/${story.name}`,
|
|
758
|
+
type: "story",
|
|
759
|
+
subtype: "test",
|
|
760
|
+
name: test.name,
|
|
761
|
+
parent: story.id,
|
|
762
|
+
parentName: story.name,
|
|
763
|
+
tags: [
|
|
764
|
+
...storyInput.tags,
|
|
765
|
+
// this tag comes before test tags so users can invert if they like
|
|
766
|
+
"!autodocs",
|
|
767
|
+
...test.tags,
|
|
768
|
+
// this tag comes after test tags so users can't change it
|
|
769
|
+
"test-fn"
|
|
770
|
+
],
|
|
771
|
+
__id: test.id
|
|
772
|
+
});
|
|
773
|
+
});
|
|
774
|
+
}
|
|
685
775
|
});
|
|
776
|
+
return index;
|
|
686
777
|
}
|
|
687
778
|
};
|
|
688
779
|
var babelParseFile = /* @__PURE__ */ __name(({
|
|
@@ -1877,6 +1968,8 @@ var isValidTest = /* @__PURE__ */ __name((storyTags, tagsFilter) => {
|
|
|
1877
1968
|
}
|
|
1878
1969
|
return true;
|
|
1879
1970
|
}, "isValidTest");
|
|
1971
|
+
var DOUBLE_SPACES = " ";
|
|
1972
|
+
var getLiteralWithZeroWidthSpace = /* @__PURE__ */ __name((testTitle) => t6.stringLiteral(`${testTitle}${DOUBLE_SPACES}`), "getLiteralWithZeroWidthSpace");
|
|
1880
1973
|
async function vitestTransform({
|
|
1881
1974
|
code,
|
|
1882
1975
|
fileName,
|
|
@@ -1924,7 +2017,7 @@ async function vitestTransform({
|
|
|
1924
2017
|
);
|
|
1925
2018
|
}
|
|
1926
2019
|
const validStories = {};
|
|
1927
|
-
Object.keys(parsed._stories).
|
|
2020
|
+
Object.keys(parsed._stories).forEach((key) => {
|
|
1928
2021
|
const finalTags = combineTags(
|
|
1929
2022
|
"test",
|
|
1930
2023
|
"dev",
|
|
@@ -1945,7 +2038,7 @@ async function vitestTransform({
|
|
|
1945
2038
|
])
|
|
1946
2039
|
);
|
|
1947
2040
|
ast.program.body.push(describeSkipBlock);
|
|
1948
|
-
const
|
|
2041
|
+
const imports2 = [
|
|
1949
2042
|
t6.importDeclaration(
|
|
1950
2043
|
[
|
|
1951
2044
|
t6.importSpecifier(vitestTestId, t6.identifier("test")),
|
|
@@ -1954,103 +2047,165 @@ async function vitestTransform({
|
|
|
1954
2047
|
t6.stringLiteral("vitest")
|
|
1955
2048
|
)
|
|
1956
2049
|
];
|
|
1957
|
-
ast.program.body.unshift(...
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
]
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2050
|
+
ast.program.body.unshift(...imports2);
|
|
2051
|
+
return formatCsf(parsed, { sourceMaps: true, sourceFileName: fileName }, code);
|
|
2052
|
+
}
|
|
2053
|
+
const vitestExpectId = parsed._file.path.scope.generateUidIdentifier("expect");
|
|
2054
|
+
const testStoryId = parsed._file.path.scope.generateUidIdentifier("testStory");
|
|
2055
|
+
const skipTagsId = t6.identifier(JSON.stringify(tagsFilter.skip));
|
|
2056
|
+
function getTestGuardDeclaration() {
|
|
2057
|
+
const isRunningFromThisFileId2 = parsed._file.path.scope.generateUidIdentifier("isRunningFromThisFile");
|
|
2058
|
+
const testPathProperty = t6.memberExpression(
|
|
2059
|
+
t6.callExpression(t6.memberExpression(vitestExpectId, t6.identifier("getState")), []),
|
|
2060
|
+
t6.identifier("testPath")
|
|
2061
|
+
);
|
|
2062
|
+
const filePathProperty = t6.memberExpression(
|
|
2063
|
+
t6.memberExpression(t6.identifier("globalThis"), t6.identifier("__vitest_worker__")),
|
|
2064
|
+
t6.identifier("filepath")
|
|
2065
|
+
);
|
|
2066
|
+
const nullishCoalescingExpression = t6.logicalExpression(
|
|
2067
|
+
"??",
|
|
2068
|
+
// TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
|
|
2069
|
+
// https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
|
|
2070
|
+
filePathProperty,
|
|
2071
|
+
testPathProperty
|
|
2072
|
+
);
|
|
2073
|
+
const includesCall = t6.callExpression(
|
|
2074
|
+
t6.memberExpression(
|
|
2075
|
+
t6.callExpression(t6.identifier("convertToFilePath"), [
|
|
2076
|
+
t6.memberExpression(
|
|
2077
|
+
t6.memberExpression(t6.identifier("import"), t6.identifier("meta")),
|
|
2078
|
+
t6.identifier("url")
|
|
2079
|
+
)
|
|
2080
|
+
]),
|
|
2081
|
+
t6.identifier("includes")
|
|
2082
|
+
),
|
|
2083
|
+
[nullishCoalescingExpression]
|
|
2084
|
+
);
|
|
2085
|
+
const isRunningFromThisFileDeclaration2 = t6.variableDeclaration("const", [
|
|
2086
|
+
t6.variableDeclarator(isRunningFromThisFileId2, includesCall)
|
|
2087
|
+
]);
|
|
2088
|
+
return { isRunningFromThisFileDeclaration: isRunningFromThisFileDeclaration2, isRunningFromThisFileId: isRunningFromThisFileId2 };
|
|
2089
|
+
}
|
|
2090
|
+
__name(getTestGuardDeclaration, "getTestGuardDeclaration");
|
|
2091
|
+
const { isRunningFromThisFileDeclaration, isRunningFromThisFileId } = getTestGuardDeclaration();
|
|
2092
|
+
ast.program.body.push(isRunningFromThisFileDeclaration);
|
|
2093
|
+
const getTestStatementForStory = /* @__PURE__ */ __name(({
|
|
2094
|
+
localName,
|
|
2095
|
+
exportName,
|
|
2096
|
+
testTitle,
|
|
2097
|
+
node,
|
|
2098
|
+
overrideSourcemap = true,
|
|
2099
|
+
storyId
|
|
2100
|
+
}) => {
|
|
2101
|
+
const testStoryCall = t6.expressionStatement(
|
|
2102
|
+
t6.callExpression(vitestTestId, [
|
|
2103
|
+
t6.stringLiteral(testTitle),
|
|
2104
|
+
t6.callExpression(testStoryId, [
|
|
2105
|
+
t6.stringLiteral(exportName),
|
|
2106
|
+
t6.identifier(localName),
|
|
2107
|
+
t6.identifier(metaExportName),
|
|
2108
|
+
skipTagsId,
|
|
2109
|
+
t6.stringLiteral(storyId)
|
|
2015
2110
|
])
|
|
2016
|
-
)
|
|
2111
|
+
])
|
|
2112
|
+
);
|
|
2113
|
+
if (overrideSourcemap) {
|
|
2017
2114
|
testStoryCall.loc = node.loc;
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2115
|
+
}
|
|
2116
|
+
return testStoryCall;
|
|
2117
|
+
}, "getTestStatementForStory");
|
|
2118
|
+
const getDescribeStatementForStory = /* @__PURE__ */ __name((options) => {
|
|
2119
|
+
const { localName, describeTitle, exportName, tests, node, parentStoryId } = options;
|
|
2120
|
+
const describeBlock = t6.callExpression(vitestDescribeId, [
|
|
2121
|
+
getLiteralWithZeroWidthSpace(describeTitle),
|
|
2122
|
+
t6.arrowFunctionExpression(
|
|
2123
|
+
[],
|
|
2124
|
+
t6.blockStatement([
|
|
2125
|
+
getTestStatementForStory({
|
|
2126
|
+
...options,
|
|
2127
|
+
testTitle: "base story",
|
|
2128
|
+
overrideSourcemap: false,
|
|
2129
|
+
storyId: parentStoryId
|
|
2130
|
+
}),
|
|
2131
|
+
...tests.map(({ name: testName, node: testNode, id: storyId }) => {
|
|
2132
|
+
const testStatement = t6.expressionStatement(
|
|
2133
|
+
t6.callExpression(vitestTestId, [
|
|
2134
|
+
t6.stringLiteral(testName),
|
|
2135
|
+
t6.callExpression(testStoryId, [
|
|
2136
|
+
t6.stringLiteral(exportName),
|
|
2137
|
+
t6.identifier(localName),
|
|
2138
|
+
t6.identifier(metaExportName),
|
|
2139
|
+
t6.arrayExpression([]),
|
|
2140
|
+
t6.stringLiteral(storyId),
|
|
2141
|
+
t6.stringLiteral(testName)
|
|
2142
|
+
])
|
|
2143
|
+
])
|
|
2144
|
+
);
|
|
2145
|
+
testStatement.loc = testNode.loc;
|
|
2146
|
+
return testStatement;
|
|
2147
|
+
})
|
|
2148
|
+
])
|
|
2149
|
+
)
|
|
2150
|
+
]);
|
|
2151
|
+
describeBlock.loc = node.loc;
|
|
2152
|
+
return t6.expressionStatement(describeBlock);
|
|
2153
|
+
}, "getDescribeStatementForStory");
|
|
2154
|
+
const storyTestStatements = Object.entries(validStories).map(([exportName, node]) => {
|
|
2155
|
+
if (node === null) {
|
|
2156
|
+
logger4.warn(
|
|
2157
|
+
import_ts_dedent4.dedent`
|
|
2024
2158
|
[Storybook]: Could not transform "${exportName}" story into test at "${fileName}".
|
|
2025
2159
|
Please make sure to define stories in the same file and not re-export stories coming from other files".
|
|
2026
2160
|
`
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2161
|
+
);
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const localName = parsed._stories[exportName].localName ?? exportName;
|
|
2165
|
+
const testTitle = parsed._stories[exportName].name ?? exportName;
|
|
2166
|
+
const storyId = parsed._stories[exportName].id;
|
|
2167
|
+
const tests = parsed.getStoryTests(exportName);
|
|
2168
|
+
if (tests?.length > 0) {
|
|
2169
|
+
return getDescribeStatementForStory({
|
|
2170
|
+
localName,
|
|
2171
|
+
describeTitle: testTitle,
|
|
2172
|
+
exportName,
|
|
2173
|
+
tests,
|
|
2174
|
+
node,
|
|
2175
|
+
parentStoryId: storyId
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
return getTestStatementForStory({
|
|
2179
|
+
testTitle,
|
|
2180
|
+
localName,
|
|
2181
|
+
exportName,
|
|
2182
|
+
node,
|
|
2183
|
+
storyId
|
|
2184
|
+
});
|
|
2185
|
+
}).filter((st) => !!st);
|
|
2186
|
+
const testBlock = t6.ifStatement(isRunningFromThisFileId, t6.blockStatement(storyTestStatements));
|
|
2187
|
+
ast.program.body.push(testBlock);
|
|
2188
|
+
const hasTests = Object.keys(validStories).some(
|
|
2189
|
+
(exportName) => parsed.getStoryTests(exportName).length > 0
|
|
2190
|
+
);
|
|
2191
|
+
const imports = [
|
|
2192
|
+
t6.importDeclaration(
|
|
2193
|
+
[
|
|
2194
|
+
t6.importSpecifier(vitestTestId, t6.identifier("test")),
|
|
2195
|
+
t6.importSpecifier(vitestExpectId, t6.identifier("expect")),
|
|
2196
|
+
...hasTests ? [t6.importSpecifier(vitestDescribeId, t6.identifier("describe"))] : []
|
|
2197
|
+
],
|
|
2198
|
+
t6.stringLiteral("vitest")
|
|
2199
|
+
),
|
|
2200
|
+
t6.importDeclaration(
|
|
2201
|
+
[
|
|
2202
|
+
t6.importSpecifier(testStoryId, t6.identifier("testStory")),
|
|
2203
|
+
t6.importSpecifier(t6.identifier("convertToFilePath"), t6.identifier("convertToFilePath"))
|
|
2204
|
+
],
|
|
2205
|
+
t6.stringLiteral("@storybook/addon-vitest/internal/test-utils")
|
|
2206
|
+
)
|
|
2207
|
+
];
|
|
2208
|
+
ast.program.body.unshift(...imports);
|
|
2054
2209
|
return formatCsf(parsed, { sourceMaps: true, sourceFileName: fileName }, code);
|
|
2055
2210
|
}
|
|
2056
2211
|
__name(vitestTransform, "vitestTransform");
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_7kszd2fgfzq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_7kszd2fgfzq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_7kszd2fgfzq from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_7kszd2fgfzq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_7kszd2fgfzq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_7kszd2fgfzq.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
__name
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FRTUAT3V.js";
|
|
15
15
|
|
|
16
16
|
// ../node_modules/empathic/resolve.mjs
|
|
17
17
|
import { createRequire } from "node:module";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_7kszd2fgfzq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_7kszd2fgfzq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_7kszd2fgfzq from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_7kszd2fgfzq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_7kszd2fgfzq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_7kszd2fgfzq.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
__name
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FRTUAT3V.js";
|
|
15
15
|
|
|
16
16
|
// ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
17
17
|
var isProduction = process.env.NODE_ENV === "production";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_7kszd2fgfzq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_7kszd2fgfzq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_7kszd2fgfzq from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_7kszd2fgfzq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_7kszd2fgfzq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_7kszd2fgfzq.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// package.json
|
|
14
|
+
var version = "10.0.0-beta.8";
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
version
|
|
18
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_7kszd2fgfzq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_7kszd2fgfzq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_7kszd2fgfzq from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_7kszd2fgfzq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_7kszd2fgfzq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_7kszd2fgfzq.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
__commonJS,
|
|
14
14
|
__name,
|
|
15
15
|
__toESM
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FRTUAT3V.js";
|
|
17
17
|
|
|
18
18
|
// ../node_modules/balanced-match/index.js
|
|
19
19
|
var require_balanced_match = __commonJS({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_7kszd2fgfzq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_7kszd2fgfzq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_7kszd2fgfzq from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_7kszd2fgfzq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_7kszd2fgfzq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_7kszd2fgfzq.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
__commonJS,
|
|
14
14
|
__name,
|
|
15
15
|
__require
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FRTUAT3V.js";
|
|
17
17
|
|
|
18
18
|
// ../node_modules/kleur/index.js
|
|
19
19
|
var require_kleur = __commonJS({
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_7kszd2fgfzq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_7kszd2fgfzq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_7kszd2fgfzq from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_7kszd2fgfzq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_7kszd2fgfzq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_7kszd2fgfzq.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
require_dist
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-5SPDSTWP.js";
|
|
15
15
|
import {
|
|
16
16
|
require_picocolors
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-JEIQPNWQ.js";
|
|
18
18
|
import {
|
|
19
19
|
__name,
|
|
20
20
|
__toESM
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-FRTUAT3V.js";
|
|
22
22
|
|
|
23
23
|
// src/server-errors.ts
|
|
24
24
|
var import_picocolors = __toESM(require_picocolors(), 1);
|