@pezkuwi/dev-test 0.85.1 → 0.85.3

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 (127) hide show
  1. package/.skip-deno +0 -0
  2. package/package.json +9 -199
  3. package/tsconfig.build.json +16 -0
  4. package/tsconfig.build.tsbuildinfo +1 -0
  5. package/tsconfig.spec.json +16 -0
  6. package/tsconfig.spec.tsbuildinfo +1 -0
  7. package/LICENSE +0 -201
  8. package/browser.d.ts +0 -1
  9. package/browser.js +0 -2
  10. package/cjs/browser.d.ts +0 -1
  11. package/cjs/browser.js +0 -4
  12. package/cjs/detectOther.d.ts +0 -2
  13. package/cjs/detectOther.js +0 -3
  14. package/cjs/env/browser.d.ts +0 -313
  15. package/cjs/env/browser.js +0 -98
  16. package/cjs/env/expect.d.ts +0 -297
  17. package/cjs/env/expect.js +0 -213
  18. package/cjs/env/index.d.ts +0 -4
  19. package/cjs/env/index.js +0 -20
  20. package/cjs/env/jest.d.ts +0 -127
  21. package/cjs/env/jest.js +0 -56
  22. package/cjs/env/lifecycle.d.ts +0 -12
  23. package/cjs/env/lifecycle.js +0 -17
  24. package/cjs/env/suite.d.ts +0 -16
  25. package/cjs/env/suite.js +0 -35
  26. package/cjs/index.d.ts +0 -1
  27. package/cjs/index.js +0 -1
  28. package/cjs/node.d.ts +0 -1
  29. package/cjs/node.js +0 -4
  30. package/cjs/package.json +0 -3
  31. package/cjs/packageInfo.d.ts +0 -6
  32. package/cjs/packageInfo.js +0 -4
  33. package/cjs/root.d.ts +0 -2
  34. package/cjs/root.js +0 -6
  35. package/cjs/rootJs/Clazz.d.ts +0 -18
  36. package/cjs/rootJs/Clazz.js +0 -36
  37. package/cjs/rootJs/Jsx.d.ts +0 -5
  38. package/cjs/rootJs/Jsx.js +0 -16
  39. package/cjs/rootJs/JsxChild.d.ts +0 -9
  40. package/cjs/rootJs/JsxChild.js +0 -9
  41. package/cjs/rootJs/augmented.d.ts +0 -8
  42. package/cjs/rootJs/augmented.js +0 -3
  43. package/cjs/rootJs/index.d.ts +0 -19
  44. package/cjs/rootJs/index.js +0 -51
  45. package/cjs/rootTests.d.ts +0 -2
  46. package/cjs/rootTests.js +0 -44
  47. package/cjs/sample.d.ts +0 -1
  48. package/cjs/sample.js +0 -4
  49. package/cjs/types.d.ts +0 -15
  50. package/cjs/types.js +0 -2
  51. package/cjs/util.d.ts +0 -20
  52. package/cjs/util.js +0 -51
  53. package/config/eslint.js +0 -160
  54. package/config/eslint.rules.js +0 -214
  55. package/config/prettier.cjs +0 -22
  56. package/config/rollup.js +0 -113
  57. package/config/tsconfig.json +0 -32
  58. package/config/typedoc.cjs +0 -18
  59. package/detectOther.d.ts +0 -2
  60. package/detectOther.js +0 -1
  61. package/env/browser.d.ts +0 -313
  62. package/env/browser.js +0 -95
  63. package/env/expect.d.ts +0 -297
  64. package/env/expect.js +0 -210
  65. package/env/index.d.ts +0 -4
  66. package/env/index.js +0 -17
  67. package/env/jest.d.ts +0 -127
  68. package/env/jest.js +0 -53
  69. package/env/lifecycle.d.ts +0 -12
  70. package/env/lifecycle.js +0 -14
  71. package/env/suite.d.ts +0 -16
  72. package/env/suite.js +0 -32
  73. package/globals.cjs +0 -4
  74. package/globals.d.cts +0 -1
  75. package/globals.d.ts +0 -32
  76. package/index.d.ts +0 -1
  77. package/index.js +0 -1
  78. package/node.d.ts +0 -1
  79. package/node.js +0 -2
  80. package/packageInfo.d.ts +0 -6
  81. package/packageInfo.js +0 -1
  82. package/root.d.ts +0 -2
  83. package/root.js +0 -2
  84. package/rootJs/Clazz.d.ts +0 -18
  85. package/rootJs/Clazz.js +0 -32
  86. package/rootJs/Jsx.d.ts +0 -5
  87. package/rootJs/Jsx.js +0 -13
  88. package/rootJs/JsxChild.d.ts +0 -9
  89. package/rootJs/JsxChild.js +0 -6
  90. package/rootJs/augmented.d.ts +0 -8
  91. package/rootJs/augmented.js +0 -2
  92. package/rootJs/dynamic.d.mts +0 -8
  93. package/rootJs/dynamic.mjs +0 -13
  94. package/rootJs/index.d.ts +0 -19
  95. package/rootJs/index.js +0 -39
  96. package/rootJs/testJson.json +0 -5
  97. package/rootStatic/zagros.svg +0 -1
  98. package/rootTests.d.ts +0 -2
  99. package/rootTests.js +0 -41
  100. package/scripts/pezkuwi-ci-ghact-build.mjs +0 -536
  101. package/scripts/pezkuwi-ci-ghact-docs.mjs +0 -14
  102. package/scripts/pezkuwi-ci-ghpages-force.mjs +0 -43
  103. package/scripts/pezkuwi-dev-build-docs.mjs +0 -19
  104. package/scripts/pezkuwi-dev-build-ts.mjs +0 -1518
  105. package/scripts/pezkuwi-dev-circular.mjs +0 -29
  106. package/scripts/pezkuwi-dev-clean-build.mjs +0 -61
  107. package/scripts/pezkuwi-dev-contrib.mjs +0 -74
  108. package/scripts/pezkuwi-dev-copy-dir.mjs +0 -44
  109. package/scripts/pezkuwi-dev-copy-to.mjs +0 -53
  110. package/scripts/pezkuwi-dev-deno-map.mjs +0 -35
  111. package/scripts/pezkuwi-dev-run-lint.mjs +0 -40
  112. package/scripts/pezkuwi-dev-run-node-ts.mjs +0 -9
  113. package/scripts/pezkuwi-dev-run-test.mjs +0 -163
  114. package/scripts/pezkuwi-dev-version.mjs +0 -143
  115. package/scripts/pezkuwi-dev-yarn-only.mjs +0 -11
  116. package/scripts/pezkuwi-exec-eslint.mjs +0 -7
  117. package/scripts/pezkuwi-exec-ghpages.mjs +0 -11
  118. package/scripts/pezkuwi-exec-ghrelease.mjs +0 -7
  119. package/scripts/pezkuwi-exec-node-test.mjs +0 -368
  120. package/scripts/pezkuwi-exec-rollup.mjs +0 -7
  121. package/scripts/pezkuwi-exec-tsc.mjs +0 -7
  122. package/scripts/pezkuwi-exec-webpack.mjs +0 -7
  123. package/scripts/util.mjs +0 -540
  124. package/types.d.ts +0 -15
  125. package/types.js +0 -1
  126. package/util.d.ts +0 -20
  127. package/util.js +0 -46
