exisjs 0.1.2 → 0.1.4

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 (79) hide show
  1. package/README.md +8 -2
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +1 -0
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/dev.d.ts.map +1 -1
  6. package/dist/cli/commands/dev.js +9 -13
  7. package/dist/cli/commands/dev.js.map +1 -1
  8. package/dist/cli/commands/start.d.ts.map +1 -1
  9. package/dist/cli/commands/start.js +1 -6
  10. package/dist/cli/commands/start.js.map +1 -1
  11. package/dist/cli/commands/test.d.ts +1 -0
  12. package/dist/cli/commands/test.d.ts.map +1 -1
  13. package/dist/cli/commands/test.js +7 -12
  14. package/dist/cli/commands/test.js.map +1 -1
  15. package/dist/cli/index.js +1 -0
  16. package/dist/cli/index.js.map +1 -1
  17. package/dist/decorators/index.d.ts +59 -0
  18. package/dist/decorators/index.d.ts.map +1 -1
  19. package/dist/decorators/index.js +80 -11
  20. package/dist/decorators/index.js.map +1 -1
  21. package/dist/di/inject.d.ts +17 -0
  22. package/dist/di/inject.d.ts.map +1 -1
  23. package/dist/di/inject.js +17 -0
  24. package/dist/di/inject.js.map +1 -1
  25. package/dist/integrations/mongoose.d.ts.map +1 -1
  26. package/dist/integrations/mongoose.js +3 -2
  27. package/dist/integrations/mongoose.js.map +1 -1
  28. package/dist/module/module.d.ts +16 -0
  29. package/dist/module/module.d.ts.map +1 -1
  30. package/dist/module/module.js +16 -0
  31. package/dist/module/module.js.map +1 -1
  32. package/dist/router/router.d.ts.map +1 -1
  33. package/dist/router/router.js +44 -22
  34. package/dist/router/router.js.map +1 -1
  35. package/dist/server/app.d.ts.map +1 -1
  36. package/dist/server/app.js +156 -95
  37. package/dist/server/app.js.map +1 -1
  38. package/dist/server/cluster.d.ts.map +1 -1
  39. package/dist/server/cluster.js +4 -9
  40. package/dist/server/cluster.js.map +1 -1
  41. package/dist/server/define.d.ts +14 -0
  42. package/dist/server/define.d.ts.map +1 -1
  43. package/dist/server/define.js +14 -0
  44. package/dist/server/define.js.map +1 -1
  45. package/dist/server/request.d.ts +136 -0
  46. package/dist/server/request.d.ts.map +1 -1
  47. package/dist/server/request.js +136 -0
  48. package/dist/server/request.js.map +1 -1
  49. package/dist/server/response.d.ts +186 -0
  50. package/dist/server/response.d.ts.map +1 -1
  51. package/dist/server/response.js +188 -1
  52. package/dist/server/response.js.map +1 -1
  53. package/dist/server/route.d.ts +28 -2
  54. package/dist/server/route.d.ts.map +1 -1
  55. package/dist/server/route.js +28 -2
  56. package/dist/server/route.js.map +1 -1
  57. package/dist/server/uws-adapter.d.ts +4 -1
  58. package/dist/server/uws-adapter.d.ts.map +1 -1
  59. package/dist/server/uws-adapter.js +55 -6
  60. package/dist/server/uws-adapter.js.map +1 -1
  61. package/dist/testing/expect.d.ts +56 -0
  62. package/dist/testing/expect.d.ts.map +1 -0
  63. package/dist/testing/expect.js +435 -0
  64. package/dist/testing/expect.js.map +1 -0
  65. package/dist/testing/index.d.ts +52 -2
  66. package/dist/testing/index.d.ts.map +1 -1
  67. package/dist/testing/index.js +147 -18
  68. package/dist/testing/index.js.map +1 -1
  69. package/dist/testing/reporter.d.ts +5 -10
  70. package/dist/testing/reporter.d.ts.map +1 -1
  71. package/dist/testing/reporter.js +144 -59
  72. package/dist/testing/reporter.js.map +1 -1
  73. package/dist/websocket/server.d.ts.map +1 -1
  74. package/dist/websocket/server.js +5 -3
  75. package/dist/websocket/server.js.map +1 -1
  76. package/dist/websocket/socket.d.ts.map +1 -1
  77. package/dist/websocket/socket.js +8 -6
  78. package/dist/websocket/socket.js.map +1 -1
  79. package/package.json +2 -2
