@voidzero-dev/vite-plus-test 0.1.9 → 0.1.11

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.
Files changed (206) hide show
  1. package/LICENSE.md +181 -1
  2. package/dist/@vitest/browser/client/.vite/manifest.json +6 -6
  3. package/dist/@vitest/browser/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
  4. package/dist/@vitest/browser/client/__vitest__/assets/index-Di71CKDo.js +63 -0
  5. package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
  6. package/dist/@vitest/browser/client/__vitest__/favicon.svg +49 -4
  7. package/dist/@vitest/browser/client/__vitest__/index.html +2 -2
  8. package/dist/@vitest/browser/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
  9. package/dist/@vitest/browser/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +168 -59
  10. package/dist/@vitest/browser/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
  11. package/dist/@vitest/browser/client/favicon.svg +49 -4
  12. package/dist/@vitest/browser/client/orchestrator.html +2 -2
  13. package/dist/@vitest/browser/client/tester/tester.html +2 -2
  14. package/dist/@vitest/browser/client.js +20 -13
  15. package/dist/@vitest/browser/context.d.ts +160 -10
  16. package/dist/@vitest/browser/context.js +108 -22
  17. package/dist/@vitest/browser/expect-element.js +23 -28
  18. package/dist/@vitest/browser/index-5Pe7X7sp.js +7 -0
  19. package/dist/@vitest/browser/index.d.ts +20 -2
  20. package/dist/@vitest/browser/index.js +5706 -159
  21. package/dist/@vitest/browser/locators.d.ts +14 -3
  22. package/dist/@vitest/browser/locators.js +1 -1
  23. package/dist/@vitest/browser-playwright/index.d.ts +23 -6
  24. package/dist/@vitest/browser-playwright/index.js +169 -61
  25. package/dist/@vitest/browser-playwright/locators.js +1 -1
  26. package/dist/@vitest/browser-preview/index.d.ts +14 -1
  27. package/dist/@vitest/browser-preview/locators.js +32 -20
  28. package/dist/@vitest/browser-webdriverio/index.d.ts +17 -3
  29. package/dist/@vitest/browser-webdriverio/index.js +22 -2
  30. package/dist/@vitest/browser-webdriverio/locators.js +85 -9
  31. package/dist/@vitest/expect/index.d.ts +172 -54
  32. package/dist/@vitest/expect/index.js +124 -67
  33. package/dist/@vitest/mocker/auto-register.js +1 -0
  34. package/dist/@vitest/mocker/automock.d.ts +1 -0
  35. package/dist/@vitest/mocker/automock.js +5 -0
  36. package/dist/@vitest/mocker/browser.d.ts +4 -4
  37. package/dist/@vitest/mocker/browser.js +1 -0
  38. package/dist/@vitest/mocker/chunk-automock.js +182 -14
  39. package/dist/@vitest/mocker/chunk-helpers.js +44 -0
  40. package/dist/@vitest/mocker/chunk-hoistMocks.js +659 -0
  41. package/dist/@vitest/mocker/chunk-mocker.js +41 -30
  42. package/dist/@vitest/mocker/chunk-registry.js +21 -7
  43. package/dist/@vitest/mocker/chunk-utils.js +18 -7
  44. package/dist/@vitest/mocker/hoistMocks.d-w2ILr1dG.d.ts +739 -0
  45. package/dist/@vitest/mocker/{index.d-C-sLYZi-.d.ts → index.d-B41z0AuW.d.ts} +1 -1
  46. package/dist/@vitest/mocker/index.d.ts +2 -2
  47. package/dist/@vitest/mocker/index.js +18 -3
  48. package/dist/@vitest/mocker/{mocker.d-TnKRhz7N.d.ts → mocker.d-QEntlm6J.d.ts} +10 -5
  49. package/dist/@vitest/mocker/node.d.ts +5 -734
  50. package/dist/@vitest/mocker/node.js +29 -587
  51. package/dist/@vitest/mocker/redirect.js +4 -4
  52. package/dist/@vitest/mocker/register.d.ts +3 -3
  53. package/dist/@vitest/mocker/register.js +1 -0
  54. package/dist/@vitest/mocker/transforms.d.ts +6 -0
  55. package/dist/@vitest/mocker/transforms.js +8 -0
  56. package/dist/@vitest/mocker/{types.d-B8CCKmHt.d.ts → types.d-BjI5eAwu.d.ts} +23 -7
  57. package/dist/@vitest/pretty-format/index.d.ts +11 -1
  58. package/dist/@vitest/pretty-format/index.js +33 -4
  59. package/dist/@vitest/runner/chunk-tasks.js +305 -37
  60. package/dist/@vitest/runner/index.d.ts +5 -6
  61. package/dist/@vitest/runner/index.js +1146 -455
  62. package/dist/@vitest/runner/{tasks.d-C7UxawJ9.d.ts → tasks.d-D2GKpdwQ.d.ts} +726 -55
  63. package/dist/@vitest/runner/types.d.ts +2 -182
  64. package/dist/@vitest/runner/utils.d.ts +16 -8
  65. package/dist/@vitest/runner/utils.js +1 -1
  66. package/dist/@vitest/snapshot/{environment.d-DHdQ1Csl.d.ts → environment.d-DOJxxZV9.d.ts} +2 -7
  67. package/dist/@vitest/snapshot/environment.d.ts +2 -1
  68. package/dist/@vitest/snapshot/environment.js +1 -1
  69. package/dist/@vitest/snapshot/index.d.ts +4 -3
  70. package/dist/@vitest/snapshot/index.js +21 -550
  71. package/dist/@vitest/snapshot/manager.d.ts +3 -2
  72. package/dist/@vitest/snapshot/manager.js +1 -1
  73. package/dist/@vitest/snapshot/{rawSnapshot.d-lFsMJFUd.d.ts → rawSnapshot.d-U2kJUxDr.d.ts} +1 -1
  74. package/dist/@vitest/spy/index.d.ts +34 -4
  75. package/dist/@vitest/spy/index.js +69 -19
  76. package/dist/@vitest/utils/diff.js +11 -9
  77. package/dist/@vitest/utils/display.d.ts +2 -1
  78. package/dist/@vitest/utils/display.js +38 -5
  79. package/dist/@vitest/utils/error.d.ts +2 -1
  80. package/dist/@vitest/utils/error.js +1 -2
  81. package/dist/@vitest/utils/helpers.d.ts +4 -1
  82. package/dist/@vitest/utils/helpers.js +43 -1
  83. package/dist/@vitest/utils/resolver.js +1 -2
  84. package/dist/@vitest/utils/serialize.js +6 -6
  85. package/dist/@vitest/utils/source-map/node.d.ts +6 -0
  86. package/dist/@vitest/utils/source-map/node.js +23 -0
  87. package/dist/@vitest/utils/source-map.js +15 -5
  88. package/dist/browser.d.ts +3 -2
  89. package/dist/browser.js +2 -2
  90. package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
  91. package/dist/chunks/{base.CJ0Y4ePK.js → base.DM0-RqVb.js} +54 -16
  92. package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.D0SlKNbZ.js} +1 -1
  93. package/dist/chunks/{browser.d.ChKACdzH.d.ts → browser.d.X3SXoOCV.d.ts} +4 -1
  94. package/dist/chunks/{cac.DVeoLl0M.js → cac.CWGDZnXT.js} +979 -20
  95. package/dist/chunks/{cli-api.B7PN_QUv.js → cli-api.DuT9iuvY.js} +8764 -7898
  96. package/dist/chunks/{config.d.Cy95HiCx.d.ts → config.d.EJLVE3es.d.ts} +30 -15
  97. package/dist/chunks/{console.Cf-YriPC.js → console.3WNpx0tS.js} +3 -2
  98. package/dist/chunks/{constants.D_Q9UYh-.js → constants.CPYnjOGj.js} +4 -2
  99. package/dist/chunks/coverage.Bri33R1t.js +1050 -0
  100. package/dist/chunks/{creator.DAmOKTvJ.js → creator.DgVhQm5q.js} +35 -4
  101. package/dist/chunks/{defaults.BOqNVLsY.js → defaults.CdU2lD-q.js} +4 -3
  102. package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.x-ILCfAE.d.ts} +1 -2
  103. package/dist/chunks/{globals.DOayXfHP.js → globals.BXNGLnTL.js} +11 -10
  104. package/dist/chunks/{coverage.AVPTjMgw.js → index.BCY_7LL2.js} +5 -959
  105. package/dist/chunks/{index.C5r1PdPD.js → index.CEzQDJGb.js} +1 -1
  106. package/dist/chunks/{index.D3XRDfWc.js → index.CMESou6r.js} +26 -1
  107. package/dist/chunks/{index.6Qv1eEA6.js → index.DGNSnENe.js} +95 -9
  108. package/dist/chunks/{index.M8mOzt4Y.js → index.DXMFO5MJ.js} +3279 -2914
  109. package/dist/chunks/{index.Z5E_ObnR.js → index.DlDSLQD3.js} +7 -3
  110. package/dist/chunks/{index.CyBMJtT7.js → index.EY6TCHpo.js} +10 -8
  111. package/dist/chunks/{index.D4KonVSU.js → index.og1WyBLx.js} +18 -3
  112. package/dist/chunks/{init-forks._y3TW739.js → init-forks.DeArv0jT.js} +1 -1
  113. package/dist/chunks/{init-threads.DBO2kn-p.js → init-threads.-2OUl4Nn.js} +1 -1
  114. package/dist/chunks/{init.B6MLFIaN.js → init.DICorXCo.js} +52 -13
  115. package/dist/chunks/native.DPzPHdi5.js +148 -0
  116. package/dist/chunks/nativeModuleMocker.DndvSdL6.js +206 -0
  117. package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
  118. package/dist/chunks/{node.Ce0vMQM7.js → node.COQbm6gK.js} +1 -1
  119. package/dist/chunks/{plugin.d.CtqpEehP.d.ts → plugin.d.BuW-flqo.d.ts} +1 -1
  120. package/dist/chunks/{reporters.d.CWXNI2jG.d.ts → reporters.d.DVUYHHhe.d.ts} +328 -79
  121. package/dist/chunks/rpc.MzXet3jl.js +144 -0
  122. package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.BFMWpdph.d.ts} +10 -2
  123. package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.B41N_kPE.js} +3 -3
  124. package/dist/chunks/{startModuleRunner.DEj0jb3e.js → startVitestModuleRunner.C3ZR-4J3.js} +265 -405
  125. package/dist/chunks/{suite.d.BJWk38HB.d.ts → suite.d.udJtyAgw.d.ts} +1 -1
  126. package/dist/chunks/{vi.2VT5v0um.js → test.CTcmp4Su.js} +538 -181
  127. package/dist/chunks/{utils.DvEY5TfP.js → utils.BX5Fg8C4.js} +8 -1
  128. package/dist/chunks/{vm.D3epNOPZ.js → vm.Dh2rTtmP.js} +48 -8
  129. package/dist/chunks/{worker.d.Dyxm8DEL.d.ts → worker.d.B84sVRy0.d.ts} +2 -2
  130. package/dist/cli.js +6 -5
  131. package/dist/client/.vite/manifest.json +6 -6
  132. package/dist/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
  133. package/dist/client/__vitest__/assets/index-Di71CKDo.js +63 -0
  134. package/dist/client/__vitest__/favicon.ico +0 -0
  135. package/dist/client/__vitest__/favicon.svg +49 -4
  136. package/dist/client/__vitest__/index.html +2 -2
  137. package/dist/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
  138. package/dist/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +167 -58
  139. package/dist/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
  140. package/dist/client/favicon.svg +49 -4
  141. package/dist/client/orchestrator.html +2 -2
  142. package/dist/client/tester/tester.html +2 -2
  143. package/dist/client.js +20 -13
  144. package/dist/config.cjs +3 -2
  145. package/dist/config.d.ts +13 -12
  146. package/dist/config.js +2 -2
  147. package/dist/context.js +108 -22
  148. package/dist/coverage.d.ts +12 -8
  149. package/dist/coverage.js +8 -5
  150. package/dist/environments.js +3 -1
  151. package/dist/expect-element.js +23 -23
  152. package/dist/index-5Pe7X7sp.js +7 -0
  153. package/dist/index.d.ts +66 -27
  154. package/dist/index.js +10 -9
  155. package/dist/locators.d.ts +14 -3
  156. package/dist/locators.js +1 -1
  157. package/dist/module-evaluator.d.ts +11 -1
  158. package/dist/module-evaluator.js +43 -26
  159. package/dist/node.d.ts +28 -14
  160. package/dist/node.js +42 -40
  161. package/dist/nodejs-worker-loader.js +41 -0
  162. package/dist/plugins/mocker-transforms.mjs +2 -0
  163. package/dist/plugins/utils-source-map-node.mjs +2 -0
  164. package/dist/reporters.d.ts +8 -8
  165. package/dist/reporters.js +7 -5
  166. package/dist/runners.d.ts +24 -5
  167. package/dist/runners.js +6 -6
  168. package/dist/runtime.d.ts +6 -0
  169. package/dist/runtime.js +35 -0
  170. package/dist/snapshot.js +4 -2
  171. package/dist/suite.d.ts +1 -1
  172. package/dist/suite.js +4 -2
  173. package/dist/vendor/blazediff_core.d.mts +1 -0
  174. package/dist/vendor/blazediff_core.mjs +117 -0
  175. package/dist/vendor/chai.mjs +4 -249
  176. package/dist/vendor/convert-source-map.d.mts +1 -0
  177. package/dist/vendor/convert-source-map.mjs +150 -0
  178. package/dist/vendor/expect-type.d.mts +14 -7
  179. package/dist/vendor/expect-type.mjs +5 -5
  180. package/dist/vendor/std-env.d.mts +131 -40
  181. package/dist/vendor/std-env.mjs +114 -117
  182. package/dist/worker.d.ts +6 -6
  183. package/dist/worker.js +27 -21
  184. package/dist/workers/forks.js +23 -17
  185. package/dist/workers/runVmTests.js +18 -16
  186. package/dist/workers/threads.js +23 -17
  187. package/dist/workers/vmForks.js +15 -12
  188. package/dist/workers/vmThreads.js +15 -12
  189. package/globals.d.ts +2 -0
  190. package/package.json +35 -26
  191. package/suppress-warnings.cjs +1 -0
  192. package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +0 -57
  193. package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
  194. package/dist/@vitest/browser/index-D6m36C6U.js +0 -11
  195. package/dist/@vitest/utils/chunk-_commonjsHelpers.js +0 -5
  196. package/dist/@vitest/utils/highlight.d.ts +0 -9
  197. package/dist/@vitest/utils/highlight.js +0 -538
  198. package/dist/chunks/date.Bq6ZW5rf.js +0 -73
  199. package/dist/chunks/rpc.BoxB0q7B.js +0 -76
  200. package/dist/chunks/test.B8ej_ZHS.js +0 -254
  201. package/dist/client/__vitest__/assets/index-BUCFJtth.js +0 -57
  202. package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
  203. package/dist/index-D6m36C6U.js +0 -6
  204. package/dist/mocker.d.ts +0 -1
  205. package/dist/mocker.js +0 -1
  206. package/dist/module-runner.js +0 -17
