@storybook/testing-react
Advanced tools
Comparing version 1.3.0 to 2.0.0--canary.120.9304a9f.0
@@ -1,2 +0,2 @@ | ||
import type { Meta, ReactFramework } from '@storybook/react'; | ||
import type { Meta } from '@storybook/react'; | ||
import type { GlobalConfig, StoriesWithPartialProps, StoryFile, TestingStory, TestingStoryPlayContext } from './types'; | ||
@@ -46,8 +46,8 @@ /** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder. | ||
export declare function composeStory<GenericArgs>(story: TestingStory<GenericArgs>, meta: Meta<GenericArgs | any>, globalConfig?: GlobalConfig): { | ||
(extraArgs: Partial<GenericArgs>): import("@storybook/react/dist/ts3.9/client/preview/types").StoryFnReactReturnType; | ||
(extraArgs: Partial<GenericArgs>): import("@storybook/react/dist/types-53756156").S; | ||
storyName: string | undefined; | ||
args: GenericArgs; | ||
play: ({ ...extraContext }: TestingStoryPlayContext<GenericArgs>) => void | Promise<void> | undefined; | ||
decorators: (import("@storybook/csf").DecoratorFunction<ReactFramework, import("@storybook/addons").Args> | import("@storybook/csf").DecoratorFunction<ReactFramework, GenericArgs> | import("@storybook/csf").DecoratorFunction<ReactFramework, any>)[]; | ||
parameters: import("@storybook/addons").Parameters; | ||
decorators: any[]; | ||
parameters: import("@storybook/types").Parameters; | ||
}; | ||
@@ -54,0 +54,0 @@ /** |
@@ -7,5 +7,4 @@ 'use strict'; | ||
var clientApi = require('@storybook/client-api'); | ||
var store = require('@storybook/store'); | ||
var addons = require('@storybook/addons'); | ||
var addons__default = _interopDefault(addons); | ||
var csf = require('@storybook/csf'); | ||
@@ -78,5 +77,5 @@ var React = _interopDefault(require('react')); | ||
addons__default.setChannel(addons.mockChannel()); | ||
addons.addons.setChannel(addons.mockChannel()); | ||
var globalStorybookConfig = {}; | ||
var decorateStory = /*#__PURE__*/addons.applyHooks(clientApi.defaultDecorateStory); | ||
var decorateStory = /*#__PURE__*/addons.applyHooks(store.defaultDecorateStory); | ||
@@ -160,4 +159,5 @@ var isValidStoryExport = function isValidStoryExport(storyName, nonStoryExportsConfig) { | ||
throw new Error('composeStory does not support legacy style stories (with passArgsFirst = false).'); | ||
} | ||
} // @ts-expect-error (just trying to get this to build) | ||
return renderFn(context.args, context); | ||
@@ -178,3 +178,3 @@ }; | ||
}, {}); | ||
var combinedParameters = clientApi.combineParameters(globalConfig.parameters || {}, (meta == null ? void 0 : meta.parameters) || {}, story.parameters || {}, { | ||
var combinedParameters = store.combineParameters(globalConfig.parameters || {}, (meta == null ? void 0 : meta.parameters) || {}, story.parameters || {}, { | ||
component: meta == null ? void 0 : meta.component | ||
@@ -211,2 +211,3 @@ }); | ||
// @ts-expect-error (just trying to get this to build) | ||
return story.play == null ? void 0 : story.play(_extends({}, context, extraContext)); | ||
@@ -213,0 +214,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@storybook/client-api"),t=require("@storybook/addons"),o=r(t),n=require("@storybook/csf"),s=r(require("react"));function a(){return(a=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r}).apply(this,arguments)}var i=function(r,e){var t=e.parameters;if(!t.component)throw new Error("\n Could not render story due to missing 'component' property in Meta.\n Please refer to https://github.com/storybookjs/testing-react#csf3\n ");return s.createElement(t.component,a({},r))},u=new Set(["string","number","boolean","symbol"]),c=["default","__esModule"];o.setChannel(t.mockChannel());var l={},p=t.applyHooks(e.defaultDecorateStory);function d(r,o,n){var s,c;if(void 0===n&&(n=l),function(r){return!r||Array.isArray(r)||u.has(typeof r)}(r))throw new Error("Cannot compose story due to invalid format. @storybook/testing-react expected a function/object but received "+typeof r+" instead.");if(void 0!==r.story)throw new Error("StoryFn.story object-style annotation is not supported. @storybook/testing-react expects hoisted CSF stories.\n https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations");var d="function"==typeof r?r:null!=(s=null!=(c=r.render)?c:o.render)?s:i,y=[].concat(r.decorators||[],(null==o?void 0:o.decorators)||[],n.decorators||[]),f=p((function(r){var e=r.parameters.passArgsFirst;if(void 0!==e&&!e)throw new Error("composeStory does not support legacy style stories (with passArgsFirst = false).");return d(r.args,r)}),y),m=Object.entries(n.globalTypes||{}).reduce((function(r,e){var t=e[1].defaultValue;return t&&(r[e[0]]=t),r}),{}),b=e.combineParameters(n.parameters||{},(null==o?void 0:o.parameters)||{},r.parameters||{},{component:null==o?void 0:o.component}),v=a({},null==o?void 0:o.args,r.args),g={componentId:"",kind:"",title:"",id:"",name:"",story:"",argTypes:n.argTypes||{},globals:m,parameters:b,initialArgs:v,args:v,viewMode:"story",originalStoryFn:d,hooks:new t.HooksContext},h=function(r){return f(a({},g,{args:a({},v,r)}))};return h.storyName=r.storyName||r.name,h.args=v,h.play=function(e){var t=a({},e);return null==r.play?void 0:r.play(a({},g,t))},h.decorators=y,h.parameters=b,h}exports.composeStories=function(r,e){var t,o=r.default;return(t=function(r,e){if(null==r)return{};var t,o,n={},s=Object.keys(r);for(o=0;o<s.length;o++)e.indexOf(t=s[o])>=0||(n[t]=r[t]);return n}(r,c),Object.entries(t)).reduce((function(r,t){var s,a=t[0],i=t[1],u=String(a);if(!function(r,e){return void 0===e&&(e={}),n.isExportStory(r,e)&&"__namedExportsOrder"!==r}(u,o))return r;var c=i;return c.storyName=function(r){return r.storyName?r.storyName:"function"!=typeof r&&r.name?r.name:void 0}(c)||u,Object.assign(r,((s={})[a]=d(c,o,e),s))}),{})},exports.composeStory=d,exports.setGlobalConfig=function(r){l=r}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r,e=require("@storybook/store"),t=require("@storybook/addons"),o=require("@storybook/csf"),n=(r=require("react"))&&"object"==typeof r&&"default"in r?r.default:r;function s(){return(s=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r}).apply(this,arguments)}var a=function(r,e){var t=e.parameters;if(!t.component)throw new Error("\n Could not render story due to missing 'component' property in Meta.\n Please refer to https://github.com/storybookjs/testing-react#csf3\n ");return n.createElement(t.component,s({},r))},i=new Set(["string","number","boolean","symbol"]),u=["default","__esModule"];t.addons.setChannel(t.mockChannel());var c={},l=t.applyHooks(e.defaultDecorateStory);function p(r,o,n){var u,p;if(void 0===n&&(n=c),function(r){return!r||Array.isArray(r)||i.has(typeof r)}(r))throw new Error("Cannot compose story due to invalid format. @storybook/testing-react expected a function/object but received "+typeof r+" instead.");if(void 0!==r.story)throw new Error("StoryFn.story object-style annotation is not supported. @storybook/testing-react expects hoisted CSF stories.\n https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations");var d="function"==typeof r?r:null!=(u=null!=(p=r.render)?p:o.render)?u:a,y=[].concat(r.decorators||[],(null==o?void 0:o.decorators)||[],n.decorators||[]),f=l((function(r){var e=r.parameters.passArgsFirst;if(void 0!==e&&!e)throw new Error("composeStory does not support legacy style stories (with passArgsFirst = false).");return d(r.args,r)}),y),m=Object.entries(n.globalTypes||{}).reduce((function(r,e){var t=e[1].defaultValue;return t&&(r[e[0]]=t),r}),{}),b=e.combineParameters(n.parameters||{},(null==o?void 0:o.parameters)||{},r.parameters||{},{component:null==o?void 0:o.component}),v=s({},null==o?void 0:o.args,r.args),g={componentId:"",kind:"",title:"",id:"",name:"",story:"",argTypes:n.argTypes||{},globals:m,parameters:b,initialArgs:v,args:v,viewMode:"story",originalStoryFn:d,hooks:new t.HooksContext},h=function(r){return f(s({},g,{args:s({},v,r)}))};return h.storyName=r.storyName||r.name,h.args=v,h.play=function(e){var t=s({},e);return null==r.play?void 0:r.play(s({},g,t))},h.decorators=y,h.parameters=b,h}exports.composeStories=function(r,e){var t,n=r.default;return(t=function(r,e){if(null==r)return{};var t,o,n={},s=Object.keys(r);for(o=0;o<s.length;o++)e.indexOf(t=s[o])>=0||(n[t]=r[t]);return n}(r,u),Object.entries(t)).reduce((function(r,t){var s,a=t[0],i=t[1],u=String(a);if(!function(r,e){return void 0===e&&(e={}),o.isExportStory(r,e)&&"__namedExportsOrder"!==r}(u,n))return r;var c=i;return c.storyName=function(r){return r.storyName?r.storyName:"function"!=typeof r&&r.name?r.name:void 0}(c)||u,Object.assign(r,((s={})[a]=p(c,n,e),s))}),{})},exports.composeStory=p,exports.setGlobalConfig=function(r){c=r}; | ||
//# sourceMappingURL=testing-react.cjs.production.min.js.map |
@@ -1,3 +0,3 @@ | ||
import { combineParameters, defaultDecorateStory } from '@storybook/client-api'; | ||
import addons, { mockChannel, HooksContext, applyHooks } from '@storybook/addons'; | ||
import { combineParameters, defaultDecorateStory } from '@storybook/store'; | ||
import { addons, mockChannel, HooksContext, applyHooks } from '@storybook/addons'; | ||
import { isExportStory } from '@storybook/csf'; | ||
@@ -151,4 +151,5 @@ import React from 'react'; | ||
throw new Error('composeStory does not support legacy style stories (with passArgsFirst = false).'); | ||
} | ||
} // @ts-expect-error (just trying to get this to build) | ||
return renderFn(context.args, context); | ||
@@ -201,2 +202,3 @@ }; | ||
// @ts-expect-error (just trying to get this to build) | ||
return story.play == null ? void 0 : story.play(_extends({}, context, extraContext)); | ||
@@ -203,0 +205,0 @@ }; |
@@ -1,4 +0,4 @@ | ||
import type { BaseAnnotations, BaseStoryFn as OriginalBaseStoryFn } from '@storybook/addons'; | ||
import type { WebProjectAnnotations } from '@storybook/preview-web'; | ||
import type { StoryFn as OriginalStoryFn, StoryObj, Meta, Args, StoryContext, ReactFramework } from '@storybook/react'; | ||
import type { BaseStoryFn as OriginalBaseStoryFn } from '@storybook/addons'; | ||
import type { BaseAnnotations, Store_WebProjectAnnotations, StoryContext, Args } from '@storybook/types'; | ||
import type { StoryFn as OriginalStoryFn, StoryObj, Meta, ReactFramework } from '@storybook/react'; | ||
import type { ReactElement } from 'react'; | ||
@@ -13,3 +13,3 @@ declare type StoryFnReactReturnType = ReactElement<unknown>; | ||
*/ | ||
export declare type GlobalConfig = WebProjectAnnotations<ReactFramework>; | ||
export declare type GlobalConfig = Store_WebProjectAnnotations<ReactFramework>; | ||
export declare type TestingStory<T = Args> = StoryFn<T> | StoryObj<T>; | ||
@@ -16,0 +16,0 @@ export declare type StoryFile = { |
{ | ||
"name": "@storybook/testing-react", | ||
"version": "1.3.0", | ||
"version": "2.0.0--canary.120.9304a9f.0", | ||
"description": "Testing utilities that allow you to reuse your stories in your unit tests", | ||
@@ -64,5 +64,7 @@ "keywords": [ | ||
"@size-limit/preset-small-lib": "^4.10.1", | ||
"@storybook/addons": "^6.4.0", | ||
"@storybook/client-api": "^6.4.0", | ||
"@storybook/react": "^6.4.0", | ||
"@storybook/addons": "^7.0.0-alpha.49", | ||
"@storybook/react": "^7.0.0-alpha.49", | ||
"@storybook/store": "^7.0.0-alpha.49", | ||
"@storybook/types": "^7.0.0-alpha.49", | ||
"@types/react": "17", | ||
"auto": "^10.31.0", | ||
@@ -79,5 +81,5 @@ "concurrently": "^6.0.0", | ||
"@storybook/addons": ">=6.4.0", | ||
"@storybook/client-api": ">=6.4.0", | ||
"@storybook/preview-web": ">=6.4.0", | ||
"@storybook/react": ">=6.4.0", | ||
"@storybook/store": ">=6.4.0", | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||
@@ -101,4 +103,4 @@ }, | ||
"dependencies": { | ||
"@storybook/csf": "0.0.2--canary.87bc651.0" | ||
"@storybook/csf": "next" | ||
} | ||
} |
@@ -1,5 +0,6 @@ | ||
import { defaultDecorateStory, combineParameters } from '@storybook/client-api'; | ||
import addons, { applyHooks, HooksContext, mockChannel } from '@storybook/addons'; | ||
import type { Meta, StoryContext, ReactFramework } from '@storybook/react'; | ||
import { isExportStory } from '@storybook/csf' | ||
import { defaultDecorateStory, combineParameters } from '@storybook/store'; | ||
import { addons, applyHooks, HooksContext, mockChannel } from '@storybook/addons'; | ||
import type { Meta, ReactFramework } from '@storybook/react'; | ||
import type { StoryContext } from '@storybook/types'; | ||
import { isExportStory } from '@storybook/csf'; | ||
@@ -92,2 +93,3 @@ import type { GlobalConfig, StoriesWithPartialProps, StoryFile, TestingStory, TestingStoryPlayContext } from './types'; | ||
// @ts-expect-error (just trying to get this to build) | ||
return renderFn(context.args, context); | ||
@@ -155,2 +157,3 @@ }; | ||
const boundPlay = ({ ...extraContext }: TestingStoryPlayContext<GenericArgs>) => { | ||
// @ts-expect-error (just trying to get this to build) | ||
return story.play?.({ ...context, ...extraContext }); | ||
@@ -233,2 +236,2 @@ } | ||
return composedStories as unknown as Omit<StoriesWithPartialProps<TModule>, keyof StoryFile>; | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
import type { BaseAnnotations, BaseStoryFn as OriginalBaseStoryFn } from '@storybook/addons'; | ||
import type { WebProjectAnnotations } from '@storybook/preview-web'; | ||
import type { StoryFn as OriginalStoryFn, StoryObj, Meta, Args,StoryContext, ReactFramework } from '@storybook/react'; | ||
import type { BaseStoryFn as OriginalBaseStoryFn } from '@storybook/addons'; | ||
import type { BaseAnnotations, Store_WebProjectAnnotations, StoryContext, Args } from '@storybook/types'; | ||
import type { StoryFn as OriginalStoryFn, StoryObj, Meta, ReactFramework } from '@storybook/react'; | ||
import type { ReactElement } from 'react'; | ||
@@ -15,3 +15,3 @@ | ||
*/ | ||
export type GlobalConfig = WebProjectAnnotations<ReactFramework>; | ||
export type GlobalConfig = Store_WebProjectAnnotations<ReactFramework>; | ||
@@ -18,0 +18,0 @@ export type TestingStory<T = Args> = StoryFn<T> | StoryObj<T>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
113742
873
17
3
+ Added@storybook/csf@0.1.13-next.0(transitive)
+ Added@storybook/store@7.6.20(transitive)
- Removed@storybook/client-api@7.6.20(transitive)
- Removed@storybook/csf@0.0.2--canary.87bc651.0(transitive)
Updated@storybook/csf@next