@@ -0,0 +1,56 @@
1
+ export declare class Expectation {
2
+ private readonly actual;
3
+ private readonly isNot;
4
+ constructor(actual: any, isNot?: boolean);
5
+ get not(): Expectation;
6
+ toBe(expected: any): void;
7
+ toEqual(expected: any): void;
8
+ toStrictEqual(expected: any): void;
9
+ toMatchObject(expected: any): void;
10
+ toBeTruthy(): void;
11
+ toBeFalsy(): void;
12
+ toBeNull(): void;
13
+ toBeUndefined(): void;
14
+ toBeDefined(): void;
15
+ toBeGreaterThan(expected: number): void;
16
+ toBeGreaterThanOrEqual(expected: number): void;
17
+ toBeLessThan(expected: number): void;
18
+ toBeCloseTo(expected: number, precision?: number): void;
19
+ toBeLessThanOrEqual(expected: number): void;
20
+ toBeInstanceOf(constructor: any): void;
21
+ toContain(item: any): void;
22
+ toHaveLength(length: number): void;
23
+ toHaveProperty(key: string | string[], value?: any): void;
24
+ toThrow(expected?: any): void;
25
+ toMatch(expected: RegExp | string): void;
26
+ toHaveBeenCalled(): void;
27
+ toHaveBeenCalledTimes(expected: number): void;
28
+ toHaveBeenCalledWith(...expectedArgs: any[]): void;
29
+ toMatchSnapshot(): void;
30
+ toMatchInlineSnapshot(): void;
31
+ get resolves(): {
32
+ toBe: (expected: any) => Promise<void>;
33
+ toEqual: (expected: any) => Promise<void>;
34
+ toStrictEqual: (expected: any) => Promise<void>;
35
+ toBeUndefined: () => Promise<void>;
36
+ readonly not: /*elided*/ any;
37
+ };
38
+ get rejects(): {
39
+ toThrow: (expected?: any) => Promise<void>;
40
+ readonly not: /*elided*/ any;
41
+ };
42
+ }
43
+ export declare function expect(actual: any): Expectation;
44
+ export declare namespace expect {
45
+ var stringContaining: (expected: string) => {
46
+ __isStringContaining: boolean;
47
+ expected: string;
48
+ };
49
+ var any: (constructor: any) => {
50
+ __isAny: boolean;
51
+ constructor: any;
52
+ };
53
+ var objectContaining: (expected: any) => any;
54
+ var fail: (message?: string) => never;
55
+ }
56
+ //# sourceMappingURL=expect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/testing/expect.ts"],"names":[],"mappings":"AAGA,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QA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AI,IAAI;IAUvB,qBAAqB,IAAI,IAAI;IAY7B,IAAI,QAAQ;yBAKe,GAAG;4BAIA,GAAG;kCAIG,GAAG;;;MAatC;IAED,IAAI,OAAO;6BAKoB,GAAG;;MAuDjC;CACF;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,WAAW,CAE/C;yBAFe,MAAM;qCAKe,MAAM;;;;2BAMhB,GAAG;;;;qCAMO,GAAG;yBAMf,MAAM"}
@@ -0,0 +1,435 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Expectation = void 0;
7
+ exports.expect = expect;
8
+ const node_assert_1 = __importDefault(require("node:assert"));
9
+ const node_test_1 = require("node:test");
10
+ class Expectation {
11
+ constructor(actual, isNot = false) {
12
+ this.actual = actual;
13
+ this.isNot = isNot;
14
+ }
15
+ get not() {
16
+ return new Expectation(this.actual, !this.isNot);
17
+ }
18
+ // --- Equality ---
19
+ toBe(expected) {
20
+ if (this.isNot) {
21
+ node_assert_1.default.notStrictEqual(this.actual, expected);
22
+ }
23
+ else {
24
+ node_assert_1.default.strictEqual(this.actual, expected);
25
+ }
26
+ }
27
+ toEqual(expected) {
28
+ if (this.isNot) {
29
+ node_assert_1.default.notDeepEqual(this.actual, expected);
30
+ }
31
+ else {
32
+ node_assert_1.default.deepEqual(this.actual, expected);
33
+ }
34
+ }
35
+ toStrictEqual(expected) {
36
+ if (this.isNot) {
37
+ node_assert_1.default.notDeepStrictEqual(this.actual, expected);
38
+ }
39
+ else {
40
+ node_assert_1.default.deepStrictEqual(this.actual, expected);
41
+ }
42
+ }
43
+ toMatchObject(expected) {
44
+ const isObject = (o) => o != null && typeof o === 'object';
45
+ const contains = (actual, expected) => {
46
+ if (!isObject(actual) || !isObject(expected)) {
47
+ if (expected && expected.__isAny) {
48
+ return (Object(actual) instanceof expected.constructor ||
49
+ typeof actual === typeof expected.constructor());
50
+ }
51
+ if (expected && expected.__isStringContaining) {
52
+ return (typeof actual === 'string' && actual.includes(expected.expected));
53
+ }
54
+ return actual === expected;
55
+ }
56
+ return Object.keys(expected).every((k) => contains(actual[k], expected[k]));
57
+ };
58
+ if (this.isNot) {
59
+ node_assert_1.default.ok(!contains(this.actual, expected), `Expected ${this.actual} not to match object ${expected}`);
60
+ }
61
+ else {
62
+ node_assert_1.default.ok(contains(this.actual, expected), `Expected ${this.actual} to match object ${expected}`);
63
+ }
64
+ }
65
+ // --- Truthiness ---
66
+ toBeTruthy() {
67
+ if (this.isNot) {
68
+ node_assert_1.default.ok(!this.actual);
69
+ }
70
+ else {
71
+ node_assert_1.default.ok(this.actual);
72
+ }
73
+ }
74
+ toBeFalsy() {
75
+ if (this.isNot) {
76
+ node_assert_1.default.ok(this.actual);
77
+ }
78
+ else {
79
+ node_assert_1.default.ok(!this.actual);
80
+ }
81
+ }
82
+ toBeNull() {
83
+ this.toBe(null);
84
+ }
85
+ toBeUndefined() {
86
+ this.toBe(undefined);
87
+ }
88
+ toBeDefined() {
89
+ if (this.isNot) {
90
+ node_assert_1.default.strictEqual(this.actual, undefined);
91
+ }
92
+ else {
93
+ node_assert_1.default.notStrictEqual(this.actual, undefined);
94
+ }
95
+ }
96
+ // --- Numbers ---
97
+ toBeGreaterThan(expected) {
98
+ if (this.isNot) {
99
+ node_assert_1.default.ok(this.actual <= expected, `Expected ${this.actual} not to be greater than ${expected}`);
100
+ }
101
+ else {
102
+ node_assert_1.default.ok(this.actual > expected, `Expected ${this.actual} to be greater than ${expected}`);
103
+ }
104
+ }
105
+ toBeGreaterThanOrEqual(expected) {
106
+ if (this.isNot) {
107
+ node_assert_1.default.ok(this.actual < expected, `Expected ${this.actual} not to be greater than or equal to ${expected}`);
108
+ }
109
+ else {
110
+ node_assert_1.default.ok(this.actual >= expected, `Expected ${this.actual} to be greater than or equal to ${expected}`);
111
+ }
112
+ }
113
+ toBeLessThan(expected) {
114
+ if (this.isNot) {
115
+ node_assert_1.default.ok(this.actual >= expected, `Expected ${this.actual} not to be less than ${expected}`);
116
+ }
117
+ else {
118
+ node_assert_1.default.ok(this.actual < expected, `Expected ${this.actual} to be less than ${expected}`);
119
+ }
120
+ }
121
+ toBeCloseTo(expected, precision = 2) {
122
+ const pass = Math.abs(expected - this.actual) < Math.pow(10, -precision) / 2;
123
+ if (this.isNot) {
124
+ node_assert_1.default.ok(!pass, `Expected ${this.actual} not to be close to ${expected}`);
125
+ }
126
+ else {
127
+ node_assert_1.default.ok(pass, `Expected ${this.actual} to be close to ${expected}`);
128
+ }
129
+ }
130
+ toBeLessThanOrEqual(expected) {
131
+ if (this.isNot) {
132
+ node_assert_1.default.ok(this.actual > expected, `Expected ${this.actual} not to be less than or equal to ${expected}`);
133
+ }
134
+ else {
135
+ node_assert_1.default.ok(this.actual <= expected, `Expected ${this.actual} to be less than or equal to ${expected}`);
136
+ }
137
+ }
138
+ // --- Types & Instances ---
139
+ toBeInstanceOf(constructor) {
140
+ const isInstance = this.actual instanceof constructor;
141
+ if (this.isNot) {
142
+ node_assert_1.default.strictEqual(isInstance, false, `Expected value not to be instance of ${constructor.name}`);
143
+ }
144
+ else {
145
+ node_assert_1.default.strictEqual(isInstance, true, `Expected value to be instance of ${constructor.name}`);
146
+ }
147
+ }
148
+ // --- Arrays / Strings ---
149
+ toContain(item) {
150
+ const contains = Array.isArray(this.actual) || typeof this.actual === 'string'
151
+ ? this.actual.includes(item)
152
+ : false;
153
+ if (this.isNot) {
154
+ node_assert_1.default.strictEqual(contains, false, `Expected ${this.actual} not to contain ${item}`);
155
+ }
156
+ else {
157
+ node_assert_1.default.strictEqual(contains, true, `Expected ${this.actual} to contain ${item}`);
158
+ }
159
+ }
160
+ toHaveLength(length) {
161
+ if (this.isNot) {
162
+ node_assert_1.default.notStrictEqual(this.actual?.length, length);
163
+ }
164
+ else {
165
+ node_assert_1.default.strictEqual(this.actual?.length, length);
166
+ }
167
+ }
168
+ // --- Objects ---
169
+ toHaveProperty(key, value) {
170
+ const keys = Array.isArray(key) ? key : key.split('.');
171
+ let current = this.actual;
172
+ let hasProp = true;
173
+ for (const k of keys) {
174
+ if (current === undefined || current === null || !(k in current)) {
175
+ hasProp = false;
176
+ break;
177
+ }
178
+ current = current[k];
179
+ }
180
+ if (this.isNot) {
181
+ if (value !== undefined) {
182
+ if (hasProp) {
183
+ try {
184
+ node_assert_1.default.notDeepStrictEqual(current, value);
185
+ }
186
+ catch {
187
+ node_assert_1.default.fail(`Expected property ${key} not to equal ${value}`);
188
+ }
189
+ }
190
+ }
191
+ else {
192
+ node_assert_1.default.strictEqual(hasProp, false, `Expected object not to have property ${key}`);
193
+ }
194
+ }
195
+ else {
196
+ node_assert_1.default.strictEqual(hasProp, true, `Expected object to have property ${key}`);
197
+ if (value !== undefined) {
198
+ node_assert_1.default.deepStrictEqual(current, value);
199
+ }
200
+ }
201
+ }
202
+ // --- Functions ---
203
+ toThrow(expected) {
204
+ if (typeof this.actual !== 'function') {
205
+ node_assert_1.default.fail('Expected value must be a function to use toThrow');
206
+ }
207
+ let threw = false;
208
+ let error;
209
+ try {
210
+ this.actual();
211
+ }
212
+ catch (e) {
213
+ threw = true;
214
+ error = e;
215
+ }
216
+ if (this.isNot) {
217
+ if (threw) {
218
+ if (expected) {
219
+ if (error instanceof Error &&
220
+ (error.message.includes(expected) ||
221
+ (expected instanceof RegExp && expected.test(error.message)))) {
222
+ node_assert_1.default.fail(`Expected function not to throw error matching ${expected}`);
223
+ }
224
+ }
225
+ else {
226
+ node_assert_1.default.fail(`Expected function not to throw, but it threw: ${error}`);
227
+ }
228
+ }
229
+ }
230
+ else {
231
+ if (!threw) {
232
+ node_assert_1.default.fail('Expected function to throw');
233
+ }
234
+ if (expected) {
235
+ if (typeof expected === 'string') {
236
+ node_assert_1.default.ok(error?.message?.includes(expected), `Expected error message to include ${expected}`);
237
+ }
238
+ else if (expected instanceof RegExp) {
239
+ node_assert_1.default.ok(expected.test(error?.message), `Expected error message to match ${expected}`);
240
+ }
241
+ else if (typeof expected === 'function') {
242
+ node_assert_1.default.ok(error instanceof expected, `Expected error to be instance of ${expected.name}`);
243
+ }
244
+ }
245
+ }
246
+ }
247
+ toMatch(expected) {
248
+ if (this.isNot) {
249
+ if (expected instanceof RegExp) {
250
+ node_assert_1.default.ok(!expected.test(this.actual), `Expected ${this.actual} not to match ${expected}`);
251
+ }
252
+ else {
253
+ node_assert_1.default.ok(!String(this.actual).match(expected), `Expected ${this.actual} not to match ${expected}`);
254
+ }
255
+ }
256
+ else {
257
+ if (expected instanceof RegExp) {
258
+ node_assert_1.default.ok(expected.test(this.actual), `Expected ${this.actual} to match ${expected}`);
259
+ }
260
+ else {
261
+ node_assert_1.default.ok(String(this.actual).match(expected), `Expected ${this.actual} to match ${expected}`);
262
+ }
263
+ }
264
+ }
265
+ // --- Mocks ---
266
+ toHaveBeenCalled() {
267
+ const callCount = this.actual.mock?.callCount() || 0;
268
+ if (this.isNot) {
269
+ node_assert_1.default.strictEqual(callCount, 0, `Expected mock not to have been called`);
270
+ }
271
+ else {
272
+ node_assert_1.default.ok(callCount > 0, `Expected mock to have been called`);
273
+ }
274
+ }
275
+ toHaveBeenCalledTimes(expected) {
276
+ const callCount = this.actual.mock?.callCount() || 0;
277
+ if (this.isNot) {
278
+ node_assert_1.default.notStrictEqual(callCount, expected, `Expected mock not to have been called ${expected} times`);
279
+ }
280
+ else {
281
+ node_assert_1.default.strictEqual(callCount, expected, `Expected mock to have been called ${expected} times`);
282
+ }
283
+ }
284
+ toHaveBeenCalledWith(...expectedArgs) {
285
+ const calls = this.actual.mock?.calls || [];
286
+ const isObject = (o) => o != null && typeof o === 'object';
287
+ const contains = (actual, expected) => {
288
+ if (!isObject(actual) || !isObject(expected)) {
289
+ if (expected && expected.__isAny) {
290
+ return (Object(actual) instanceof expected.constructor ||
291
+ typeof actual === typeof expected.constructor());
292
+ }
293
+ if (expected && expected.__isStringContaining) {
294
+ return (typeof actual === 'string' && actual.includes(expected.expected));
295
+ }
296
+ return actual === expected;
297
+ }
298
+ return Object.keys(expected).every((k) => contains(actual[k], expected[k]));
299
+ };
300
+ const hasCall = calls.some((call) => {
301
+ const actualArgs = call.arguments;
302
+ if (actualArgs.length !== expectedArgs.length)
303
+ return false;
304
+ return expectedArgs.every((expectedArg, i) => contains(actualArgs[i], expectedArg));
305
+ });
306
+ if (this.isNot) {
307
+ node_assert_1.default.ok(!hasCall, `Expected mock not to have been called with ${JSON.stringify(expectedArgs)}`);
308
+ }
309
+ else {
310
+ node_assert_1.default.ok(hasCall, `Expected mock to have been called with ${JSON.stringify(expectedArgs)}`);
311
+ }
312
+ }
313
+ // --- Snapshots ---
314
+ toMatchSnapshot() {
315
+ const t = (0, node_test_1.getTestContext)();
316
+ if (!t) {
317
+ node_assert_1.default.fail('expect().toMatchSnapshot() can only be called inside a test() block.');
318
+ }
319
+ t.assert.snapshot(this.actual);
320
+ }
321
+ toMatchInlineSnapshot() {
322
+ const t = (0, node_test_1.getTestContext)();
323
+ if (!t) {
324
+ node_assert_1.default.fail('expect().toMatchInlineSnapshot() can only be called inside a test() block.');
325
+ }
326
+ t.assert.snapshot(this.actual);
327
+ }
328
+ // --- Promises ---
329
+ get resolves() {
330
+ if (!(this.actual instanceof Promise)) {
331
+ node_assert_1.default.fail('resolves must be used with a Promise');
332
+ }
333
+ const createResolves = (isNot) => ({
334
+ toBe: async (expected) => {
335
+ const val = await this.actual;
336
+ new Expectation(val, isNot).toBe(expected);
337
+ },
338
+ toEqual: async (expected) => {
339
+ const val = await this.actual;
340
+ new Expectation(val, isNot).toEqual(expected);
341
+ },
342
+ toStrictEqual: async (expected) => {
343
+ const val = await this.actual;
344
+ new Expectation(val, isNot).toStrictEqual(expected);
345
+ },
346
+ toBeUndefined: async () => {
347
+ const val = await this.actual;
348
+ new Expectation(val, isNot).toBeUndefined();
349
+ },
350
+ get not() {
351
+ return createResolves(!isNot);
352
+ },
353
+ });
354
+ return createResolves(this.isNot);
355
+ }
356
+ get rejects() {
357
+ if (!(this.actual instanceof Promise)) {
358
+ node_assert_1.default.fail('rejects must be used with a Promise');
359
+ }
360
+ const createRejects = (isNot) => ({
361
+ toThrow: async (expected) => {
362
+ let threw = false;
363
+ let error;
364
+ try {
365
+ await this.actual;
366
+ }
367
+ catch (e) {
368
+ threw = true;
369
+ error = e;
370
+ }
371
+ if (isNot) {
372
+ if (threw) {
373
+ if (expected) {
374
+ if (error instanceof Error &&
375
+ (error.message.includes(expected) ||
376
+ (expected instanceof RegExp && expected.test(error.message)))) {
377
+ node_assert_1.default.fail(`Expected promise not to throw error matching ${expected}`);
378
+ }
379
+ }
380
+ else {
381
+ node_assert_1.default.fail('Expected promise not to throw');
382
+ }
383
+ }
384
+ }
385
+ else {
386
+ if (!threw) {
387
+ node_assert_1.default.fail('Expected promise to throw');
388
+ }
389
+ if (expected) {
390
+ if (typeof expected === 'string') {
391
+ node_assert_1.default.ok(error?.message?.includes(expected), `Expected error message to include ${expected}`);
392
+ }
393
+ else if (expected instanceof RegExp) {
394
+ node_assert_1.default.ok(expected.test(error?.message), `Expected error message to match ${expected}`);
395
+ }
396
+ else if (typeof expected === 'function') {
397
+ node_assert_1.default.ok(error instanceof expected, `Expected error to be instance of ${expected.name}`);
398
+ }
399
+ }
400
+ }
401
+ },
402
+ get not() {
403
+ return createRejects(!isNot);
404
+ },
405
+ });
406
+ return createRejects(this.isNot);
407
+ }
408
+ }
409
+ exports.Expectation = Expectation;
410
+ function expect(actual) {
411
+ return new Expectation(actual);
412
+ }
413
+ // Attach matchers
414
+ expect.stringContaining = (expected) => {
415
+ return {
416
+ __isStringContaining: true,
417
+ expected,
418
+ };
419
+ };
420
+ expect.any = (constructor) => {
421
+ return {
422
+ __isAny: true,
423
+ constructor,
424
+ };
425
+ };
426
+ expect.objectContaining = (expected) => {
427
+ return {
428
+ ...expected,
429
+ __isObjectContaining: true,
430
+ };
431
+ };
432
+ expect.fail = (message) => {
433
+ node_assert_1.default.fail(message);
434
+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QAAQ,EACzB,oCAAoC,QAAQ,CAAC,IAAI,EAAE,CACpD,CAAA;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,GAAG;gBACL,OAAO,aAAa,CAAC,CAAC,KAAK,CAAC,CAAA;YAC9B,CAAC;SACF,CAAC,CAAA;QACF,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;CACF;AAvhBD,kCAuhBC;AAED,SAAgB,MAAM,CAAC,MAAW;IAChC,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC;AAED,kBAAkB;AAClB,MAAM,CAAC,gBAAgB,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC7C,OAAO;QACL,oBAAoB,EAAE,IAAI;QAC1B,QAAQ;KACT,CAAA;AACH,CAAC,CAAA;AACD,MAAM,CAAC,GAAG,GAAG,CAAC,WAAgB,EAAE,EAAE;IAChC,OAAO;QACL,OAAO,EAAE,IAAI;QACb,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AACD,MAAM,CAAC,gBAAgB,GAAG,CAAC,QAAa,EAAE,EAAE;IAC1C,OAAO;QACL,GAAG,QAAQ;QACX,oBAAoB,EAAE,IAAI;KAC3B,CAAA;AACH,CAAC,CAAA;AACD,MAAM,CAAC,IAAI,GAAG,CAAC,OAAgB,EAAE,EAAE;IACjC,qBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACtB,CAAC,CAAA"}
@@ -1,7 +1,57 @@
1
1
  export * from './mocks';
2
2
  export * from './client';
3
+ import * as _nodeTest from 'node:test';
3
4
  import { TestApp } from './client';
4
- export { test, describe, it, before, after, beforeEach, afterEach, mock, } from 'node:test';
5
- export { default as assert } from 'node:assert';
5
+ export interface TestOptions {
6
+ only?: boolean;
7
+ skip?: boolean | string;
8
+ todo?: boolean | string;
9
+ concurrency?: number | boolean;
10
+ timeout?: number;
11
+ }
12
+ export interface TestContext {
13
+ name: string;
14
+ skip(message?: string): void;
15
+ todo(message?: string): void;
16
+ test(name: string, fn?: TestFunction): void;
17
+ test(name: string, options: TestOptions, fn?: TestFunction): void;
18
+ }
19
+ export type TestFunction = (t: TestContext) => void | Promise<void>;
20
+ export type HookFunction = () => void | Promise<void>;
21
+ export interface TestApi {
22
+ (name: string, fn?: TestFunction): void;
23
+ (name: string, options: TestOptions, fn?: TestFunction): void;
24
+ only(name: string, fn?: TestFunction): void;
25
+ only(name: string, options: TestOptions, fn?: TestFunction): void;
26
+ skip(name: string, fn?: TestFunction): void;
27
+ skip(name: string, options: TestOptions, fn?: TestFunction): void;
28
+ todo(name: string, fn?: TestFunction): void;
29
+ todo(name: string, options: TestOptions, fn?: TestFunction): void;
30
+ each<T = any>(cases: T[]): (name: string, fn: (...args: any[]) => void | Promise<void>) => void;
31
+ }
32
+ export type HookApi = (fn: HookFunction) => void;
33
+ export declare const test: TestApi;
34
+ export declare const describe: TestApi;
35
+ export declare const it: TestApi;
36
+ export declare const before: HookApi;
37
+ export declare const beforeAll: HookApi;
38
+ export declare const after: HookApi;
39
+ export declare const afterAll: HookApi;
40
+ export declare const beforeEach: HookApi;
41
+ export declare const afterEach: HookApi;
42
+ export declare const mock: _nodeTest.MockTracker;
43
+ export declare const ex: {
44
+ fn: (impl?: any) => any;
45
+ spyOn: (obj: any, methodName: string) => any;
46
+ timers: _nodeTest.MockTimers;
47
+ mock: (specifier: string, factory?: () => any) => void;
48
+ setSystemTime: (time: number | Date) => void;
49
+ advanceTimersByTime: (ms: number) => void;
50
+ useFakeTimers: () => void;
51
+ useRealTimers: () => void;
52
+ clearAllMocks: () => void;
53
+ };
54
+ export declare const assert: typeof _nodeTest.assert;
55
+ export { expect } from './expect';
6
56
  export declare function createTestContext(app: any): TestApp;
7
57
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB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