@@ -1,12 +1,12 @@
1
+ import { H as HoistMocksOptions } from './hoistMocks.d-w2ILr1dG.js';
2
+ export { c as createManualModuleSource } from './hoistMocks.d-w2ILr1dG.js';
1
3
  import { AutomockOptions } from './automock.js';
2
4
  export { automockModule } from './automock.js';
3
5
  import { Plugin, Rollup, ViteDevServer } from '@voidzero-dev/vite-plus-core';
4
6
  import { SourceMap } from '../../vendor/magic-string.mjs';
5
- import { M as MockerRegistry, S as ServerMockResolution, e as ServerIdResolution } from './types.d-B8CCKmHt.js';
7
+ import { M as MockerRegistry, S as ServerMockResolution, f as ServerIdResolution } from './types.d-BjI5eAwu.js';
6
8
  export { findMockRedirect } from './redirect.js';
7
9
 
8
- declare function createManualModuleSource(moduleUrl: string, exports: string[], globalAccessor?: string): string;
9
-
10
10
  declare function automockPlugin(options?: AutomockOptions): Plugin;
11
11
 
12
12
  interface DynamicImportPluginOptions {
@@ -18,732 +18,6 @@ interface DynamicImportPluginOptions {
18
18
  }
19
19
  declare function dynamicImportPlugin(options?: DynamicImportPluginOptions): Plugin;
20
20
 
21
- // This definition file follows a somewhat unusual format. ESTree allows
22
- // runtime type checks based on the `type` parameter. In order to explain this
23
- // to typescript we want to use discriminated union types:
24
- // https://github.com/Microsoft/TypeScript/pull/9163
25
- //
26
- // For ESTree this is a bit tricky because the high level interfaces like
27
- // Node or Function are pulling double duty. We want to pass common fields down
28
- // to the interfaces that extend them (like Identifier or
29
- // ArrowFunctionExpression), but you can't extend a type union or enforce
30
- // common fields on them. So we've split the high level interfaces into two
31
- // types, a base type which passes down inherited fields, and a type union of
32
- // all types which extend the base type. Only the type union is exported, and
33
- // the union is how other types refer to the collection of inheriting types.
34
- //
35
- // This makes the definitions file here somewhat more difficult to maintain,
36
- // but it has the notable advantage of making ESTree much easier to use as
37
- // an end user.
38
-
39
- interface BaseNodeWithoutComments {
40
- // Every leaf interface that extends BaseNode must specify a type property.
41
- // The type property should be a string literal. For example, Identifier
42
- // has: `type: "Identifier"`
43
- type: string;
44
- loc?: SourceLocation | null | undefined;
45
- range?: [number, number] | undefined;
46
- }
47
-
48
- interface BaseNode extends BaseNodeWithoutComments {
49
- leadingComments?: Comment[] | undefined;
50
- trailingComments?: Comment[] | undefined;
51
- }
52
-
53
- interface NodeMap {
54
- AssignmentProperty: AssignmentProperty;
55
- CatchClause: CatchClause;
56
- Class: Class;
57
- ClassBody: ClassBody;
58
- Expression: Expression;
59
- Function: Function;
60
- Identifier: Identifier;
61
- Literal: Literal;
62
- MethodDefinition: MethodDefinition;
63
- ModuleDeclaration: ModuleDeclaration;
64
- ModuleSpecifier: ModuleSpecifier;
65
- Pattern: Pattern;
66
- PrivateIdentifier: PrivateIdentifier;
67
- Program: Program;
68
- Property: Property;
69
- PropertyDefinition: PropertyDefinition;
70
- SpreadElement: SpreadElement;
71
- Statement: Statement;
72
- Super: Super;
73
- SwitchCase: SwitchCase;
74
- TemplateElement: TemplateElement;
75
- VariableDeclarator: VariableDeclarator;
76
- }
77
-
78
- type Node$1 = NodeMap[keyof NodeMap];
79
-
80
- interface Comment extends BaseNodeWithoutComments {
81
- type: "Line" | "Block";
82
- value: string;
83
- }
84
-
85
- interface SourceLocation {
86
- source?: string | null | undefined;
87
- start: Position;
88
- end: Position;
89
- }
90
-
91
- interface Position {
92
- /** >= 1 */
93
- line: number;
94
- /** >= 0 */
95
- column: number;
96
- }
97
-
98
- interface Program extends BaseNode {
99
- type: "Program";
100
- sourceType: "script" | "module";
101
- body: Array<Directive | Statement | ModuleDeclaration>;
102
- comments?: Comment[] | undefined;
103
- }
104
-
105
- interface Directive extends BaseNode {
106
- type: "ExpressionStatement";
107
- expression: Literal;
108
- directive: string;
109
- }
110
-
111
- interface BaseFunction extends BaseNode {
112
- params: Pattern[];
113
- generator?: boolean | undefined;
114
- async?: boolean | undefined;
115
- // The body is either BlockStatement or Expression because arrow functions
116
- // can have a body that's either. FunctionDeclarations and
117
- // FunctionExpressions have only BlockStatement bodies.
118
- body: BlockStatement | Expression;
119
- }
120
-
121
- type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
122
-
123
- type Statement =
124
- | ExpressionStatement
125
- | BlockStatement
126
- | StaticBlock
127
- | EmptyStatement
128
- | DebuggerStatement
129
- | WithStatement
130
- | ReturnStatement
131
- | LabeledStatement
132
- | BreakStatement
133
- | ContinueStatement
134
- | IfStatement
135
- | SwitchStatement
136
- | ThrowStatement
137
- | TryStatement
138
- | WhileStatement
139
- | DoWhileStatement
140
- | ForStatement
141
- | ForInStatement
142
- | ForOfStatement
143
- | Declaration;
144
-
145
- interface BaseStatement extends BaseNode {}
146
-
147
- interface EmptyStatement extends BaseStatement {
148
- type: "EmptyStatement";
149
- }
150
-
151
- interface BlockStatement extends BaseStatement {
152
- type: "BlockStatement";
153
- body: Statement[];
154
- innerComments?: Comment[] | undefined;
155
- }
156
-
157
- interface StaticBlock extends Omit<BlockStatement, "type"> {
158
- type: "StaticBlock";
159
- }
160
-
161
- interface ExpressionStatement extends BaseStatement {
162
- type: "ExpressionStatement";
163
- expression: Expression;
164
- }
165
-
166
- interface IfStatement extends BaseStatement {
167
- type: "IfStatement";
168
- test: Expression;
169
- consequent: Statement;
170
- alternate?: Statement | null | undefined;
171
- }
172
-
173
- interface LabeledStatement extends BaseStatement {
174
- type: "LabeledStatement";
175
- label: Identifier;
176
- body: Statement;
177
- }
178
-
179
- interface BreakStatement extends BaseStatement {
180
- type: "BreakStatement";
181
- label?: Identifier | null | undefined;
182
- }
183
-
184
- interface ContinueStatement extends BaseStatement {
185
- type: "ContinueStatement";
186
- label?: Identifier | null | undefined;
187
- }
188
-
189
- interface WithStatement extends BaseStatement {
190
- type: "WithStatement";
191
- object: Expression;
192
- body: Statement;
193
- }
194
-
195
- interface SwitchStatement extends BaseStatement {
196
- type: "SwitchStatement";
197
- discriminant: Expression;
198
- cases: SwitchCase[];
199
- }
200
-
201
- interface ReturnStatement extends BaseStatement {
202
- type: "ReturnStatement";
203
- argument?: Expression | null | undefined;
204
- }
205
-
206
- interface ThrowStatement extends BaseStatement {
207
- type: "ThrowStatement";
208
- argument: Expression;
209
- }
210
-
211
- interface TryStatement extends BaseStatement {
212
- type: "TryStatement";
213
- block: BlockStatement;
214
- handler?: CatchClause | null | undefined;
215
- finalizer?: BlockStatement | null | undefined;
216
- }
217
-
218
- interface WhileStatement extends BaseStatement {
219
- type: "WhileStatement";
220
- test: Expression;
221
- body: Statement;
222
- }
223
-
224
- interface DoWhileStatement extends BaseStatement {
225
- type: "DoWhileStatement";
226
- body: Statement;
227
- test: Expression;
228
- }
229
-
230
- interface ForStatement extends BaseStatement {
231
- type: "ForStatement";
232
- init?: VariableDeclaration | Expression | null | undefined;
233
- test?: Expression | null | undefined;
234
- update?: Expression | null | undefined;
235
- body: Statement;
236
- }
237
-
238
- interface BaseForXStatement extends BaseStatement {
239
- left: VariableDeclaration | Pattern;
240
- right: Expression;
241
- body: Statement;
242
- }
243
-
244
- interface ForInStatement extends BaseForXStatement {
245
- type: "ForInStatement";
246
- }
247
-
248
- interface DebuggerStatement extends BaseStatement {
249
- type: "DebuggerStatement";
250
- }
251
-
252
- type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
253
-
254
- interface BaseDeclaration extends BaseStatement {}
255
-
256
- interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
257
- type: "FunctionDeclaration";
258
- /** It is null when a function declaration is a part of the `export default function` statement */
259
- id: Identifier | null;
260
- body: BlockStatement;
261
- }
262
-
263
- interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
264
- id: Identifier;
265
- }
266
-
267
- interface VariableDeclaration extends BaseDeclaration {
268
- type: "VariableDeclaration";
269
- declarations: VariableDeclarator[];
270
- kind: "var" | "let" | "const" | "using" | "await using";
271
- }
272
-
273
- interface VariableDeclarator extends BaseNode {
274
- type: "VariableDeclarator";
275
- id: Pattern;
276
- init?: Expression | null | undefined;
277
- }
278
-
279
- interface ExpressionMap {
280
- ArrayExpression: ArrayExpression;
281
- ArrowFunctionExpression: ArrowFunctionExpression;
282
- AssignmentExpression: AssignmentExpression;
283
- AwaitExpression: AwaitExpression;
284
- BinaryExpression: BinaryExpression;
285
- CallExpression: CallExpression;
286
- ChainExpression: ChainExpression;
287
- ClassExpression: ClassExpression;
288
- ConditionalExpression: ConditionalExpression;
289
- FunctionExpression: FunctionExpression;
290
- Identifier: Identifier;
291
- ImportExpression: ImportExpression;
292
- Literal: Literal;
293
- LogicalExpression: LogicalExpression;
294
- MemberExpression: MemberExpression;
295
- MetaProperty: MetaProperty;
296
- NewExpression: NewExpression;
297
- ObjectExpression: ObjectExpression;
298
- SequenceExpression: SequenceExpression;
299
- TaggedTemplateExpression: TaggedTemplateExpression;
300
- TemplateLiteral: TemplateLiteral;
301
- ThisExpression: ThisExpression;
302
- UnaryExpression: UnaryExpression;
303
- UpdateExpression: UpdateExpression;
304
- YieldExpression: YieldExpression;
305
- }
306
-
307
- type Expression = ExpressionMap[keyof ExpressionMap];
308
-
309
- interface BaseExpression extends BaseNode {}
310
-
311
- type ChainElement = SimpleCallExpression | MemberExpression;
312
-
313
- interface ChainExpression extends BaseExpression {
314
- type: "ChainExpression";
315
- expression: ChainElement;
316
- }
317
-
318
- interface ThisExpression extends BaseExpression {
319
- type: "ThisExpression";
320
- }
321
-
322
- interface ArrayExpression extends BaseExpression {
323
- type: "ArrayExpression";
324
- elements: Array<Expression | SpreadElement | null>;
325
- }
326
-
327
- interface ObjectExpression extends BaseExpression {
328
- type: "ObjectExpression";
329
- properties: Array<Property | SpreadElement>;
330
- }
331
-
332
- interface PrivateIdentifier extends BaseNode {
333
- type: "PrivateIdentifier";
334
- name: string;
335
- }
336
-
337
- interface Property extends BaseNode {
338
- type: "Property";
339
- key: Expression | PrivateIdentifier;
340
- value: Expression | Pattern; // Could be an AssignmentProperty
341
- kind: "init" | "get" | "set";
342
- method: boolean;
343
- shorthand: boolean;
344
- computed: boolean;
345
- }
346
-
347
- interface PropertyDefinition extends BaseNode {
348
- type: "PropertyDefinition";
349
- key: Expression | PrivateIdentifier;
350
- value?: Expression | null | undefined;
351
- computed: boolean;
352
- static: boolean;
353
- }
354
-
355
- interface FunctionExpression extends BaseFunction, BaseExpression {
356
- id?: Identifier | null | undefined;
357
- type: "FunctionExpression";
358
- body: BlockStatement;
359
- }
360
-
361
- interface SequenceExpression extends BaseExpression {
362
- type: "SequenceExpression";
363
- expressions: Expression[];
364
- }
365
-
366
- interface UnaryExpression extends BaseExpression {
367
- type: "UnaryExpression";
368
- operator: UnaryOperator;
369
- prefix: true;
370
- argument: Expression;
371
- }
372
-
373
- interface BinaryExpression extends BaseExpression {
374
- type: "BinaryExpression";
375
- operator: BinaryOperator;
376
- left: Expression | PrivateIdentifier;
377
- right: Expression;
378
- }
379
-
380
- interface AssignmentExpression extends BaseExpression {
381
- type: "AssignmentExpression";
382
- operator: AssignmentOperator;
383
- left: Pattern | MemberExpression;
384
- right: Expression;
385
- }
386
-
387
- interface UpdateExpression extends BaseExpression {
388
- type: "UpdateExpression";
389
- operator: UpdateOperator;
390
- argument: Expression;
391
- prefix: boolean;
392
- }
393
-
394
- interface LogicalExpression extends BaseExpression {
395
- type: "LogicalExpression";
396
- operator: LogicalOperator;
397
- left: Expression;
398
- right: Expression;
399
- }
400
-
401
- interface ConditionalExpression extends BaseExpression {
402
- type: "ConditionalExpression";
403
- test: Expression;
404
- alternate: Expression;
405
- consequent: Expression;
406
- }
407
-
408
- interface BaseCallExpression extends BaseExpression {
409
- callee: Expression | Super;
410
- arguments: Array<Expression | SpreadElement>;
411
- }
412
- type CallExpression = SimpleCallExpression | NewExpression;
413
-
414
- interface SimpleCallExpression extends BaseCallExpression {
415
- type: "CallExpression";
416
- optional: boolean;
417
- }
418
-
419
- interface NewExpression extends BaseCallExpression {
420
- type: "NewExpression";
421
- }
422
-
423
- interface MemberExpression extends BaseExpression, BasePattern {
424
- type: "MemberExpression";
425
- object: Expression | Super;
426
- property: Expression | PrivateIdentifier;
427
- computed: boolean;
428
- optional: boolean;
429
- }
430
-
431
- type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
432
-
433
- interface BasePattern extends BaseNode {}
434
-
435
- interface SwitchCase extends BaseNode {
436
- type: "SwitchCase";
437
- test?: Expression | null | undefined;
438
- consequent: Statement[];
439
- }
440
-
441
- interface CatchClause extends BaseNode {
442
- type: "CatchClause";
443
- param: Pattern | null;
444
- body: BlockStatement;
445
- }
446
-
447
- interface Identifier extends BaseNode, BaseExpression, BasePattern {
448
- type: "Identifier";
449
- name: string;
450
- }
451
-
452
- type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
453
-
454
- interface SimpleLiteral extends BaseNode, BaseExpression {
455
- type: "Literal";
456
- value: string | boolean | number | null;
457
- raw?: string | undefined;
458
- }
459
-
460
- interface RegExpLiteral extends BaseNode, BaseExpression {
461
- type: "Literal";
462
- value?: RegExp | null | undefined;
463
- regex: {
464
- pattern: string;
465
- flags: string;
466
- };
467
- raw?: string | undefined;
468
- }
469
-
470
- interface BigIntLiteral extends BaseNode, BaseExpression {
471
- type: "Literal";
472
- value?: bigint | null | undefined;
473
- bigint: string;
474
- raw?: string | undefined;
475
- }
476
-
477
- type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
478
-
479
- type BinaryOperator =
480
- | "=="
481
- | "!="
482
- | "==="
483
- | "!=="
484
- | "<"
485
- | "<="
486
- | ">"
487
- | ">="
488
- | "<<"
489
- | ">>"
490
- | ">>>"
491
- | "+"
492
- | "-"
493
- | "*"
494
- | "/"
495
- | "%"
496
- | "**"
497
- | "|"
498
- | "^"
499
- | "&"
500
- | "in"
501
- | "instanceof";
502
-
503
- type LogicalOperator = "||" | "&&" | "??";
504
-
505
- type AssignmentOperator =
506
- | "="
507
- | "+="
508
- | "-="
509
- | "*="
510
- | "/="
511
- | "%="
512
- | "**="
513
- | "<<="
514
- | ">>="
515
- | ">>>="
516
- | "|="
517
- | "^="
518
- | "&="
519
- | "||="
520
- | "&&="
521
- | "??=";
522
-
523
- type UpdateOperator = "++" | "--";
524
-
525
- interface ForOfStatement extends BaseForXStatement {
526
- type: "ForOfStatement";
527
- await: boolean;
528
- }
529
-
530
- interface Super extends BaseNode {
531
- type: "Super";
532
- }
533
-
534
- interface SpreadElement extends BaseNode {
535
- type: "SpreadElement";
536
- argument: Expression;
537
- }
538
-
539
- interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
540
- type: "ArrowFunctionExpression";
541
- expression: boolean;
542
- body: BlockStatement | Expression;
543
- }
544
-
545
- interface YieldExpression extends BaseExpression {
546
- type: "YieldExpression";
547
- argument?: Expression | null | undefined;
548
- delegate: boolean;
549
- }
550
-
551
- interface TemplateLiteral extends BaseExpression {
552
- type: "TemplateLiteral";
553
- quasis: TemplateElement[];
554
- expressions: Expression[];
555
- }
556
-
557
- interface TaggedTemplateExpression extends BaseExpression {
558
- type: "TaggedTemplateExpression";
559
- tag: Expression;
560
- quasi: TemplateLiteral;
561
- }
562
-
563
- interface TemplateElement extends BaseNode {
564
- type: "TemplateElement";
565
- tail: boolean;
566
- value: {
567
- /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
568
- cooked?: string | null | undefined;
569
- raw: string;
570
- };
571
- }
572
-
573
- interface AssignmentProperty extends Property {
574
- value: Pattern;
575
- kind: "init";
576
- method: boolean; // false
577
- }
578
-
579
- interface ObjectPattern extends BasePattern {
580
- type: "ObjectPattern";
581
- properties: Array<AssignmentProperty | RestElement>;
582
- }
583
-
584
- interface ArrayPattern extends BasePattern {
585
- type: "ArrayPattern";
586
- elements: Array<Pattern | null>;
587
- }
588
-
589
- interface RestElement extends BasePattern {
590
- type: "RestElement";
591
- argument: Pattern;
592
- }
593
-
594
- interface AssignmentPattern extends BasePattern {
595
- type: "AssignmentPattern";
596
- left: Pattern;
597
- right: Expression;
598
- }
599
-
600
- type Class = ClassDeclaration | ClassExpression;
601
- interface BaseClass extends BaseNode {
602
- superClass?: Expression | null | undefined;
603
- body: ClassBody;
604
- }
605
-
606
- interface ClassBody extends BaseNode {
607
- type: "ClassBody";
608
- body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
609
- }
610
-
611
- interface MethodDefinition extends BaseNode {
612
- type: "MethodDefinition";
613
- key: Expression | PrivateIdentifier;
614
- value: FunctionExpression;
615
- kind: "constructor" | "method" | "get" | "set";
616
- computed: boolean;
617
- static: boolean;
618
- }
619
-
620
- interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
621
- type: "ClassDeclaration";
622
- /** It is null when a class declaration is a part of the `export default class` statement */
623
- id: Identifier | null;
624
- }
625
-
626
- interface ClassDeclaration extends MaybeNamedClassDeclaration {
627
- id: Identifier;
628
- }
629
-
630
- interface ClassExpression extends BaseClass, BaseExpression {
631
- type: "ClassExpression";
632
- id?: Identifier | null | undefined;
633
- }
634
-
635
- interface MetaProperty extends BaseExpression {
636
- type: "MetaProperty";
637
- meta: Identifier;
638
- property: Identifier;
639
- }
640
-
641
- type ModuleDeclaration =
642
- | ImportDeclaration
643
- | ExportNamedDeclaration
644
- | ExportDefaultDeclaration
645
- | ExportAllDeclaration;
646
- interface BaseModuleDeclaration extends BaseNode {}
647
-
648
- type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
649
- interface BaseModuleSpecifier extends BaseNode {
650
- local: Identifier;
651
- }
652
-
653
- interface ImportDeclaration extends BaseModuleDeclaration {
654
- type: "ImportDeclaration";
655
- specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
656
- attributes: ImportAttribute[];
657
- source: Literal;
658
- }
659
-
660
- interface ImportSpecifier extends BaseModuleSpecifier {
661
- type: "ImportSpecifier";
662
- imported: Identifier | Literal;
663
- }
664
-
665
- interface ImportAttribute extends BaseNode {
666
- type: "ImportAttribute";
667
- key: Identifier | Literal;
668
- value: Literal;
669
- }
670
-
671
- interface ImportExpression extends BaseExpression {
672
- type: "ImportExpression";
673
- source: Expression;
674
- options?: Expression | null | undefined;
675
- }
676
-
677
- interface ImportDefaultSpecifier extends BaseModuleSpecifier {
678
- type: "ImportDefaultSpecifier";
679
- }
680
-
681
- interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
682
- type: "ImportNamespaceSpecifier";
683
- }
684
-
685
- interface ExportNamedDeclaration extends BaseModuleDeclaration {
686
- type: "ExportNamedDeclaration";
687
- declaration?: Declaration | null | undefined;
688
- specifiers: ExportSpecifier[];
689
- attributes: ImportAttribute[];
690
- source?: Literal | null | undefined;
691
- }
692
-
693
- interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
694
- type: "ExportSpecifier";
695
- local: Identifier | Literal;
696
- exported: Identifier | Literal;
697
- }
698
-
699
- interface ExportDefaultDeclaration extends BaseModuleDeclaration {
700
- type: "ExportDefaultDeclaration";
701
- declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
702
- }
703
-
704
- interface ExportAllDeclaration extends BaseModuleDeclaration {
705
- type: "ExportAllDeclaration";
706
- exported: Identifier | Literal | null;
707
- attributes: ImportAttribute[];
708
- source: Literal;
709
- }
710
-
711
- interface AwaitExpression extends BaseExpression {
712
- type: "AwaitExpression";
713
- argument: Expression;
714
- }
715
-
716
- type Positioned<T> = T & {
717
- start: number;
718
- end: number;
719
- };
720
- type Node = Positioned<Node$1>;
721
-
722
- interface HoistMocksOptions {
723
- /**
724
- * List of modules that should always be imported before compiler hints.
725
- * @default 'vitest'
726
- */
727
- hoistedModule?: string;
728
- /**
729
- * @default ["vi", "vitest"]
730
- */
731
- utilsObjectNames?: string[];
732
- /**
733
- * @default ["mock", "unmock"]
734
- */
735
- hoistableMockMethodNames?: string[];
736
- /**
737
- * @default ["mock", "unmock", "doMock", "doUnmock"]
738
- */
739
- dynamicImportMockMethodNames?: string[];
740
- /**
741
- * @default ["hoisted"]
742
- */
743
- hoistedMethodNames?: string[];
744
- regexpHoistable?: RegExp;
745
- codeFrameGenerator?: CodeFrameGenerator;
746
- }
747
21
  interface HoistMocksPluginOptions extends Omit<HoistMocksOptions, "regexpHoistable"> {
748
22
  include?: string | RegExp | (string | RegExp)[];
749
23
  exclude?: string | RegExp | (string | RegExp)[];
@@ -753,14 +27,11 @@ interface HoistMocksPluginOptions extends Omit<HoistMocksOptions, "regexpHoistab
753
27
  filter?: (id: string) => boolean;
754
28
  }