package/env/expect.d.ts DELETED
@@ -1,297 +0,0 @@
1
- type AssertMatchFn = (value: unknown) => void;
2
- /**
3
- * @internal
4
- *
5
- * A helper that wraps a matching function in an ExpectMatcher. This is (currently)
6
- * only used/checked for in the calledWith* helpers
7
- *
8
- * TODO We don't use it in pezkuwi-js, but a useful enhancement could be for
9
- * any of the to* expectations to detect and use those. An example of useful code
10
- * in that case:
11
- *
12
- * ```js
13
- * expect({
14
- * a: 'blah',
15
- * b: 3
16
- * }).toEqual(
17
- * expect.objectContaining({ b: 3 })
18
- * )
19
- * ```
20
- *
21
- * An example of matcher use can be seen in the isCalledWith loops
22
- */
23
- declare class Matcher {
24
- assertMatch: AssertMatchFn;
25
- constructor(assertFn: (value: any, check: any) => void, check?: unknown);
26
- }
27
- /**
28
- * Sets up the shimmed expect(...) function, including all .to* and .not.to*
29
- * functions. This is not comprehensive, rather is contains what we need to
30
- * make all pezkuwi-js usages pass
31
- **/
32
- export declare function expect(): {
33
- expect: ((value: unknown) => {
34
- not: {
35
- toBe: (other: unknown) => void;
36
- toBeDefined: () => void;
37
- toBeNull: (value: unknown) => void;
38
- toBeUndefined: () => void;
39
- toEqual: (other: unknown) => void;
40
- toHaveBeenCalled: () => void;
41
- toThrow: (message?: RegExp | Error | string) => void;
42
- } & Omit<{
43
- not: import("../types.js").StubFn;
44
- toMatchInlineSnapshot: import("../types.js").StubFn;
45
- toMatchSnapshot: import("../types.js").StubFn;
46
- toThrowErrorMatchingInlineSnapshot: import("../types.js").StubFn;
47
- toThrowErrorMatchingSnapshot: import("../types.js").StubFn;
48
- lastCalledWith: import("../types.js").StubFn;
49
- lastReturnedWith: import("../types.js").StubFn;
50
- nthCalledWith: import("../types.js").StubFn;
51
- nthReturnedWith: import("../types.js").StubFn;
52
- rejects: import("../types.js").StubFn;
53
- resolves: import("../types.js").StubFn;
54
- toBe: import("../types.js").StubFn;
55
- toBeCalled: import("../types.js").StubFn;
56
- toBeCalledTimes: import("../types.js").StubFn;
57
- toBeCalledWith: import("../types.js").StubFn;
58
- toBeCloseTo: import("../types.js").StubFn;
59
- toBeDefined: import("../types.js").StubFn;
60
- toBeFalsy: import("../types.js").StubFn;
61
- toBeGreaterThan: import("../types.js").StubFn;
62
- toBeGreaterThanOrEqual: import("../types.js").StubFn;
63
- toBeInstanceOf: import("../types.js").StubFn;
64
- toBeLessThan: import("../types.js").StubFn;
65
- toBeLessThanOrEqual: import("../types.js").StubFn;
66
- toBeNaN: import("../types.js").StubFn;
67
- toBeNull: import("../types.js").StubFn;
68
- toBeTruthy: import("../types.js").StubFn;
69
- toBeUndefined: import("../types.js").StubFn;
70
- toContain: import("../types.js").StubFn;
71
- toContainEqual: import("../types.js").StubFn;
72
- toEqual: import("../types.js").StubFn;
73
- toHaveBeenCalled: import("../types.js").StubFn;
74
- toHaveBeenCalledTimes: import("../types.js").StubFn;
75
- toHaveBeenCalledWith: import("../types.js").StubFn;
76
- toHaveBeenLastCalledWith: import("../types.js").StubFn;
77
- toHaveBeenNthCalledWith: import("../types.js").StubFn;
78
- toHaveLastReturnedWith: import("../types.js").StubFn;
79
- toHaveLength: import("../types.js").StubFn;
80
- toHaveNthReturnedWith: import("../types.js").StubFn;
81
- toHaveProperty: import("../types.js").StubFn;
82
- toHaveReturned: import("../types.js").StubFn;
83
- toHaveReturnedTimes: import("../types.js").StubFn;
84
- toHaveReturnedWith: import("../types.js").StubFn;
85
- toMatch: import("../types.js").StubFn;
86
- toMatchObject: import("../types.js").StubFn;
87
- toReturn: import("../types.js").StubFn;
88
- toReturnTimes: import("../types.js").StubFn;
89
- toReturnWith: import("../types.js").StubFn;
90
- toStrictEqual: import("../types.js").StubFn;
91
- toThrow: import("../types.js").StubFn;
92
- toThrowError: import("../types.js").StubFn;
93
- }, "toBe" | "toBeDefined" | "toBeNull" | "toBeUndefined" | "toEqual" | "toHaveBeenCalled" | "toThrow">;
94
- rejects: {
95
- toThrow: (message?: RegExp | Error | string) => Promise<void>;
96
- } & Omit<{
97
- not: import("../types.js").StubFn;
98
- toMatchInlineSnapshot: import("../types.js").StubFn;
99
- toMatchSnapshot: import("../types.js").StubFn;
100
- toThrowErrorMatchingInlineSnapshot: import("../types.js").StubFn;
101
- toThrowErrorMatchingSnapshot: import("../types.js").StubFn;
102
- lastCalledWith: import("../types.js").StubFn;
103
- lastReturnedWith: import("../types.js").StubFn;
104
- nthCalledWith: import("../types.js").StubFn;
105
- nthReturnedWith: import("../types.js").StubFn;
106
- rejects: import("../types.js").StubFn;
107
- resolves: import("../types.js").StubFn;
108
- toBe: import("../types.js").StubFn;
109
- toBeCalled: import("../types.js").StubFn;
110
- toBeCalledTimes: import("../types.js").StubFn;
111
- toBeCalledWith: import("../types.js").StubFn;
112
- toBeCloseTo: import("../types.js").StubFn;
113
- toBeDefined: import("../types.js").StubFn;
114
- toBeFalsy: import("../types.js").StubFn;
115
- toBeGreaterThan: import("../types.js").StubFn;
116
- toBeGreaterThanOrEqual: import("../types.js").StubFn;
117
- toBeInstanceOf: import("../types.js").StubFn;
118
- toBeLessThan: import("../types.js").StubFn;
119
- toBeLessThanOrEqual: import("../types.js").StubFn;
120
- toBeNaN: import("../types.js").StubFn;
121
- toBeNull: import("../types.js").StubFn;
122
- toBeTruthy: import("../types.js").StubFn;
123
- toBeUndefined: import("../types.js").StubFn;
124
- toContain: import("../types.js").StubFn;
125
- toContainEqual: import("../types.js").StubFn;
126
- toEqual: import("../types.js").StubFn;
127
- toHaveBeenCalled: import("../types.js").StubFn;
128
- toHaveBeenCalledTimes: import("../types.js").StubFn;
129
- toHaveBeenCalledWith: import("../types.js").StubFn;
130
- toHaveBeenLastCalledWith: import("../types.js").StubFn;
131
- toHaveBeenNthCalledWith: import("../types.js").StubFn;
132
- toHaveLastReturnedWith: import("../types.js").StubFn;
133
- toHaveLength: import("../types.js").StubFn;
134
- toHaveNthReturnedWith: import("../types.js").StubFn;
135
- toHaveProperty: import("../types.js").StubFn;
136
- toHaveReturned: import("../types.js").StubFn;
137
- toHaveReturnedTimes: import("../types.js").StubFn;
138
- toHaveReturnedWith: import("../types.js").StubFn;
139
- toMatch: import("../types.js").StubFn;
140
- toMatchObject: import("../types.js").StubFn;
141
- toReturn: import("../types.js").StubFn;
142
- toReturnTimes: import("../types.js").StubFn;
143
- toReturnWith: import("../types.js").StubFn;
144
- toStrictEqual: import("../types.js").StubFn;
145
- toThrow: import("../types.js").StubFn;
146
- toThrowError: import("../types.js").StubFn;
147
- }, "toThrow">;
148
- resolves: Omit<{
149
- not: import("../types.js").StubFn;
150
- toMatchInlineSnapshot: import("../types.js").StubFn;
151
- toMatchSnapshot: import("../types.js").StubFn;
152
- toThrowErrorMatchingInlineSnapshot: import("../types.js").StubFn;
153
- toThrowErrorMatchingSnapshot: import("../types.js").StubFn;
154
- lastCalledWith: import("../types.js").StubFn;
155
- lastReturnedWith: import("../types.js").StubFn;
156
- nthCalledWith: import("../types.js").StubFn;
157
- nthReturnedWith: import("../types.js").StubFn;
158
- rejects: import("../types.js").StubFn;
159
- resolves: import("../types.js").StubFn;
160
- toBe: import("../types.js").StubFn;
161
- toBeCalled: import("../types.js").StubFn;
162
- toBeCalledTimes: import("../types.js").StubFn;
163
- toBeCalledWith: import("../types.js").StubFn;
164
- toBeCloseTo: import("../types.js").StubFn;
165
- toBeDefined: import("../types.js").StubFn;
166
- toBeFalsy: import("../types.js").StubFn;
167
- toBeGreaterThan: import("../types.js").StubFn;
168
- toBeGreaterThanOrEqual: import("../types.js").StubFn;
169
- toBeInstanceOf: import("../types.js").StubFn;
170
- toBeLessThan: import("../types.js").StubFn;
171
- toBeLessThanOrEqual: import("../types.js").StubFn;
172
- toBeNaN: import("../types.js").StubFn;
173
- toBeNull: import("../types.js").StubFn;
174
- toBeTruthy: import("../types.js").StubFn;
175
- toBeUndefined: import("../types.js").StubFn;
176
- toContain: import("../types.js").StubFn;
177
- toContainEqual: import("../types.js").StubFn;
178
- toEqual: import("../types.js").StubFn;
179
- toHaveBeenCalled: import("../types.js").StubFn;
180
- toHaveBeenCalledTimes: import("../types.js").StubFn;
181
- toHaveBeenCalledWith: import("../types.js").StubFn;
182
- toHaveBeenLastCalledWith: import("../types.js").StubFn;
183
- toHaveBeenNthCalledWith: import("../types.js").StubFn;
184
- toHaveLastReturnedWith: import("../types.js").StubFn;
185
- toHaveLength: import("../types.js").StubFn;
186
- toHaveNthReturnedWith: import("../types.js").StubFn;
187
- toHaveProperty: import("../types.js").StubFn;
188
- toHaveReturned: import("../types.js").StubFn;
189
- toHaveReturnedTimes: import("../types.js").StubFn;
190
- toHaveReturnedWith: import("../types.js").StubFn;
191
- toMatch: import("../types.js").StubFn;
192
- toMatchObject: import("../types.js").StubFn;
193
- toReturn: import("../types.js").StubFn;
194
- toReturnTimes: import("../types.js").StubFn;
195
- toReturnWith: import("../types.js").StubFn;
196
- toStrictEqual: import("../types.js").StubFn;
197
- toThrow: import("../types.js").StubFn;
198
- toThrowError: import("../types.js").StubFn;
199
- }, never>;
200
- toBe: (other: unknown) => void;
201
- toBeDefined: () => void;
202
- toBeFalsy: () => void;
203
- toBeInstanceOf: (Clazz: Function) => void;
204
- toBeNull: (value: unknown) => void;
205
- toBeTruthy: () => void;
206
- toBeUndefined: () => void;
207
- toEqual: (other: unknown) => void;
208
- toHaveBeenCalled: () => void;
209
- toHaveBeenCalledTimes: (count: number) => void;
210
- toHaveBeenCalledWith: (...args: unknown[]) => void;
211
- toHaveBeenLastCalledWith: (...args: unknown[]) => void;
212
- toHaveLength: (length: number) => void;
213
- toMatch: (check: string | RegExp) => void;
214
- toMatchObject: (check: object) => void;
215
- toThrow: (message?: RegExp | Error | string) => void;
216
- } & Omit<{
217
- not: import("../types.js").StubFn;
218
- toMatchInlineSnapshot: import("../types.js").StubFn;
219
- toMatchSnapshot: import("../types.js").StubFn;
220
- toThrowErrorMatchingInlineSnapshot: import("../types.js").StubFn;
221
- toThrowErrorMatchingSnapshot: import("../types.js").StubFn;
222
- lastCalledWith: import("../types.js").StubFn;
223
- lastReturnedWith: import("../types.js").StubFn;
224
- nthCalledWith: import("../types.js").StubFn;
225
- nthReturnedWith: import("../types.js").StubFn;
226
- rejects: import("../types.js").StubFn;
227
- resolves: import("../types.js").StubFn;
228
- toBe: import("../types.js").StubFn;
229
- toBeCalled: import("../types.js").StubFn;
230
- toBeCalledTimes: import("../types.js").StubFn;
231
- toBeCalledWith: import("../types.js").StubFn;
232
- toBeCloseTo: import("../types.js").StubFn;
233
- toBeDefined: import("../types.js").StubFn;
234
- toBeFalsy: import("../types.js").StubFn;
235
- toBeGreaterThan: import("../types.js").StubFn;
236
- toBeGreaterThanOrEqual: import("../types.js").StubFn;
237
- toBeInstanceOf: import("../types.js").StubFn;
238
- toBeLessThan: import("../types.js").StubFn;
239
- toBeLessThanOrEqual: import("../types.js").StubFn;
240
- toBeNaN: import("../types.js").StubFn;
241
- toBeNull: import("../types.js").StubFn;
242
- toBeTruthy: import("../types.js").StubFn;
243
- toBeUndefined: import("../types.js").StubFn;
244
- toContain: import("../types.js").StubFn;
245
- toContainEqual: import("../types.js").StubFn;
246
- toEqual: import("../types.js").StubFn;
247
- toHaveBeenCalled: import("../types.js").StubFn;
248
- toHaveBeenCalledTimes: import("../types.js").StubFn;
249
- toHaveBeenCalledWith: import("../types.js").StubFn;
250
- toHaveBeenLastCalledWith: import("../types.js").StubFn;
251
- toHaveBeenNthCalledWith: import("../types.js").StubFn;
252
- toHaveLastReturnedWith: import("../types.js").StubFn;
253
- toHaveLength: import("../types.js").StubFn;
254
- toHaveNthReturnedWith: import("../types.js").StubFn;
255
- toHaveProperty: import("../types.js").StubFn;
256
- toHaveReturned: import("../types.js").StubFn;
257
- toHaveReturnedTimes: import("../types.js").StubFn;
258
- toHaveReturnedWith: import("../types.js").StubFn;
259
- toMatch: import("../types.js").StubFn;
260
- toMatchObject: import("../types.js").StubFn;
261
- toReturn: import("../types.js").StubFn;
262
- toReturnTimes: import("../types.js").StubFn;
263
- toReturnWith: import("../types.js").StubFn;
264
- toStrictEqual: import("../types.js").StubFn;
265
- toThrow: import("../types.js").StubFn;
266
- toThrowError: import("../types.js").StubFn;
267
- }, "not" | "rejects" | "resolves" | "toBe" | "toBeDefined" | "toBeFalsy" | "toBeInstanceOf" | "toBeNull" | "toBeTruthy" | "toBeUndefined" | "toEqual" | "toHaveBeenCalled" | "toHaveBeenCalledTimes" | "toHaveBeenCalledWith" | "toHaveBeenLastCalledWith" | "toHaveLength" | "toMatch" | "toMatchObject" | "toThrow">) & Omit<{
268
- any: (Clazz: Function) => Matcher;
269
- anything: () => Matcher;
270
- arrayContaining: (check: string) => Matcher;
271
- objectContaining: (check: object) => Matcher;
272
- stringContaining: (check: string) => Matcher;
273
- stringMatching: (check: string | RegExp) => Matcher;
274
- }, never> & Omit<{
275
- addEqualityTesters: import("../types.js").StubFn;
276
- addSnapshotSerializer: import("../types.js").StubFn;
277
- any: import("../types.js").StubFn;
278
- anything: import("../types.js").StubFn;
279
- arrayContaining: import("../types.js").StubFn;
280
- assertions: import("../types.js").StubFn;
281
- closeTo: import("../types.js").StubFn;
282
- extend: import("../types.js").StubFn;
283
- extractExpectedAssertionsErrors: import("../types.js").StubFn;
284
- getState: import("../types.js").StubFn;
285
- hasAssertions: import("../types.js").StubFn;
286
- not: import("../types.js").StubFn;
287
- objectContaining: import("../types.js").StubFn;
288
- setState: import("../types.js").StubFn;
289
- stringContaining: import("../types.js").StubFn;
290
- stringMatching: import("../types.js").StubFn;
291
- toMatchInlineSnapshot: import("../types.js").StubFn;
292
- toMatchSnapshot: import("../types.js").StubFn;
293
- toThrowErrorMatchingInlineSnapshot: import("../types.js").StubFn;
294
- toThrowErrorMatchingSnapshot: import("../types.js").StubFn;
295
- }, "any" | "anything" | "arrayContaining" | "objectContaining" | "stringContaining" | "stringMatching">;
296
- };
297
- export {};
package/env/expect.js DELETED
@@ -1,210 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { enhanceObj, stubObj } from '../util.js';
3
- const EXPECT_KEYS = ['addEqualityTesters', 'addSnapshotSerializer', 'any', 'anything', 'arrayContaining', 'assertions', 'closeTo', 'extend', 'extractExpectedAssertionsErrors', 'getState', 'hasAssertions', 'not', 'objectContaining', 'setState', 'stringContaining', 'stringMatching', 'toMatchInlineSnapshot', 'toMatchSnapshot', 'toThrowErrorMatchingInlineSnapshot', 'toThrowErrorMatchingSnapshot'];
4
- const EXPECT_KEYS_FN = ['lastCalledWith', 'lastReturnedWith', 'not', 'nthCalledWith', 'nthReturnedWith', 'rejects', 'resolves', 'toBe', 'toBeCalled', 'toBeCalledTimes', 'toBeCalledWith', 'toBeCloseTo', 'toBeDefined', 'toBeFalsy', 'toBeGreaterThan', 'toBeGreaterThanOrEqual', 'toBeInstanceOf', 'toBeLessThan', 'toBeLessThanOrEqual', 'toBeNaN', 'toBeNull', 'toBeTruthy', 'toBeUndefined', 'toContain', 'toContainEqual', 'toEqual', 'toHaveBeenCalled', 'toHaveBeenCalledTimes', 'toHaveBeenCalledWith', 'toHaveBeenLastCalledWith', 'toHaveBeenNthCalledWith', 'toHaveLastReturnedWith', 'toHaveLength', 'toHaveNthReturnedWith', 'toHaveProperty', 'toHaveReturned', 'toHaveReturnedTimes', 'toHaveReturnedWith', 'toMatch', 'toMatchInlineSnapshot', 'toMatchObject', 'toMatchSnapshot', 'toReturn', 'toReturnTimes', 'toReturnWith', 'toStrictEqual', 'toThrow', 'toThrowError', 'toThrowErrorMatchingInlineSnapshot', 'toThrowErrorMatchingSnapshot'];
5
- const stubExpect = stubObj('expect', EXPECT_KEYS);
6
- const stubExpectFn = stubObj('expect(...)', EXPECT_KEYS_FN, {
7
- toThrowError: 'expect(...).toThrow'
8
- });
9
- const stubExpectFnRejects = stubObj('expect(...).rejects', EXPECT_KEYS_FN, {
10
- toThrowError: 'expect(...).rejects.toThrow'
11
- });
12
- const stubExpectFnResolves = stubObj('expect(...).resolves', EXPECT_KEYS_FN);
13
- const stubExpectFnNot = stubObj('expect(...).not', EXPECT_KEYS_FN, {
14
- toBeFalsy: 'expect(...).toBeTruthy',
15
- toBeTruthy: 'expect(...).toBeFalsy',
16
- toThrowError: 'expect(...).not.toThrow'
17
- });
18
- /**
19
- * @internal
20
- *
21
- * A helper that wraps a matching function in an ExpectMatcher. This is (currently)
22
- * only used/checked for in the calledWith* helpers
23
- *
24
- * TODO We don't use it in pezkuwi-js, but a useful enhancement could be for
25
- * any of the to* expectations to detect and use those. An example of useful code
26
- * in that case:
27
- *
28
- * ```js
29
- * expect({
30
- * a: 'blah',
31
- * b: 3
32
- * }).toEqual(
33
- * expect.objectContaining({ b: 3 })
34
- * )
35
- * ```
36
- *
37
- * An example of matcher use can be seen in the isCalledWith loops
38
- */
39
- class Matcher {
40
- assertMatch;
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- constructor(assertFn, check) {
43
- this.assertMatch = (value) => assertFn(value, check);
44
- }
45
- }
46
- /**
47
- * @internal
48
- *
49
- * Asserts that the input value is non-nullish
50
- */
51
- function assertNonNullish(value) {
52
- assert.ok(value !== null && value !== undefined, `Expected non-nullish value, found ${value}`);
53
- }
54
- /**
55
- * @internal
56
- *
57
- * A helper that checks a single call arguments, which may include the
58
- * use of matchers. This is used in finding any call or checking a specific
59
- * call
60
- */
61
- function assertCallHasArgs(call, args) {
62
- assert.ok(call && args.length === call.arguments?.length, 'Number of arguments does not match');
63
- args.forEach((arg, i) => assertMatch(call.arguments[i], arg));
64
- }
65
- /**
66
- * @internal
67
- *
68
- * A helper that checks for the first instance of a match on the actual call
69
- * arguments (this extracts the toHaveBeenCalledWith logic)
70
- */
71
- function assertSomeCallHasArgs(value, args) {
72
- assert.ok(value?.mock?.calls.some((call) => {
73
- try {
74
- assertCallHasArgs(call, args);
75
- return true;
76
- }
77
- catch {
78
- return false;
79
- }
80
- }), 'No call found matching arguments');
81
- }
82
- /**
83
- * @internal
84
- *
85
- * Asserts that the value is either (equal deep) or matches the matcher (if supplied)
86
- */
87
- function assertMatch(value, check) {
88
- check instanceof Matcher
89
- ? check.assertMatch(value)
90
- : Array.isArray(check)
91
- ? assertMatchArr(value, check)
92
- : check && typeof check === 'object'
93
- ? assertMatchObj(value, check)
94
- : assert.deepStrictEqual(value, check);
95
- }
96
- /**
97
- * @internal
98
- *
99
- * A helper to match the supplied array check against the resulting array
100
- *
101
- * @param {unknown} value
102
- * @param {unknown[]} check
103
- */
104
- function assertMatchArr(value, check) {
105
- assert.ok(value && Array.isArray(value), `Expected array value, found ${typeof value}`);
106
- assert.ok(value.length === check.length, `Expected array with ${check.length} entries, found ${value.length}`);
107
- check.forEach((other, i) => assertMatch(value[i], other));
108
- }
109
- /**
110
- * @internal
111
- *
112
- * A helper to match the supplied fields against the resulting object
113
- */
114
- function assertMatchObj(value, check) {
115
- assert.ok(value && typeof value === 'object', `Expected object value, found ${typeof value}`);
116
- Object
117
- .entries(check)
118
- .forEach(([key, other]) => assertMatch(value[key], other));
119
- }
120
- /**
121
- * @internal
122
- *
123
- * A helper to match a string value against another string or regex
124
- */
125
- function assertMatchStr(value, check) {
126
- assert.ok(typeof value === 'string', `Expected string value, found ${typeof value}`);
127
- typeof check === 'string'
128
- ? assert.strictEqual(value, check)
129
- : assert.match(value, check);
130
- }
131
- /**
132
- * @internal
133
- *
134
- * A helper to check the type of a specific value as used in the expect.any(Clazz) matcher
135
- *
136
- * @see https://github.com/facebook/jest/blob/a49c88610e49a3242576160740a32a2fe11161e1/packages/expect/src/asymmetricMatchers.ts#L103-L133
137
- */
138
- function assertInstanceOf(value, Clazz) {
139
- assert.ok((Clazz === Array && Array.isArray(value)) ||
140
- (Clazz === BigInt && typeof value === 'bigint') ||
141
- (Clazz === Boolean && typeof value === 'boolean') ||
142
- (Clazz === Function && typeof value === 'function') ||
143
- (Clazz === Number && typeof value === 'number') ||
144
- (Clazz === Object && typeof value === 'object') ||
145
- (Clazz === String && typeof value === 'string') ||
146
- (Clazz === Symbol && typeof value === 'symbol') ||
147
- (value instanceof Clazz), `${value} is not an instance of ${Clazz.name}`);
148
- }
149
- /**
150
- * @internal
151
- *
152
- * A helper to ensure that the supplied string/array does include the checker string.
153
- *
154
- * @param {string | unknown[]} value
155
- * @param {string} check
156
- */
157
- function assertIncludes(value, [check, Clazz]) {
158
- assertInstanceOf(value, Clazz);
159
- assert.ok(value?.includes(check), `${value} does not include ${check}`);
160
- }
161
- /**
162
- * Sets up the shimmed expect(...) function, including all .to* and .not.to*
163
- * functions. This is not comprehensive, rather is contains what we need to
164
- * make all pezkuwi-js usages pass
165
- **/
166
- export function expect() {
167
- const rootMatchers = {
168
- // eslint-disable-next-line @typescript-eslint/ban-types
169
- any: (Clazz) => new Matcher(assertInstanceOf, Clazz),
170
- anything: () => new Matcher(assertNonNullish),
171
- arrayContaining: (check) => new Matcher(assertIncludes, [check, Array]),
172
- objectContaining: (check) => new Matcher(assertMatchObj, check),
173
- stringContaining: (check) => new Matcher(assertIncludes, [check, String]),
174
- stringMatching: (check) => new Matcher(assertMatchStr, check)
175
- };
176
- return {
177
- expect: enhanceObj(enhanceObj((value) => enhanceObj({
178
- not: enhanceObj({
179
- toBe: (other) => assert.notStrictEqual(value, other),
180
- toBeDefined: () => assert.ok(value === undefined),
181
- toBeNull: (value) => assert.ok(value !== null),
182
- toBeUndefined: () => assert.ok(value !== undefined),
183
- toEqual: (other) => assert.notDeepEqual(value, other),
184
- toHaveBeenCalled: () => assert.ok(!value?.mock?.calls.length),
185
- toThrow: (message) => assert.doesNotThrow(value, message && { message })
186
- }, stubExpectFnNot),
187
- rejects: enhanceObj({
188
- toThrow: (message) => assert.rejects(value, message && { message })
189
- }, stubExpectFnRejects),
190
- resolves: enhanceObj({}, stubExpectFnResolves),
191
- toBe: (other) => assert.strictEqual(value, other),
192
- toBeDefined: () => assert.ok(value !== undefined),
193
- toBeFalsy: () => assert.ok(!value),
194
- // eslint-disable-next-line @typescript-eslint/ban-types
195
- toBeInstanceOf: (Clazz) => assertInstanceOf(value, Clazz),
196
- toBeNull: (value) => assert.ok(value === null),
197
- toBeTruthy: () => assert.ok(value),
198
- toBeUndefined: () => assert.ok(value === undefined),
199
- toEqual: (other) => assert.deepEqual(value, other),
200
- toHaveBeenCalled: () => assert.ok(value?.mock?.calls.length),
201
- toHaveBeenCalledTimes: (count) => assert.equal(value?.mock?.calls.length, count),
202
- toHaveBeenCalledWith: (...args) => assertSomeCallHasArgs(value, args),
203
- toHaveBeenLastCalledWith: (...args) => assertCallHasArgs(value?.mock?.calls.at(-1), args),
204
- toHaveLength: (length) => assert.equal(value?.length, length),
205
- toMatch: (check) => assertMatchStr(value, check),
206
- toMatchObject: (check) => assertMatchObj(value, check),
207
- toThrow: (message) => assert.throws(value, message && { message })
208
- }, stubExpectFn), rootMatchers), stubExpect)
209
- };
210
- }
package/env/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * Exposes the jest-y environment via globals.
3
- */
4
- export declare function exposeEnv(isBrowser: boolean): void;
package/env/index.js DELETED
@@ -1,17 +0,0 @@
1
- import { browser } from './browser.js';
2
- import { expect } from './expect.js';
3
- import { jest } from './jest.js';
4
- import { lifecycle } from './lifecycle.js';
5
- import { suite } from './suite.js';
6
- /**
7
- * Exposes the jest-y environment via globals.
8
- */
9
- export function exposeEnv(isBrowser) {
10
- [expect, jest, lifecycle, suite, isBrowser && browser].forEach((env) => {
11
- env && Object
12
- .entries(env())
13
- .forEach(([key, fn]) => {
14
- globalThis[key] ??= fn;
15
- });
16
- });
17
- }
package/env/jest.d.ts DELETED
@@ -1,127 +0,0 @@
1
- import type { AnyFn } from '../types.js';
2
- /**
3
- * Sets up the jest object. This is certainly not extensive, and probably
4
- * not quite meant to be (never say never). Rather this adds the functionality
5
- * that we use in the pezkuwi-js projects.
6
- **/
7
- export declare function jest(): {
8
- jest: {
9
- fn: <F extends AnyFn>(fn?: F) => F & {
10
- mock: {
11
- calls: {
12
- arguments: unknown[];
13
- }[];
14
- mockImplementation: (fn: AnyFn) => void;
15
- mockImplementationOnce: (fn: AnyFn) => void;
16
- resetCalls: () => void;
17
- restore: () => void;
18
- };
19
- } & Omit<{
20
- mockImplementation: <F_1 extends AnyFn>(fn: F_1) => void;
21
- mockImplementationOnce: <F_1 extends AnyFn>(fn: F_1) => void;
22
- mockReset: () => void;
23
- mockRestore: () => void;
24
- }, "mock" | keyof F> & Omit<{
25
- mock: import("../types.js").StubFn;
26
- _isMockFunction: import("../types.js").StubFn;
27
- getMockImplementation: import("../types.js").StubFn;
28
- getMockName: import("../types.js").StubFn;
29
- mockClear: import("../types.js").StubFn;
30
- mockImplementation: import("../types.js").StubFn;
31
- mockImplementationOnce: import("../types.js").StubFn;
32
- mockName: import("../types.js").StubFn;
33
- mockRejectedValue: import("../types.js").StubFn;
34
- mockRejectedValueOnce: import("../types.js").StubFn;
35
- mockReset: import("../types.js").StubFn;
36
- mockResolvedValue: import("../types.js").StubFn;
37
- mockResolvedValueOnce: import("../types.js").StubFn;
38
- mockRestore: import("../types.js").StubFn;
39
- mockReturnThis: import("../types.js").StubFn;
40
- mockReturnValue: import("../types.js").StubFn;
41
- mockReturnValueOnce: import("../types.js").StubFn;
42
- withImplementation: import("../types.js").StubFn;
43
- }, "mock" | keyof F | Exclude<"mockImplementation", "mock" | keyof F> | Exclude<"mockImplementationOnce", "mock" | keyof F> | Exclude<"mockReset", "mock" | keyof F> | Exclude<"mockRestore", "mock" | keyof F>>;
44
- restoreAllMocks: () => void;
45
- spyOn: <F extends AnyFn>(obj: object, key: string) => F & {
46
- mock: {
47
- calls: {
48
- arguments: unknown[];
49
- }[];
50
- mockImplementation: (fn: AnyFn) => void;
51
- mockImplementationOnce: (fn: AnyFn) => void;
52
- resetCalls: () => void;
53
- restore: () => void;
54
- };
55
- } & Omit<{
56
- mockImplementation: <F_1 extends AnyFn>(fn: F_1) => void;
57
- mockImplementationOnce: <F_1 extends AnyFn>(fn: F_1) => void;
58
- mockReset: () => void;
59
- mockRestore: () => void;
60
- }, "mock" | keyof F> & Omit<{
61
- mock: import("../types.js").StubFn;
62
- _isMockFunction: import("../types.js").StubFn;
63
- getMockImplementation: import("../types.js").StubFn;
64
- getMockName: import("../types.js").StubFn;
65
- mockClear: import("../types.js").StubFn;
66
- mockImplementation: import("../types.js").StubFn;
67
- mockImplementationOnce: import("../types.js").StubFn;
68
- mockName: import("../types.js").StubFn;
69
- mockRejectedValue: import("../types.js").StubFn;
70
- mockRejectedValueOnce: import("../types.js").StubFn;
71
- mockReset: import("../types.js").StubFn;
72
- mockResolvedValue: import("../types.js").StubFn;
73
- mockResolvedValueOnce: import("../types.js").StubFn;
74
- mockRestore: import("../types.js").StubFn;
75
- mockReturnThis: import("../types.js").StubFn;
76
- mockReturnValue: import("../types.js").StubFn;
77
- mockReturnValueOnce: import("../types.js").StubFn;
78
- withImplementation: import("../types.js").StubFn;
79
- }, "mock" | keyof F | Exclude<"mockImplementation", "mock" | keyof F> | Exclude<"mockImplementationOnce", "mock" | keyof F> | Exclude<"mockReset", "mock" | keyof F> | Exclude<"mockRestore", "mock" | keyof F>>;
80
- } & Omit<{
81
- setTimeout: import("../types.js").StubFn;
82
- }, "fn" | "restoreAllMocks" | "spyOn"> & Omit<{
83
- setTimeout: import("../types.js").StubFn;
84
- mock: import("../types.js").StubFn;
85
- advanceTimersByTime: import("../types.js").StubFn;
86
- advanceTimersToNextTimer: import("../types.js").StubFn;
87
- autoMockOff: import("../types.js").StubFn;
88
- autoMockOn: import("../types.js").StubFn;
89
- clearAllMocks: import("../types.js").StubFn;
90
- clearAllTimers: import("../types.js").StubFn;
91
- createMockFromModule: import("../types.js").StubFn;
92
- deepUnmock: import("../types.js").StubFn;
93
- disableAutomock: import("../types.js").StubFn;
94
- doMock: import("../types.js").StubFn;
95
- dontMock: import("../types.js").StubFn;
96
- enableAutomock: import("../types.js").StubFn;
97
- fn: import("../types.js").StubFn;
98
- genMockFromModule: import("../types.js").StubFn;
99
- getRealSystemTime: import("../types.js").StubFn;
100
- getSeed: import("../types.js").StubFn;
101
- getTimerCount: import("../types.js").StubFn;
102
- isEnvironmentTornDown: import("../types.js").StubFn;
103
- isMockFunction: import("../types.js").StubFn;
104
- isolateModules: import("../types.js").StubFn;
105
- isolateModulesAsync: import("../types.js").StubFn;
106
- mocked: import("../types.js").StubFn;
107
- now: import("../types.js").StubFn;
108
- replaceProperty: import("../types.js").StubFn;
109
- requireActual: import("../types.js").StubFn;
110
- requireMock: import("../types.js").StubFn;
111
- resetAllMocks: import("../types.js").StubFn;
112
- resetModules: import("../types.js").StubFn;
113
- restoreAllMocks: import("../types.js").StubFn;
114
- retryTimes: import("../types.js").StubFn;
115
- runAllImmediates: import("../types.js").StubFn;
116
- runAllTicks: import("../types.js").StubFn;
117
- runAllTimers: import("../types.js").StubFn;
118
- runOnlyPendingTimers: import("../types.js").StubFn;
119
- setMock: import("../types.js").StubFn;
120
- setSystemTime: import("../types.js").StubFn;
121
- spyOn: import("../types.js").StubFn;
122
- unmock: import("../types.js").StubFn;
123
- unstable_mockModule: import("../types.js").StubFn;
124
- useFakeTimers: import("../types.js").StubFn;
125
- useRealTimers: import("../types.js").StubFn;
126
- }, "setTimeout" | "fn" | "restoreAllMocks" | "spyOn">;
127
- };