-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
index.d.ts
697 lines (610 loc) · 19.5 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
import { TransformOptions as BabelCompilerOptions } from "@babel/core";
import { Options as CSCompilerOptions } from "coffeescript";
import { Application, Express } from "express";
import { CompilerOptions as TSCompilerOptions } from "typescript";
/**
* Typings for a Wallaby config file.
*
* @see {@link https://wallabyjs.com/docs}
*/
declare module "wallabyjs" {
/**
* Wallaby configuration settings.
*
* Specify the type arg `T` if you need to configure your test framework
* within {@link IWallabyConfig.bootstrap}.
*
* @template T - Test framework instance
* @see {@link https://wallabyjs.com/docs/config/overview.html} for details.
*/
export interface IWallabyConfig<T = any> {
/**
* File patterns as keys and compiler functions as values.
*/
compilers?: IWallabyCompilers | undefined;
/**
* If `true`, Wallaby will write debug messages to its console.
*/
debug?: boolean | undefined;
/**
* Specify a different test runner or change the runner settings.
*/
env?: IWallabyEnvironment | undefined;
/**
* Specifies an array of source files or file name patterns to copy to
* the local cache.
*
* @see {@link https://wallabyjs.com/docs/config/files.html} for details
*/
files: Array<string | IWallabyFilePattern>;
/**
* Function that runs for every batch of file changes after all
* compilers and preprocessors.
*
* @see {@link https://wallabyjs.com/docs/config/postprocessor.html} for
* details
*/
postprocessor?: IWallabyProcessors | undefined;
/**
* Function that runs for every batch of file changes after all compilers.
*
* @see {@link https://wallabyjs.com/docs/config/preprocessors.html} for details
*/
preprocessors?: IWallabyProcessors | undefined;
/**
* Specifies the name and version of the testing framework you are using
* for your tests.
*/
testFramework?: string | undefined;
/**
* Specifies an array of test files or test file name patterns to copy
* to the local cache.
*
* @see {@link https://wallabyjs.com/docs/config/files.html} for details
*/
tests: Array<string | IWallabyFilePattern>;
/**
* Degree of parallelism used to run your tests and controls the way
* Wallaby re-uses workers.
*
* @see {@link https://wallabyjs.com/docs/config/workers.html} for
* details
*/
workers?: IWallabyWorkers | undefined;
/**
* Bootstrap function
*
* Alias of {@link bootstrap}
*
* @see {@link https://wallabyjs.com/docs/config/bootstrap.html} for details
*/
setup?: IWallabySetup<T>;
/**
* Bootstrap function
*
* Alias of {@link setup}
*
* @see {@link https://wallabyjs.com/docs/config/bootstrap.html} for details
*/
bootstrap?: IWallabySetup<T>;
/**
* Teardown function
*
* Node.js only
*
* @see {@link https://wallabyjs.com/docs/config/bootstrap.html} for details
*/
teardown?: IWallabyTeardown<T>;
/**
* How long to wait (in milliseconds) for the {@link teardown} function to complete.
*
* Node.js only
*
* @see {@link https://wallabyjs.com/docs/config/bootstrap.html} for details
*/
globalSetupTeardownTimeout?: number;
/**
* Inject custom middleware into the Wallaby web server.
*
* @see {@link https://wallabyjs.com/docs/config/middleware.html} for details
*/
middleware?: ((app: Application, express: Express) => void) | undefined;
/**
* Files matching this path or glob pattern will be excluded from code
* coverage calculation.
*
* @see {@link https://wallabyjs.com/docs/config/coverage.html} for
* details
*/
filesWithNoCoverageCalculated?: string[] | undefined;
/**
* Override how Wallaby interprets inline comments.
*
* @see {@link https://wallabyjs.com/docs/config/coverage.html} for details
*/
hints?: IWallabyHints | undefined;
/**
* Configure Wallaby's "Smart Start" mode.
*
* - `open`: Start running tests when the file is opened
* - `edit`: Start running tests after the file has been edited
* - `always`: Start running tests immediately on start
* - `never`: Never automatically run tests
*
* @defaultValue `'open'`
* @see {@link https://wallabyjs.com/docs/config/smart-start.html} for details
*/
startMode?: "open" | "edit" | "always" | "never" | undefined;
/**
* Glob pattern that determines which test files {@link startMode} applies to.
*
* @see {@link https://wallabyjs.com/docs/config/smart-start.html} for details
*/
pattern?: string | undefined;
/**
* Controls autodetection of files and tests
*
* If an array, the order in which frameworks are tried
*/
autoDetect?: boolean | ReadonlyArray<"angular" | "jest" | "vitest"> | undefined;
/**
* How much time Wallaby should wait before running tests
*/
delays?: IWallabyDelays | undefined;
/**
* Alias for {@link debug}
*/
trace?: boolean | undefined;
/**
* If `true`, preserve comments in instrumented code
*/
preserveComments?: boolean | undefined;
/**
* If `true`, usage of {@link console.error} will report a test as failed
*/
reportConsoleErrorAsError?: boolean | undefined;
/**
* Maximum count console messages each test can print
*
* @defaultValue `100`
*/
maxConsoleMessagesPerTest?: number | undefined;
/**
* How long a test can take before it's considered "slow" (in ms)
*
* @defaultValue `75`
*/
slowTestThreshold?: number | undefined;
/**
* Whether to run Wallaby as you type (`automatic`) or only upon file
* save (`onsave`).
*
* @defaultValue `'automatic'`
*/
runMode?: "onsave" | "automatic" | undefined;
/**
* Percentage of coverage a file must have _not_ to be considered as
* having "low coverage"
*
* @defaultValue `80`
*/
lowCoverageThreshold?: number | undefined;
/**
* Project name
*
* Affects Wallaby web app only
*/
name?: string | undefined;
/**
* If `false`, do not reporter unhandled `Promise` rejections as errors.
*
* Node.js only
*
* @defaultValue `true`
*/
reportUnhandledPromises?: boolean | undefined;
/**
* Run _all_ tests in files affected by the most recent file change.
*
* @defaultValue `false`
*/
runAllTestsInAffectedTestFile?: boolean | undefined;
/**
* Run _all_ tests regardless of whether Wallaby thinks they are
* affected by the most recent file change.
*
* @defaultValue `false`
*/
runAllTestsWhenNoAffectedTests?: boolean | undefined;
/**
* If `true`, only reload the files a test file directly depends on.
*
* @defaultValue `false`
*/
ignoreFileLoadingDependencyTracking?: boolean | undefined;
/**
* Maximum length of a single log entry
*
* @defaultValue `16384`
*/
maxLogEntrySize?: number | undefined;
/**
* Limit the number of trace steps during a debug session
*
* @defaultValue `999999`
*/
maxTraceSteps?: number | undefined;
/**
* Take a screenshot of the last test run by Wallaby
*
* Chrome/PhantomJS only
*
* @defaultValue `false`
*/
screenshot?: number | undefined;
/**
* If `true`, any stack traces printed by `console.log` will be remapped
* to their original sources
*/
mapConsoleMessagesStackTrace?: boolean | undefined;
/**
* If `true`, automatically resolve getters in value & output explorers
*/
resolveGetters?: boolean | undefined;
/**
* If `false`, do not capture `console.log()` output
*/
captureConsoleLog?: boolean | undefined;
/**
* Configure logged value limits
*/
logLimits?: IWallabyLogLimits | undefined;
/**
* If `true`, Wallaby will not rewrite absolute filepaths so that they
* appear within the project root
*
* @defaultValue `false`
*/
preservePaths?: boolean | undefined;
/**
* If `true`, makes node test runner symlink local node modules from
* Wallaby cache to correctly support ES modules resolution
*/
symlinkNodeModules?: boolean | undefined;
/**
* If `true`, Willaby will not add new lines between test messages or
* test errors in Wallaby output.
*/
compactMessageOutput?: boolean | undefined;
}
/**
* Log limits for Wallaby's value & output explorers.
*/
export interface IWallabyLogLimits {
/**
* Limits for inline values
*/
inline?: IWallabyLogLimitsConfig | undefined;
/**
* Limits for non-inline values
*/
values?: IWallabyLogLimitsValues | undefined;
}
/**
* Log limit configuration
*/
export interface IWallabyLogLimitsConfig {
/**
* Depth at which to log values
*/
depth?: number | undefined;
/**
* Maximum number of elements to log
*/
elements?: number | undefined;
/**
* Maximum length of a string to log
*/
stringLength?: number | undefined;
}
/**
* Log limits for non-inline values
*/
export interface IWallabyLogLimitsValues {
/**
* Default log limits
*/
default?: IWallabyLogLimitsConfig | undefined;
/**
* Log limits for auto-expanding values
*/
autoExpand?: IWallabyLogLimitsConfig | undefined;
}
/**
* Delay config
*/
export interface IWallabyDelays {
/**
* Number of milliseconds to wait before letting Wallaby run
*/
run?: number | undefined;
}
/**
* Override how Wallaby interprets inline comments.
*
* @see {@link https://wallabyjs.com/docs/config/coverage.html} for details
*/
export interface IWallabyHints {
/**
* String or `RegExp` to match a comment which will tell Wallaby to ignore coverage on a file
*/
ignoreCoverageForFile?: string | RegExp | undefined;
/**
* String or `RegExp` to match a comment which will tell Wallaby to ignore coverage on a line
*/
ignoreCoverage?: string | RegExp | undefined;
}
/**
* Bootstrap function to run at Wallaby start
*
* @template T - Test framework instance
* @see {@link https://wallabyjs.com/docs/config/bootstrap.html} for details
*/
export type IWallabySetup<T = any> = (wallaby: IWallabyTestRunnerContext<T>) => void | Promise<void>;
/**
* Teardown function to run after Wallaby has completed
*
* @template T - Test framework instance
* @see {@link https://wallabyjs.com/docs/config/bootstrap.html} for details
*/
export type IWallabyTeardown<T = any> = (wallaby: IWallabyTestRunnerContext<T>) => void | Promise<void>;
/**
* Wallaby compiler configuration
*
* @see {@link https://wallabyjs.com/docs/config/compilers.html} for details.
*/
export type IWallabyCompilers = Record<string, IWallabyCompiler>;
/**
* Wallaby's built-in compilers.
*
* @see {@link https://wallabyjs.com/docs/config/compilers.html} for details.
*/
export interface IWallabyBuiltInCompilers {
/**
* Built-in Babel compiler options
*
* @see {@link https://babeljs.io/} for details.
*/
babel: (options?: BabelCompilerOptions) => IWallabyCompiler;
/**
* Built-in CoffeeScript compiler options
*
* @see {@link https://coffeescript.org/} for details.
*/
coffeeScript: (options?: CSCompilerOptions) => IWallabyCompiler;
/**
* Built-in TypeScript compiler options
*
* @see {@link https://www.typescriptlang.org/} for details.
*/
typeScript: (options?: TSCompilerOptions) => IWallabyCompiler;
}
/**
* Wallaby compiler result entity.
*
* @see {@link https://wallabyjs.com/docs/config/compilers.html} for details.
*/
export interface IWallabyCompilerResult {
/**
* Source map.
*/
map: string;
/**
* Code transformed to JavaScript.
*/
code: string;
/**
* All converable ranges of the original file.
*/
ranges: number[][];
}
/**
* Wallaby processors
*
* @see {@link https://wallabyjs.com/docs/config/preprocessors.html}
* @see {@link https://wallabyjs.com/docs/config/postprocessors.html}
*/
export type IWallabyProcessors = Record<string, IWallabyProcessor>;
/**
* A pre- or post-processor function
*
* @see {@link https://wallabyjs.com/docs/config/preprocessors.html}
* @see {@link https://wallabyjs.com/docs/config/postprocessors.html}
*/
export type IWallabyProcessor = (file: IWallabyFile) => void;
/**
* A compiler result
*
* @see {@link https://wallabyjs.com/docs/config/compilers.html}
*/
export type IWallabyCompiler = (file: IWallabyFile) => IWallabyCompilerResult;
/**
* Wallaby file object passed to pre-/post-processors and compilers.
*/
export interface IWallabyFile {
/**
* The current content of the file.
*/
content?: string | undefined;
/**
* The current path to the file.
*/
path?: string | undefined;
/**
* Rename or move the file to `newPath`.
*
* @param newPath - The new path to the file.
*/
rename(newPath: string): void;
/**
* Change the file extension.
* @param newExt - The new extension for the file.
*/
changeExt(newExt: string): void;
}
/**
* Wallaby file pattern.
*
* @see {@link https://wallabyjs.com/docs/config/files.html} for details.
*/
export interface IWallabyFilePattern {
/**
* File name or glob pattern.
*/
pattern: string;
/**
* Determines if file is ignored by Wallaby.
*
* @defaultValue `false`
*/
ignore?: boolean | undefined;
/**
* Determines if file is instrumented.
*
* @defaultValue `true`
*/
instrument?: boolean | undefined;
/**
* Determines if file is loaded to sandbox HTML via script tag.
*
* @defaultValue `true`
*/
load?: boolean | undefined;
/**
* Treat this file as a binary file
*/
binary?: boolean | undefined
}
/**
* Wallaby environment configuration.
*
* @see {@link https://wallabyjs.com/docs/config/runner.html} for details.
*/
export interface IWallabyEnvironment {
/**
* Set parameters on environment.
*/
params?: IWallabyEnvironmentParameters | undefined;
/**
* Test runner executable (e.g., `node`, `phantomjs`, `electron`) or path to it
*/
runner?: string | undefined;
/**
* To use Node.js, set `node`; `browser` for others
*
* @defaultValue `'browser'`
*/
type?: "node" | "browser";
/**
* For headless browser viewport size
*
* @defaultValue `{width: 800, height: 600}`
*/
viewportSize?: IWallabyEnvironmentViewportSize | undefined;
/**
* Report 404 server hits as errors to the Wallaby console
*/
report404AsError?: boolean | undefined;
/**
* If {@link type} is `browser`, specifies the browser to use
*
* @defaultValue `'chrome'`
*/
kind?: "chrome" | "electron" | "phantomjs";
}
/**
* Wallaby environment parameters.
*
* @see {@link https://wallabyjs.com/docs/config/runner.html} for details.
*/
export interface IWallabyEnvironmentParameters {
/**
* Semicolon-separated spawed runner process env variables.
*/
env?: string | undefined;
/**
* Space-separated spawed runner process flags.
*/
runner?: string | undefined;
}
/**
* Wallaby viewport settings for headless browsers & Electron.
*/
export interface IWallabyEnvironmentViewportSize {
/**
* Width in pixels for the viewport size in PhantomJs/Electron.
*/
width?: number | undefined;
/**
* Height in pixels for the viewport size in PhantomJs/Electron.
*/
height?: number | undefined;
}
/**
* Wallaby worker configuration.
*
* @see {@link https://wallabyjs.com/docs/config/workers.html} for details.
*/
export interface IWallabyWorkers {
/**
* May be an alias for {@link restart}
*/
recycle?: boolean | undefined;
/**
* If `true`, Wallaby will restart workers instead of reusing processes
*/
restart?: boolean | undefined;
/**
* Initial number of parallel processes to run your tests on start
*/
initial?: number;
/**
* Number of parallel processes to run your tests on code change
*/
regular?: number;
}
/**
* Wallaby object passed into config.
*
* @see {@link https://wallabyjs.com/docs/config/overview.html} for details.
*/
export interface IWallaby {
/**
* String property which returns the project local folder.
*/
localProjectDir: string;
/**
* String property which returns the project cache folder.
*/
projectCacheDir: string;
/**
* Property which allows you to access the built-in TypeScript, CoffeeScript and Babel compilers.
*/
compilers: IWallabyBuiltInCompilers;
/**
* Property which allows you to set the default values for file object properties.
*/
defaults?: any;
}
/**
* The `wallaby` object as passed to {@link bootstrap} and {@link teardown}.
*
* @template T - Test framework instance
*/
export interface IWallabyTestRunnerContext<T = any> extends IWallaby {
testFramework: T;
tests: string[];
workerId?: number;
sessionId?: string;
}
}