755
29
  declare function hoistMocksPlugin(options?: HoistMocksPluginOptions): Plugin;
30
+ declare function hoistMockAndResolve(code: string, id: string, parse: Rollup.PluginContext["parse"], options?: HoistMocksOptions): HoistMocksResult | undefined;
756
31
  interface HoistMocksResult {
757
32
  code: string;
758
33
  map: SourceMap;
759
34
  }
760
- interface CodeFrameGenerator {
761
- (node: Positioned<Node>, id: string, code: string): string;
762
- }
763
- declare function hoistMocks(code: string, id: string, parse: Rollup.PluginContext["parse"], options?: HoistMocksOptions): HoistMocksResult | undefined;
764
35
 
765
36
  interface InterceptorPluginOptions {
766
37
  /**
@@ -796,5 +67,5 @@ declare class ServerMockResolver {
796
67
  private resolveModule;
797
68
  }
798
69
 
799
- export { AutomockOptions as AutomockPluginOptions, ServerMockResolver, automockPlugin, createManualModuleSource, dynamicImportPlugin, hoistMocks, hoistMocksPlugin, interceptorPlugin, mockerPlugin };
70
+ export { AutomockOptions as AutomockPluginOptions, ServerMockResolver, automockPlugin, dynamicImportPlugin, hoistMockAndResolve as hoistMocks, hoistMocksPlugin, interceptorPlugin, mockerPlugin };
800
71
  export type { HoistMocksPluginOptions, HoistMocksResult, InterceptorPluginOptions, ServerResolverOptions };