@storybook/test 8.3.0-alpha.1 → 8.3.0-alpha.11
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/index.d.ts +22 -10
- package/dist/index.js +109 -100
- package/dist/index.mjs +111 -102
- package/package.json +13 -12
package/README.md
CHANGED
@@ -21,8 +21,8 @@ The instrumentation makes sure you can debug those methods in the [addon-interac
|
|
21
21
|
|
22
22
|
```ts
|
23
23
|
// Button.stories.ts
|
24
|
+
import { expect, fn, userEvent, within } from '@storybook/test';
|
24
25
|
import { Button } from './Button';
|
25
|
-
import { within, userEvent, expect, fn } from '@storybook/test';
|
26
26
|
|
27
27
|
export default {
|
28
28
|
component: Button,
|
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion, ExpectStatic } from '@vitest/expect';
|
2
1
|
import { TestingLibraryMatchers } from '@testing-library/jest-dom/matchers';
|
2
|
+
import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion, ExpectStatic } from '@vitest/expect';
|
3
3
|
import * as domTestingLibrary from '@testing-library/dom';
|
4
|
+
import { BoundFunctions } from '@testing-library/dom';
|
4
5
|
import _userEvent from '@testing-library/user-event';
|
5
|
-
import { spyOn as spyOn$1,
|
6
|
+
import { spyOn as spyOn$1, Mock as Mock$1, MaybeMocked, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
6
7
|
export * from '@vitest/spy';
|
7
8
|
export { isMockFunction, mocks } from '@vitest/spy';
|
8
9
|
|
@@ -113,28 +114,39 @@ declare const userEvent: UserEvent;
|
|
113
114
|
type Listener = (mock: MockInstance, args: unknown[]) => void;
|
114
115
|
declare function onMockCall(callback: Listener): () => void;
|
115
116
|
declare const spyOn: typeof spyOn$1;
|
116
|
-
|
117
|
+
type Procedure = (...args: any[]) => any;
|
118
|
+
type Mock<T extends Procedure | any[] = any[], R = any> = T extends Procedure ? Mock$1<T> : T extends any[] ? Mock$1<(...args: T) => R> : never;
|
119
|
+
declare function fn<T extends Procedure = Procedure>(implementation?: T): Mock<T>;
|
120
|
+
declare function fn<TArgs extends any[] = any, R = any>(): Mock<(...args: TArgs) => R>;
|
121
|
+
declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<(...args: TArgs) => R>;
|
122
|
+
declare function fn<TArgs extends any[] = any[], R = any>(implementation?: (...args: TArgs) => R): Mock<(...args: TArgs) => R>;
|
117
123
|
/**
|
118
|
-
* Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will
|
124
|
+
* Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will
|
125
|
+
* only empty `.mock` state, it will not reset implementation.
|
119
126
|
*
|
120
127
|
* It is useful if you need to clean up mock between different assertions.
|
121
128
|
*/
|
122
129
|
declare function clearAllMocks(): void;
|
123
130
|
/**
|
124
|
-
* Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will
|
131
|
+
* Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will
|
132
|
+
* empty `.mock` state, reset "once" implementations and force the base implementation to return
|
133
|
+
* `undefined` when invoked.
|
125
134
|
*
|
126
135
|
* This is useful when you want to completely reset a mock to the default state.
|
127
136
|
*/
|
128
137
|
declare function resetAllMocks(): void;
|
129
138
|
/**
|
130
|
-
* Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This
|
139
|
+
* Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This
|
140
|
+
* will restore all original implementations.
|
131
141
|
*/
|
132
142
|
declare function restoreAllMocks(): void;
|
133
143
|
/**
|
134
144
|
* Type helper for TypeScript. Just returns the object that was passed.
|
135
145
|
*
|
136
|
-
* When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will
|
137
|
-
* the first level values are mocked. You can pass down `{ deep:
|
146
|
+
* When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will
|
147
|
+
* only make TypeScript believe that the first level values are mocked. You can pass down `{ deep:
|
148
|
+
* true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually
|
149
|
+
* is.
|
138
150
|
*
|
139
151
|
* @param item Anything that can be mocked
|
140
152
|
* @param deep If the object is deeply mocked
|
@@ -160,7 +172,7 @@ declare function mocked<T>(item: T, options: {
|
|
160
172
|
}): MaybePartiallyMockedDeep<T>;
|
161
173
|
declare function mocked<T>(item: T): MaybeMocked<T>;
|
162
174
|
|
163
|
-
type Queries =
|
175
|
+
type Queries = BoundFunctions<typeof queries>;
|
164
176
|
declare module '@storybook/csf' {
|
165
177
|
interface Canvas extends Queries {
|
166
178
|
}
|
@@ -171,4 +183,4 @@ declare const expect: Expect;
|
|
171
183
|
|
172
184
|
declare const traverseArgs: (value: unknown, depth?: number, key?: string) => unknown;
|
173
185
|
|
174
|
-
export { UserEvent, buildQueries, clearAllMocks, 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, mocked, onMockCall, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, resetAllMocks, restoreAllMocks, screen, spyOn, traverseArgs, userEvent, waitFor, waitForElementToBeRemoved, within };
|
186
|
+
export { Mock, UserEvent, buildQueries, clearAllMocks, 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, mocked, onMockCall, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, resetAllMocks, restoreAllMocks, screen, spyOn, traverseArgs, userEvent, waitFor, waitForElementToBeRemoved, within };
|