@storybook/test 0.0.0-pr-24225-sha-5ffd56a7 → 0.0.0-pr-24225-sha-fa4f5fec

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion, ExpectStatic } from '@vitest/expect';
2
2
  import { TestingLibraryMatchers } from '@testing-library/jest-dom/types/matchers';
3
- import * as spy from '@vitest/spy';
4
3
  export * from '@vitest/spy';
5
4
  import * as _testing_library_user_event_dist_types_setup_directApi from '@testing-library/user-event/dist/types/setup/directApi';
6
5
  import * as _testing_library_user_event_dist_types_setup_setup from '@testing-library/user-event/dist/types/setup/setup';
7
6
  import * as domTestingLibrary from '@testing-library/dom';
8
- import { BoundFunctions } from '@testing-library/dom';
9
7
 
10
8
  type Promisify<Fn> = Fn extends (...args: infer A) => infer R ? (...args: A) => R extends Promise<any> ? R : Promise<R> : Fn;
11
9
  type PromisifyObject<O> = {
@@ -105,11 +103,11 @@ declare const queryByTestId: (container: HTMLElement, id: domTestingLibrary.Matc
105
103
  declare const queryByText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
106
104
  declare const queryByTitle: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
107
105
  declare const queryHelpers: typeof domTestingLibrary.queryHelpers;
106
+ declare const screen: domTestingLibrary.Screen<typeof domTestingLibrary.queries>;
108
107
  declare const waitFor: (callback: () => unknown, options?: domTestingLibrary.waitForOptions | undefined) => Promise<unknown>;
109
108
  declare const waitForElementToBeRemoved: (callback: unknown, options?: domTestingLibrary.waitForOptions | undefined) => Promise<void>;
110
- declare const within: (element: HTMLElement) => PromisifyObject<BoundFunctions<typeof domTestingLibrary.queries>>;
109
+ declare const within: typeof domTestingLibrary.getQueriesForElement;
111
110
  declare const prettyFormat: typeof domTestingLibrary.prettyFormat;
112
- declare const screen: domTestingLibrary.Screen<typeof domTestingLibrary.queries>;
113
111
  declare const userEvent: {
114
112
  readonly setup: typeof _testing_library_user_event_dist_types_setup_setup.setupMain;
115
113
  readonly clear: typeof _testing_library_user_event_dist_types_setup_directApi.clear;
@@ -130,7 +128,6 @@ declare const userEvent: {
130
128
  readonly tab: typeof _testing_library_user_event_dist_types_setup_directApi.tab;
131
129
  };
132
130
 
133
- declare const fn: typeof spy.fn;
134
131
  declare const expect: Expect;
135
132
 
136
- export { buildQueries, configure, createEvent, expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, fn, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, logDOM, logRoles, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, userEvent, waitFor, waitForElementToBeRemoved, within };
133
+ export { buildQueries, configure, createEvent, expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, logDOM, logRoles, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, userEvent, waitFor, waitForElementToBeRemoved, within };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";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 __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},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default")),__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);var src_exports={};__export(src_exports,{buildQueries:()=>buildQueries,configure:()=>configure,createEvent:()=>createEvent,expect:()=>expect3,findAllByAltText:()=>findAllByAltText,findAllByDisplayValue:()=>findAllByDisplayValue,findAllByLabelText:()=>findAllByLabelText,findAllByPlaceholderText:()=>findAllByPlaceholderText,findAllByRole:()=>findAllByRole,findAllByTestId:()=>findAllByTestId,findAllByText:()=>findAllByText,findAllByTitle:()=>findAllByTitle,findByAltText:()=>findByAltText,findByDisplayValue:()=>findByDisplayValue,findByLabelText:()=>findByLabelText,findByPlaceholderText:()=>findByPlaceholderText,findByRole:()=>findByRole,findByTestId:()=>findByTestId,findByText:()=>findByText,findByTitle:()=>findByTitle,fireEvent:()=>fireEvent,fn:()=>fn2,getAllByAltText:()=>getAllByAltText,getAllByDisplayValue:()=>getAllByDisplayValue,getAllByLabelText:()=>getAllByLabelText,getAllByPlaceholderText:()=>getAllByPlaceholderText,getAllByRole:()=>getAllByRole,getAllByTestId:()=>getAllByTestId,getAllByText:()=>getAllByText,getAllByTitle:()=>getAllByTitle,getByAltText:()=>getByAltText,getByDisplayValue:()=>getByDisplayValue,getByLabelText:()=>getByLabelText,getByPlaceholderText:()=>getByPlaceholderText,getByRole:()=>getByRole,getByTestId:()=>getByTestId,getByText:()=>getByText,getByTitle:()=>getByTitle,getConfig:()=>getConfig,getDefaultNormalizer:()=>getDefaultNormalizer,getElementError:()=>getElementError,getNodeText:()=>getNodeText,getQueriesForElement:()=>getQueriesForElement,getRoles:()=>getRoles,getSuggestedQuery:()=>getSuggestedQuery,isInaccessible:()=>isInaccessible,logDOM:()=>logDOM,logRoles:()=>logRoles,prettyDOM:()=>prettyDOM,prettyFormat:()=>prettyFormat,queries:()=>queries,queryAllByAltText:()=>queryAllByAltText,queryAllByAttribute:()=>queryAllByAttribute,queryAllByDisplayValue:()=>queryAllByDisplayValue,queryAllByLabelText:()=>queryAllByLabelText,queryAllByPlaceholderText:()=>queryAllByPlaceholderText,queryAllByRole:()=>queryAllByRole,queryAllByTestId:()=>queryAllByTestId,queryAllByText:()=>queryAllByText,queryAllByTitle:()=>queryAllByTitle,queryByAltText:()=>queryByAltText,queryByAttribute:()=>queryByAttribute,queryByDisplayValue:()=>queryByDisplayValue,queryByLabelText:()=>queryByLabelText,queryByPlaceholderText:()=>queryByPlaceholderText,queryByRole:()=>queryByRole,queryByTestId:()=>queryByTestId,queryByText:()=>queryByText,queryByTitle:()=>queryByTitle,queryHelpers:()=>queryHelpers,screen:()=>screen,userEvent:()=>userEvent,waitFor:()=>waitFor,waitForElementToBeRemoved:()=>waitForElementToBeRemoved,within:()=>within});module.exports=__toCommonJS(src_exports);var import_instrumenter2=require("@storybook/instrumenter"),spy=__toESM(require("@vitest/spy")),import_chai=__toESM(require("chai"));var chai=__toESM(require("chai")),import_expect=require("@vitest/expect"),matchers=__toESM(require("@testing-library/jest-dom/matchers"));function createExpect(){chai.use(import_expect.JestExtend),chai.use(import_expect.JestChaiExpect),chai.use(import_expect.JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=(0,import_expect.getState)(expect4);return(0,import_expect.setState)({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>(0,import_expect.getState)(expect4),expect4.setState=state=>(0,import_expect.setState)(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`)};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen})}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error})}return(0,import_expect.setState)({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,import_expect.GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});__reExport(src_exports,require("@vitest/spy"),module.exports);var import_client_logger=require("@storybook/client-logger"),import_instrumenter=require("@storybook/instrumenter"),domTestingLibrary=__toESM(require("@testing-library/dom")),import_user_event=__toESM(require("@testing-library/user-event")),import_ts_dedent=__toESM(require("ts-dedent")),testingLibrary=(0,import_instrumenter.instrument)({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")||method.startsWith("query")||method.startsWith("get")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return import_client_logger.once.warn(import_ts_dedent.default`
1
+ "use strict";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 __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},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default")),__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);var src_exports={};__export(src_exports,{buildQueries:()=>buildQueries,configure:()=>configure,createEvent:()=>createEvent,expect:()=>expect3,findAllByAltText:()=>findAllByAltText,findAllByDisplayValue:()=>findAllByDisplayValue,findAllByLabelText:()=>findAllByLabelText,findAllByPlaceholderText:()=>findAllByPlaceholderText,findAllByRole:()=>findAllByRole,findAllByTestId:()=>findAllByTestId,findAllByText:()=>findAllByText,findAllByTitle:()=>findAllByTitle,findByAltText:()=>findByAltText,findByDisplayValue:()=>findByDisplayValue,findByLabelText:()=>findByLabelText,findByPlaceholderText:()=>findByPlaceholderText,findByRole:()=>findByRole,findByTestId:()=>findByTestId,findByText:()=>findByText,findByTitle:()=>findByTitle,fireEvent:()=>fireEvent,getAllByAltText:()=>getAllByAltText,getAllByDisplayValue:()=>getAllByDisplayValue,getAllByLabelText:()=>getAllByLabelText,getAllByPlaceholderText:()=>getAllByPlaceholderText,getAllByRole:()=>getAllByRole,getAllByTestId:()=>getAllByTestId,getAllByText:()=>getAllByText,getAllByTitle:()=>getAllByTitle,getByAltText:()=>getByAltText,getByDisplayValue:()=>getByDisplayValue,getByLabelText:()=>getByLabelText,getByPlaceholderText:()=>getByPlaceholderText,getByRole:()=>getByRole,getByTestId:()=>getByTestId,getByText:()=>getByText,getByTitle:()=>getByTitle,getConfig:()=>getConfig,getDefaultNormalizer:()=>getDefaultNormalizer,getElementError:()=>getElementError,getNodeText:()=>getNodeText,getQueriesForElement:()=>getQueriesForElement,getRoles:()=>getRoles,getSuggestedQuery:()=>getSuggestedQuery,isInaccessible:()=>isInaccessible,logDOM:()=>logDOM,logRoles:()=>logRoles,prettyDOM:()=>prettyDOM,prettyFormat:()=>prettyFormat,queries:()=>queries,queryAllByAltText:()=>queryAllByAltText,queryAllByAttribute:()=>queryAllByAttribute,queryAllByDisplayValue:()=>queryAllByDisplayValue,queryAllByLabelText:()=>queryAllByLabelText,queryAllByPlaceholderText:()=>queryAllByPlaceholderText,queryAllByRole:()=>queryAllByRole,queryAllByTestId:()=>queryAllByTestId,queryAllByText:()=>queryAllByText,queryAllByTitle:()=>queryAllByTitle,queryByAltText:()=>queryByAltText,queryByAttribute:()=>queryByAttribute,queryByDisplayValue:()=>queryByDisplayValue,queryByLabelText:()=>queryByLabelText,queryByPlaceholderText:()=>queryByPlaceholderText,queryByRole:()=>queryByRole,queryByTestId:()=>queryByTestId,queryByText:()=>queryByText,queryByTitle:()=>queryByTitle,queryHelpers:()=>queryHelpers,screen:()=>screen,userEvent:()=>userEvent,waitFor:()=>waitFor,waitForElementToBeRemoved:()=>waitForElementToBeRemoved,within:()=>within});module.exports=__toCommonJS(src_exports);var import_instrumenter2=require("@storybook/instrumenter"),spy=__toESM(require("@vitest/spy")),import_chai=__toESM(require("chai")),import_core_events=require("@storybook/core-events"),import_preview_api=require("@storybook/preview-api");var chai=__toESM(require("chai")),import_expect=require("@vitest/expect"),matchers=__toESM(require("@testing-library/jest-dom/matchers"));function createExpect(){chai.use(import_expect.JestExtend),chai.use(import_expect.JestChaiExpect),chai.use(import_expect.JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=(0,import_expect.getState)(expect4);return(0,import_expect.setState)({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>(0,import_expect.getState)(expect4),expect4.setState=state=>(0,import_expect.setState)(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`)};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen})}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error})}return(0,import_expect.setState)({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,import_expect.GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});__reExport(src_exports,require("@vitest/spy"),module.exports);var import_client_logger=require("@storybook/client-logger"),import_instrumenter=require("@storybook/instrumenter"),domTestingLibrary=__toESM(require("@testing-library/dom")),import_user_event=__toESM(require("@testing-library/user-event")),import_ts_dedent=__toESM(require("ts-dedent")),testingLibrary=(0,import_instrumenter.instrument)({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return import_client_logger.once.warn(import_ts_dedent.default`
2
2
  You are using Testing Library's \`screen\` object. Use \`within(canvasElement)\` instead.
3
3
  More info: https://storybook.js.org/docs/react/essentials/interactions
4
- `),Reflect.get(target,prop,receiver)}});var{buildQueries,configure,createEvent,fireEvent,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,waitFor,waitForElementToBeRemoved,within,prettyFormat}=testingLibrary,screen=testingLibrary.screen,{userEvent}=(0,import_instrumenter.instrument)({userEvent:import_user_event.default},{intercept:!0});var{fn:fn2}=(0,import_instrumenter2.instrument)({fn:spy.fn},{retain:!0}),{expect:expect3}=(0,import_instrumenter2.instrument)({expect:expect2},{getKeys:obj=>{let privateApi=["assert","__methods","__flags"];return obj.constructor===import_chai.default.Assertion?Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it)):Object.keys(obj)},intercept:!0});0&&(module.exports={buildQueries,configure,createEvent,expect,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,fireEvent,fn,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,prettyFormat,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,screen,userEvent,waitFor,waitForElementToBeRemoved,within,...require("@vitest/spy")});
4
+ `),Reflect.get(target,prop,receiver)}});var{buildQueries,configure,createEvent,fireEvent,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,screen,waitFor,waitForElementToBeRemoved,within,prettyFormat}=testingLibrary,{userEvent}=(0,import_instrumenter.instrument)({userEvent:import_user_event.default},{intercept:!0});var channel=import_preview_api.addons.getChannel();channel.on(import_core_events.FORCE_REMOUNT,()=>spy.spies.forEach(mock=>mock.mockClear()));channel.on(import_core_events.STORY_RENDER_PHASE_CHANGED,({newPhase})=>{newPhase==="loading"&&spy.spies.forEach(mock=>mock.mockClear())});var{expect:expect3}=(0,import_instrumenter2.instrument)({expect:expect2},{getKeys:(obj,depth)=>{let privateApi=["assert","__methods","__flags"];if(obj.constructor===import_chai.default.Assertion){let keys=Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it));return depth>2?keys:[...keys,"not"]}return Object.keys(obj)},intercept:method=>method!=="expect"});0&&(module.exports={buildQueries,configure,createEvent,expect,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,fireEvent,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,prettyFormat,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,screen,userEvent,waitFor,waitForElementToBeRemoved,within,...require("@vitest/spy")});
package/dist/index.mjs CHANGED
@@ -3,6 +3,8 @@ import * as spy from '@vitest/spy';
3
3
  export * from '@vitest/spy';
