@storybook/test 0.0.0-pr-28385-sha-9aab3bd7 → 0.0.0-pr-28415-sha-98c4ca6f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion, ExpectStatic } from '@vitest/expect';
2
2
  import { TestingLibraryMatchers } from '@testing-library/jest-dom/matchers';
3
- import * as domTestingLibrary from '@testing-library/dom';
4
- import _userEvent from '@testing-library/user-event';
5
3
  import { spyOn as spyOn$1, fn as fn$1, MaybeMocked, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
6
4
  export * from '@vitest/spy';
7
5
  export { isMockFunction, mocks } from '@vitest/spy';
6
+ import * as domTestingLibrary from '@testing-library/dom';
7
+ import _userEvent from '@testing-library/user-event';
8
8
 
9
9
  type Promisify<Fn> = Fn extends (...args: infer A) => infer R ? (...args: A) => R extends Promise<any> ? R : Promise<R> : Fn;
10
10
  type PromisifyObject<O> = {
@@ -33,6 +33,56 @@ interface Expect extends AsymmetricMatchersContaining {
33
33
  not: AsymmetricMatchersContaining;
34
34
  }
35
35
 
36
+ type Listener = (mock: MockInstance, args: unknown[]) => void;
37
+ declare function onMockCall(callback: Listener): () => void;
38
+ declare const spyOn: typeof spyOn$1;
39
+ declare const fn: typeof fn$1;
40
+ /**
41
+ * Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will only empty `.mock` state, it will not reset implementation.
42
+ *
43
+ * It is useful if you need to clean up mock between different assertions.
44
+ */
45
+ declare function clearAllMocks(): void;
46
+ /**
47
+ * Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will empty `.mock` state, reset "once" implementations and force the base implementation to return `undefined` when invoked.
48
+ *
49
+ * This is useful when you want to completely reset a mock to the default state.
50
+ */
51
+ declare function resetAllMocks(): void;
52
+ /**
53
+ * Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This will restore all original implementations.
54
+ */
55
+ declare function restoreAllMocks(): void;
56
+ /**
57
+ * Type helper for TypeScript. Just returns the object that was passed.
58
+ *
59
+ * When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will only make TypeScript believe that
60
+ * the first level values are mocked. You can pass down `{ deep: true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually is.
61
+ *
62
+ * @param item Anything that can be mocked
63
+ * @param deep If the object is deeply mocked
64
+ * @param options If the object is partially or deeply mocked
65
+ */
66
+ declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
67
+ declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
68
+ declare function mocked<T>(item: T, options: {
69
+ partial?: false;
70
+ deep?: false;
71
+ }): MaybeMocked<T>;
72
+ declare function mocked<T>(item: T, options: {
73
+ partial?: false;
74
+ deep: true;
75
+ }): MaybeMockedDeep<T>;
76
+ declare function mocked<T>(item: T, options: {
77
+ partial: true;
78
+ deep?: false;
79
+ }): MaybePartiallyMocked<T>;
80
+ declare function mocked<T>(item: T, options: {
81
+ partial: true;
82
+ deep: true;
83
+ }): MaybePartiallyMockedDeep<T>;
84
+ declare function mocked<T>(item: T): MaybeMocked<T>;
85
+
36
86
  declare const buildQueries: typeof domTestingLibrary.buildQueries;
37
87
  declare const configure: typeof domTestingLibrary.configure;
38
88
  declare const createEvent: domTestingLibrary.CreateObject & domTestingLibrary.CreateFunction;
@@ -110,63 +160,6 @@ interface UserEvent extends _UserEvent {
110
160
  }
111
161
  declare const userEvent: UserEvent;
112
162
 
113
- type Listener = (mock: MockInstance, args: unknown[]) => void;
114
- declare function onMockCall(callback: Listener): () => void;
115
- declare const spyOn: typeof spyOn$1;
116
- declare const fn: typeof fn$1;
117
- /**
118
- * Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will only empty `.mock` state, it will not reset implementation.
119
- *
120
- * It is useful if you need to clean up mock between different assertions.
121
- */
122
- declare function clearAllMocks(): void;
123
- /**
124
- * Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will empty `.mock` state, reset "once" implementations and force the base implementation to return `undefined` when invoked.
125
- *
126
- * This is useful when you want to completely reset a mock to the default state.
127
- */
128
- declare function resetAllMocks(): void;
129
- /**
130
- * Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This will restore all original implementations.
131
- */
132
- declare function restoreAllMocks(): void;
133
- /**
134
- * Type helper for TypeScript. Just returns the object that was passed.
135
- *
136
- * When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will only make TypeScript believe that
137
- * the first level values are mocked. You can pass down `{ deep: true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually is.
138
- *
139
- * @param item Anything that can be mocked
140
- * @param deep If the object is deeply mocked
141
- * @param options If the object is partially or deeply mocked
142
- */
143
- declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
144
- declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
145
- declare function mocked<T>(item: T, options: {
146
- partial?: false;
147
- deep?: false;
148
- }): MaybeMocked<T>;
149
- declare function mocked<T>(item: T, options: {
150
- partial?: false;
151
- deep: true;
152
- }): MaybeMockedDeep<T>;
153
- declare function mocked<T>(item: T, options: {
154
- partial: true;
155
- deep?: false;
156
- }): MaybePartiallyMocked<T>;
157
- declare function mocked<T>(item: T, options: {
158
- partial: true;
159
- deep: true;
160
- }): MaybePartiallyMockedDeep<T>;
161
- declare function mocked<T>(item: T): MaybeMocked<T>;
162
-
163
- type Queries = ReturnType<typeof within<typeof queries>>;
164
- declare module '@storybook/csf' {
165
- interface Canvas extends Queries {
166
- }
167
- interface StoryContext {
168
- }
169
- }
170
163
  declare const expect: Expect;
171
164
 
172
165
  declare const traverseArgs: (value: unknown, depth?: number, key?: string) => unknown;