@storybook/test 0.0.0-pr-23888-sha-032c0a61 → 0.0.0-pr-24225-sha-4257f39c

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,15 +1,22 @@
1
- import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion } from '@vitest/expect';
2
- import * as spy from '@vitest/spy';
1
+ import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion, ExpectStatic } from '@vitest/expect';
2
+ import { TestingLibraryMatchers } from '@testing-library/jest-dom/types/matchers';
3
3
  export * from '@vitest/spy';
4
+ import * as _testing_library_user_event_dist_types_setup_directApi from '@testing-library/user-event/dist/types/setup/directApi';
5
+ import * as _testing_library_user_event_dist_types_setup_setup from '@testing-library/user-event/dist/types/setup/setup';
6
+ import * as domTestingLibrary from '@testing-library/dom';
7
+ import { BoundFunctions } from '@testing-library/dom';
4
8
 
5
- type Promisify<O> = {
6
- [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
9
+ type Promisify<Fn> = Fn extends (...args: infer A) => infer R ? (...args: A) => R extends Promise<any> ? R : Promise<R> : Fn;
10
+ type PromisifyObject<O> = {
11
+ -readonly [K in keyof O]: Promisify<O[K]>;
7
12
  };
8
- interface Assertion<T> extends Promisify<JestAssertion<T>> {
13
+
14
+ interface Assertion<T> extends PromisifyObject<JestAssertion<T>>, TestingLibraryMatchers<ReturnType<ExpectStatic['stringContaining']>, Promise<void>> {
9
15
  toHaveBeenCalledOnce(): Promise<void>;
10
16
  toSatisfy<E>(matcher: (value: E) => boolean, message?: string): Promise<void>;
11
- resolves: Promisify<Assertion<T>>;
12
- rejects: Promisify<Assertion<T>>;
17
+ resolves: Assertion<T>;
18
+ rejects: Assertion<T>;
19
+ not: Assertion<T>;
13
20
  }
14
21
  interface Expect extends AsymmetricMatchersContaining {
15
22
  <T>(actual: T, message?: string): Assertion<T>;
@@ -25,7 +32,103 @@ interface Expect extends AsymmetricMatchersContaining {
25
32
  not: AsymmetricMatchersContaining;
26
33
  }
27
34
 
28
- declare const fn: typeof spy.fn;
35
+ declare const buildQueries: (queryAllBy: domTestingLibrary.GetAllBy<any[]>, getMultipleError: domTestingLibrary.GetErrorFunction<any[]>, getMissingError: domTestingLibrary.GetErrorFunction<any[]>) => Promise<domTestingLibrary.BuiltQueryMethods<any[]>>;
36
+ declare const configure: (configDelta: domTestingLibrary.ConfigFn | Partial<domTestingLibrary.Config>) => Promise<void>;
37
+ declare const createEvent: (eventName: string, node: Element | Node | Document | Window, init?: {} | undefined, options?: {
38
+ EventType?: string | undefined;
39
+ defaultInit?: {} | undefined;
40
+ } | undefined) => Promise<Event>;
41
+ declare const fireEvent: ((element: Element | Node | Document | Window, event: Event) => Promise<false> | Promise<true>) & PromisifyObject<domTestingLibrary.FireObject>;
42
+ declare const findAllByAltText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
43
+ declare const findAllByDisplayValue: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
44
+ declare const findAllByLabelText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
45
+ declare const findAllByPlaceholderText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
46
+ declare const findAllByRole: (container: HTMLElement, role: domTestingLibrary.ByRoleMatcher, options?: domTestingLibrary.ByRoleOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
47
+ declare const findAllByTestId: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
48
+ declare const findAllByText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
49
+ declare const findAllByTitle: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement[]>;
50
+ declare const findByAltText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
51
+ declare const findByDisplayValue: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
52
+ declare const findByLabelText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
53
+ declare const findByPlaceholderText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
54
+ declare const findByRole: (container: HTMLElement, role: domTestingLibrary.ByRoleMatcher, options?: domTestingLibrary.ByRoleOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
55
+ declare const findByTestId: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
56
+ declare const findByText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
57
+ declare const findByTitle: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined, waitForElementOptions?: domTestingLibrary.waitForOptions | undefined) => Promise<HTMLElement>;
58
+ declare const getAllByAltText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
59
+ declare const getAllByDisplayValue: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
60
+ declare const getAllByLabelText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement[]>;
61
+ declare const getAllByPlaceholderText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
62
+ declare const getAllByRole: (container: HTMLElement, role: domTestingLibrary.ByRoleMatcher, options?: domTestingLibrary.ByRoleOptions | undefined) => Promise<HTMLElement[]>;
63
+ declare const getAllByTestId: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
64
+ declare const getAllByText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement[]>;
65
+ declare const getAllByTitle: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
66
+ declare const getByAltText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement>;
67
+ declare const getByDisplayValue: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement>;
68
+ declare const getByLabelText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement>;
69
+ declare const getByPlaceholderText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement>;
70
+ declare const getByRole: (container: HTMLElement, role: domTestingLibrary.ByRoleMatcher, options?: domTestingLibrary.ByRoleOptions | undefined) => Promise<HTMLElement>;
71
+ declare const getByTestId: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement>;
72
+ declare const getByText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement>;
73
+ declare const getByTitle: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement>;
74
+ declare const getConfig: () => Promise<domTestingLibrary.Config>;
75
+ declare const getDefaultNormalizer: (options?: domTestingLibrary.DefaultNormalizerOptions | undefined) => Promise<domTestingLibrary.NormalizerFn>;
76
+ declare const getElementError: (message: string | null, container: HTMLElement) => Promise<Error>;
77
+ declare const getNodeText: (node: HTMLElement) => Promise<string>;
78
+ declare const getQueriesForElement: typeof domTestingLibrary.getQueriesForElement;
79
+ declare const getRoles: (container: HTMLElement) => Promise<{
80
+ [index: string]: HTMLElement[];
81
+ }>;
82
+ declare const getSuggestedQuery: (element: HTMLElement, variant?: domTestingLibrary.Variant | undefined, method?: domTestingLibrary.Method | undefined) => Promise<undefined> | Promise<domTestingLibrary.Suggestion>;
83
+ declare const isInaccessible: (element: Element) => Promise<false> | Promise<true>;
84
+ declare const logDOM: (dom?: Element | HTMLDocument | undefined, maxLength?: number | undefined, options?: domTestingLibrary.PrettyDOMOptions | undefined) => Promise<void>;
85
+ declare const logRoles: (container: HTMLElement) => Promise<string>;
86
+ declare const prettyDOM: (dom?: Element | HTMLDocument | undefined, maxLength?: number | undefined, options?: domTestingLibrary.PrettyDOMOptions | undefined) => Promise<false> | Promise<string>;
87
+ declare const queries: typeof domTestingLibrary.queries;
88
+ declare const queryAllByAltText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
89
+ declare const queryAllByAttribute: (attribute: string, container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
90
+ declare const queryAllByDisplayValue: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
91
+ declare const queryAllByLabelText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement[]>;
92
+ declare const queryAllByPlaceholderText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
93
+ declare const queryAllByRole: (container: HTMLElement, role: domTestingLibrary.ByRoleMatcher, options?: domTestingLibrary.ByRoleOptions | undefined) => Promise<HTMLElement[]>;
94
+ declare const queryAllByTestId: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
95
+ declare const queryAllByText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement[]>;
96
+ declare const queryAllByTitle: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement[]>;
97
+ declare const queryByAltText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
98
+ declare const queryByAttribute: (attribute: string, container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
99
+ declare const queryByDisplayValue: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
100
+ declare const queryByLabelText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
101
+ declare const queryByPlaceholderText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
102
+ declare const queryByRole: (container: HTMLElement, role: domTestingLibrary.ByRoleMatcher, options?: domTestingLibrary.ByRoleOptions | undefined) => Promise<HTMLElement> | Promise<null>;
103
+ declare const queryByTestId: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
104
+ declare const queryByText: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.SelectorMatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
105
+ declare const queryByTitle: (container: HTMLElement, id: domTestingLibrary.Matcher, options?: domTestingLibrary.MatcherOptions | undefined) => Promise<HTMLElement> | Promise<null>;
106
+ declare const queryHelpers: typeof domTestingLibrary.queryHelpers;
107
+ declare const waitFor: (callback: () => unknown, options?: domTestingLibrary.waitForOptions | undefined) => Promise<unknown>;
108
+ declare const waitForElementToBeRemoved: (callback: unknown, options?: domTestingLibrary.waitForOptions | undefined) => Promise<void>;
109
+ declare const within: (element: HTMLElement) => PromisifyObject<BoundFunctions<typeof domTestingLibrary.queries>>;
110
+ declare const prettyFormat: typeof domTestingLibrary.prettyFormat;
111
+ declare const screen: domTestingLibrary.Screen<typeof domTestingLibrary.queries>;
112
+ declare const userEvent: {
113
+ readonly setup: typeof _testing_library_user_event_dist_types_setup_setup.setupMain;
114
+ readonly clear: typeof _testing_library_user_event_dist_types_setup_directApi.clear;
115
+ readonly click: typeof _testing_library_user_event_dist_types_setup_directApi.click;
116
+ readonly copy: typeof _testing_library_user_event_dist_types_setup_directApi.copy;
117
+ readonly cut: typeof _testing_library_user_event_dist_types_setup_directApi.cut;
118
+ readonly dblClick: typeof _testing_library_user_event_dist_types_setup_directApi.dblClick;
119
+ readonly deselectOptions: typeof _testing_library_user_event_dist_types_setup_directApi.deselectOptions;
120
+ readonly hover: typeof _testing_library_user_event_dist_types_setup_directApi.hover;
121
+ readonly keyboard: typeof _testing_library_user_event_dist_types_setup_directApi.keyboard;
122
+ readonly pointer: typeof _testing_library_user_event_dist_types_setup_directApi.pointer;
123
+ readonly paste: typeof _testing_library_user_event_dist_types_setup_directApi.paste;
124
+ readonly selectOptions: typeof _testing_library_user_event_dist_types_setup_directApi.selectOptions;
125
+ readonly tripleClick: typeof _testing_library_user_event_dist_types_setup_directApi.tripleClick;
126
+ readonly type: typeof _testing_library_user_event_dist_types_setup_directApi.type;
127
+ readonly unhover: typeof _testing_library_user_event_dist_types_setup_directApi.unhover;
128
+ readonly upload: typeof _testing_library_user_event_dist_types_setup_directApi.upload;
129
+ readonly tab: typeof _testing_library_user_event_dist_types_setup_directApi.tab;
130
+ };
131
+
29
132
  declare const expect: Expect;
30
133
 
31
- export { expect, fn };
134
+ 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 +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,{expect:()=>expect3,fn:()=>fn2});module.exports=__toCommonJS(src_exports);var import_instrumenter=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}`);Error.captureStackTrace&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen})}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");Error.captureStackTrace&&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{fn:fn2}=(0,import_instrumenter.instrument)({fn:spy.fn},{retain:!0}),{expect:expect3}=(0,import_instrumenter.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={expect,fn,...require("@vitest/spy")});
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")||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`
2
+ You are using Testing Library's \`screen\` object. Use \`within(canvasElement)\` instead.
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 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=>{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: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,9 +3,18 @@ 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';
10
+ import { once } from '@storybook/client-logger';
11
+ import * as domTestingLibrary from '@testing-library/dom';
12
+ import _userEvent from '@testing-library/user-event';
13
+ import dedent from 'ts-dedent';
8
14
 
9
- 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}`);Error.captureStackTrace&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen});}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");Error.captureStackTrace&&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 {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});
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")||method.startsWith("query")||method.startsWith("get")});testingLibrary.screen=new Proxy(testingLibrary.screen,{get(target,prop,receiver){return once.warn(dedent`
16
+ You are using Testing Library's \`screen\` object. Use \`within(canvasElement)\` instead.
17
+ More info: https://storybook.js.org/docs/react/essentials/interactions
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,waitFor,waitForElementToBeRemoved,within,prettyFormat}=testingLibrary,screen=testingLibrary.screen,{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=>{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:method=>method!=="expect"});
10
19
 
11
- export { expect3 as expect, fn2 as fn };
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-23888-sha-032c0a61",
3
+ "version": "0.0.0-pr-24225-sha-4257f39c",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "storybook"
@@ -43,12 +43,18 @@
43
43
  "prep": "../../../scripts/prepare/bundle.ts"
44
44
  },
45
45
  "dependencies": {
46
- "@storybook/instrumenter": "^0.0.0-pr-23888-sha-032c0a61",
47
- "@testing-library/jest-dom": "^6.0.0",
46
+ "@storybook/client-logger": "^0.0.0-pr-24225-sha-4257f39c",
47
+ "@storybook/core-events": "^0.0.0-pr-24225-sha-4257f39c",
48
+ "@storybook/instrumenter": "^0.0.0-pr-24225-sha-4257f39c",
49
+ "@storybook/preview-api": "^0.0.0-pr-24225-sha-4257f39c",
50
+ "@testing-library/dom": "^9.3.1",
51
+ "@testing-library/jest-dom": "^6.1.3",
52
+ "@testing-library/user-event": "^14.4.3",
48
53
  "@vitest/expect": "^0.34.2",
49
54
  "@vitest/spy": "^0.34.1",
50
55
  "chai": "^4.3.7",
51
- "expect": "^29.6.2"
56
+ "expect": "^29.6.2",
57
+ "ts-dedent": "^2.2.0"
52
58
  },
53
59
  "devDependencies": {
54
60
  "@types/chai": "^4",