4
4
  import * as chai from 'chai';
5
5
  import chai__default from 'chai';
6
+ import { FORCE_REMOUNT, STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events';
7
+ import { addons } from '@storybook/preview-api';
6
8
  import { GLOBAL_EXPECT, JestExtend, JestChaiExpect, JestAsymmetricMatchers, getState, setState } from '@vitest/expect';
7
9
  import * as matchers from '@testing-library/jest-dom/matchers';
8
10
  import { once } from '@storybook/client-logger';
@@ -10,9 +12,9 @@ import * as domTestingLibrary from '@testing-library/dom';
10
12
  import _userEvent from '@testing-library/user-event';
11
13
  import dedent from 'ts-dedent';
12
14
 
13
- function createExpect(){chai.use(JestExtend),chai.use(JestChaiExpect),chai.use(JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=getState(expect4);return setState({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>getState(expect4),expect4.setState=state=>setState(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`);};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen});}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error});}return setState({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});var testingLibrary=instrument({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")||method.startsWith("query")||method.startsWith("get")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return once.warn(dedent`
15
+ function createExpect(){chai.use(JestExtend),chai.use(JestChaiExpect),chai.use(JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=getState(expect4);return setState({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>getState(expect4),expect4.setState=state=>setState(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`);};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen});}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error});}return setState({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});var testingLibrary=instrument({...domTestingLibrary},{intercept:(method,path)=>path[0]==="fireEvent"||method.startsWith("find")||method.startsWith("waitFor")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return once.warn(dedent`
14
16
  You are using Testing Library's \`screen\` object. Use \`within(canvasElement)\` instead.
15
17
  More info: https://storybook.js.org/docs/react/essentials/interactions
16
- `),Reflect.get(target,prop,receiver)}});var {buildQueries,configure,createEvent,fireEvent,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,waitFor,waitForElementToBeRemoved,within,prettyFormat}=testingLibrary,screen=testingLibrary.screen,{userEvent}=instrument({userEvent:_userEvent},{intercept:!0});var {fn:fn2}=instrument({fn:spy.fn},{retain:!0}),{expect:expect3}=instrument({expect:expect2},{getKeys:obj=>{let privateApi=["assert","__methods","__flags"];return obj.constructor===chai__default.Assertion?Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it)):Object.keys(obj)},intercept:!0});
18
+ `),Reflect.get(target,prop,receiver)}});var {buildQueries,configure,createEvent,fireEvent,findAllByAltText,findAllByDisplayValue,findAllByLabelText,findAllByPlaceholderText,findAllByRole,findAllByTestId,findAllByText,findAllByTitle,findByAltText,findByDisplayValue,findByLabelText,findByPlaceholderText,findByRole,findByTestId,findByText,findByTitle,getAllByAltText,getAllByDisplayValue,getAllByLabelText,getAllByPlaceholderText,getAllByRole,getAllByTestId,getAllByText,getAllByTitle,getByAltText,getByDisplayValue,getByLabelText,getByPlaceholderText,getByRole,getByTestId,getByText,getByTitle,getConfig,getDefaultNormalizer,getElementError,getNodeText,getQueriesForElement,getRoles,getSuggestedQuery,isInaccessible,logDOM,logRoles,prettyDOM,queries,queryAllByAltText,queryAllByAttribute,queryAllByDisplayValue,queryAllByLabelText,queryAllByPlaceholderText,queryAllByRole,queryAllByTestId,queryAllByText,queryAllByTitle,queryByAltText,queryByAttribute,queryByDisplayValue,queryByLabelText,queryByPlaceholderText,queryByRole,queryByTestId,queryByText,queryByTitle,queryHelpers,screen,waitFor,waitForElementToBeRemoved,within,prettyFormat}=testingLibrary,{userEvent}=instrument({userEvent:_userEvent},{intercept:!0});var channel=addons.getChannel();channel.on(FORCE_REMOUNT,()=>spy.spies.forEach(mock=>mock.mockClear()));channel.on(STORY_RENDER_PHASE_CHANGED,({newPhase})=>{newPhase==="loading"&&spy.spies.forEach(mock=>mock.mockClear());});var {expect:expect3}=instrument({expect:expect2},{getKeys:(obj,depth)=>{let privateApi=["assert","__methods","__flags"];if(obj.constructor===chai__default.Assertion){let keys=Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it));return depth>2?keys:[...keys,"not"]}return Object.keys(obj)},intercept:method=>method!=="expect"});
17
19
 
18
- export { buildQueries, configure, createEvent, expect3 as expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, fn2 as fn, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, logDOM, logRoles, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, userEvent, waitFor, waitForElementToBeRemoved, within };
20
+ export { buildQueries, configure, createEvent, expect3 as expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, logDOM, logRoles, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, userEvent, waitFor, waitForElementToBeRemoved, within };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/test",
3
- "version": "0.0.0-pr-24225-sha-5ffd56a7",
3
+ "version": "0.0.0-pr-24225-sha-fa4f5fec",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "storybook"
@@ -43,8 +43,10 @@
43
43
  "prep": "../../../scripts/prepare/bundle.ts"
44
44
  },
45
45
  "dependencies": {
46
- "@storybook/client-logger": "^0.0.0-pr-24225-sha-5ffd56a7",
47
- "@storybook/instrumenter": "^0.0.0-pr-24225-sha-5ffd56a7",
46
+ "@storybook/client-logger": "^0.0.0-pr-24225-sha-fa4f5fec",
47
+ "@storybook/core-events": "^0.0.0-pr-24225-sha-fa4f5fec",
48
+ "@storybook/instrumenter": "^0.0.0-pr-24225-sha-fa4f5fec",
49
+ "@storybook/preview-api": "^0.0.0-pr-24225-sha-fa4f5fec",
48
50
  "@testing-library/dom": "^9.3.1",
49
51
  "@testing-library/jest-dom": "^6.1.3",
50
52
  "@testing-library/user-event": "^14.4.3",