-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstryker-incremental.json
854 lines (854 loc) · 39.3 KB
/
stryker-incremental.json
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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
{
"files": {
"src/index.ts": {
"language": "typescript",
"mutants": [
{
"id": "4",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 57,
"line": 34
},
"start": {
"column": 31,
"line": 34
}
}
},
{
"id": "7",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 2,
"line": 73
},
"start": {
"column": 78,
"line": 71
}
}
},
{
"id": "8",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 20,
"line": 80
},
"start": {
"column": 5,
"line": 80
}
}
},
{
"id": "9",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 20,
"line": 88
},
"start": {
"column": 5,
"line": 88
}
}
},
{
"id": "10",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 73,
"line": 95
},
"start": {
"column": 32,
"line": 95
}
}
},
{
"id": "11",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 6,
"line": 98
},
"start": {
"column": 75,
"line": 95
}
}
},
{
"id": "12",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 56,
"line": 96
},
"start": {
"column": 18,
"line": 96
}
}
},
{
"id": "13",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 54,
"line": 96
},
"start": {
"column": 36,
"line": 96
}
}
},
{
"id": "14",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 6,
"line": 108
},
"start": {
"column": 43,
"line": 105
}
}
},
{
"id": "15",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 59,
"line": 106
},
"start": {
"column": 18,
"line": 106
}
}
},
{
"id": "16",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 57,
"line": 106
},
"start": {
"column": 36,
"line": 106
}
}
},
{
"id": "17",
"mutatorName": "ArrowFunction",
"replacement": "() => undefined",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 7,
"line": 116
},
"start": {
"column": 52,
"line": 113
}
}
},
{
"id": "20",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 174,
"line": 122
},
"start": {
"column": 5,
"line": 122
}
}
},
{
"id": "21",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 6,
"line": 126
},
"start": {
"column": 5,
"line": 123
}
}
},
{
"id": "22",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 56,
"line": 124
},
"start": {
"column": 18,
"line": 124
}
}
},
{
"id": "23",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 54,
"line": 124
},
"start": {
"column": 36,
"line": 124
}
}
},
{
"id": "24",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 80,
"line": 134
},
"start": {
"column": 9,
"line": 134
}
}
},
{
"id": "25",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 24,
"line": 135
},
"start": {
"column": 9,
"line": 135
}
}
},
{
"id": "26",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 49,
"line": 142
},
"start": {
"column": 5,
"line": 142
}
}
},
{
"id": "27",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 52,
"line": 143
},
"start": {
"column": 9,
"line": 143
}
}
},
{
"id": "28",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 20,
"line": 144
},
"start": {
"column": 5,
"line": 144
}
}
},
{
"id": "29",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 39,
"line": 151
},
"start": {
"column": 5,
"line": 151
}
}
},
{
"id": "30",
"mutatorName": "ObjectLiteral",
"replacement": "{}",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 20,
"line": 152
},
"start": {
"column": 5,
"line": 152
}
}
},
{
"id": "33",
"mutatorName": "ArrowFunction",
"replacement": "() => undefined",
"statusReason": "Static mutant (and \"ignoreStatic\" was enabled)",
"status": "Ignored",
"static": true,
"coveredBy": [],
"location": {
"end": {
"column": 74,
"line": 196
},
"start": {
"column": 59,
"line": 196
}
}
},
{
"id": "1",
"mutatorName": "ArrowFunction",
"replacement": "() => undefined",
"statusReason": "Cannot read properties of undefined (reading 'toISOString')",
"status": "Killed",
"static": false,
"testsCompleted": 1,
"killedBy": [
"0"
],
"coveredBy": [
"0"
],
"location": {
"end": {
"column": 34,
"line": 16
},
"start": {
"column": 12,
"line": 16
}
}
},
{
"id": "0",
"mutatorName": "BlockStatement",
"replacement": "{}",
"statusReason": "dateFunction is not a function",
"status": "Killed",
"static": false,
"testsCompleted": 1,
"killedBy": [
"0"
],
"coveredBy": [
"0"
],
"location": {
"end": {
"column": 2,
"line": 17
},
"start": {
"column": 49,
"line": 15
}
}
},
{
"id": "2",
"mutatorName": "BlockStatement",
"replacement": "{}",
"statusReason": "expected '2024-12-09T17:41:19.544Z : I am a log…' to be '2023-09-06T00:00:00.000Z : I am a log…' // Object.is equality",
"status": "Killed",
"static": true,
"testsCompleted": 1,
"killedBy": [
"0"
],
"coveredBy": [
"0"
],
"location": {
"end": {
"column": 2,
"line": 27
},
"start": {
"column": 69,
"line": 25
}
}
},
{
"id": "3",
"mutatorName": "ArrowFunction",
"replacement": "() => undefined",
"statusReason": "Cannot read properties of undefined (reading 'toISOString')",
"status": "Killed",
"static": true,
"testsCompleted": 1,
"killedBy": [
"0"
],
"coveredBy": [
"0"
],
"location": {
"end": {
"column": 44,
"line": 26
},
"start": {
"column": 12,
"line": 26
}
}
},
{
"id": "5",
"mutatorName": "BlockStatement",
"replacement": "{}",
"statusReason": "expected 'Error: TypeError: fetch failed' to be 'User John Doe' // Object.is equality",
"status": "Killed",
"static": true,
"testsCompleted": 1,
"killedBy": [
"1"
],
"coveredBy": [
"1"
],
"location": {
"end": {
"column": 2,
"line": 66
},
"start": {
"column": 18,
"line": 63
}
}
},
{
"id": "6",
"mutatorName": "ArrowFunction",
"replacement": "() => undefined",
"statusReason": "expected 'Error: TypeError: Cannot read propert…' to be 'User John Doe' // Object.is equality",
"status": "Killed",
"static": true,
"testsCompleted": 1,
"killedBy": [
"1"
],
"coveredBy": [
"1"
],
"location": {
"end": {
"column": 54,
"line": 65
},
"start": {
"column": 12,
"line": 64
}
}
},
{
"id": "19",
"mutatorName": "StringLiteral",
"replacement": "\"\"",
"statusReason": "expected 'Error: Error' to be 'Error: Error: Connection failed ETIME…' // Object.is equality",
"status": "Killed",
"static": false,
"testsCompleted": 1,
"killedBy": [
"1"
],
"coveredBy": [
"1"
],
"location": {
"end": {
"column": 54,
"line": 115
},
"start": {
"column": 25,
"line": 115
}
}
},
{
"id": "31",
"mutatorName": "BlockStatement",
"replacement": "{}",
"statusReason": "expected [Function] to throw an error",
"status": "Killed",
"static": false,
"testsCompleted": 1,
"killedBy": [
"2"
],
"coveredBy": [
"2"
],
"location": {
"end": {
"column": 2,
"line": 173
},
"start": {
"column": 73,
"line": 171
}
}
},
{
"id": "32",
"mutatorName": "StringLiteral",
"replacement": "``",
"statusReason": "expected [Function] to throw error including 'Exit function was called with code 1' but got ''",
"status": "Killed",
"static": false,
"testsCompleted": 1,
"killedBy": [
"2"
],
"coveredBy": [
"2"
],
"location": {
"end": {
"column": 65,
"line": 172
},
"start": {
"column": 21,
"line": 172
}
}
},
{
"id": "18",
"mutatorName": "BlockStatement",
"replacement": "{}",
"statusReason": "Test timed out in 5000ms.\nIf this is a long-running test, pass a timeout value as the last argument or configure it globally with \"testTimeout\".",
"status": "Killed",
"static": false,
"testsCompleted": 1,
"killedBy": [
"1"
],
"coveredBy": [
"1"
],
"location": {
"end": {
"column": 6,
"line": 116
},
"start": {
"column": 33,
"line": 114
}
}
}
],
"source": "/* eslint-disable @typescript-eslint/naming-convention */\n\n// Date related types and functions\n\n/**\n * Type for a function that returns a Date.\n */\nexport type DateFunction = () => Date\n\n/**\n * Returns a DateFunction that returns the current date.\n * Can for example be used to get the current date when logging.\n * @returns DateFunction function returning the current data\n */\nexport function nowDateFunction(): DateFunction {\n return (): Date => new Date()\n}\n\n/**\n * Returns a DateFunction that returns a fixed date.\n * Can for example be used to get a fixed date for testing.\n * @param dateString fixed date string\n * @returns DateFunction function returning the fixed date\n */\nexport function fixedDateFunction(dateString: string): DateFunction {\n return (): Date => new Date(dateString)\n}\n\n/**\n * Test date\n * '1001-01-01T00:00:00.000Z'\n * as ISO Date string. Can be used to ease and unify testing.\n */\nexport const testDateString = '1001-01-01T00:00:00.000Z'\n\n/**\n * DateFunction that returns the test date.\n * Can for example be used to always get the date when testing.\n */\nexport const testDateFunction: DateFunction = fixedDateFunction(testDateString)\n\n// Fetch related types and functions\n\n/**\n * Type for a fetch function that given an input (url, request, etc.) and request init\n * returns a Promise<Response>\n */\nexport type FetchFunction = (\n input: string | URL | Request,\n init?: RequestInit,\n) => Promise<Response>\n\n/**\n * Returns a FetchFunction that always returns a fixed response.\n * Can for example be used to get a fixed Response for testing.\n * @param bodyInit body for the response\n * @param init response init\n * @returns FetchFunction function returning the fixed Response\n */\nexport function fixedResponseFetchFunction(\n bodyInit?: BodyInit,\n init?: ResponseInit,\n): FetchFunction {\n return (): Promise<Response> =>\n Promise.resolve(new Response(bodyInit, init))\n}\n\n/**\n * FetchFunction that returns a fixed Response with and empty body and status 400 (Bad Request).\n */\nexport const badRequestFetchFunction = fixedResponseFetchFunction(undefined, {\n status: 400,\n})\n\n/**\n * FetchFunction that returns a fixed Response with and empty body and status 404 (Not Found).\n */\nexport const notFoundFetchFunction: FetchFunction = fixedResponseFetchFunction(\n undefined,\n { status: 404 },\n)\n\n/**\n * FetchFunction that returns a fixed Response with and empty body and status 500 (Internal Server Error).\n */\nexport const internalServerErrorFetchFunction = fixedResponseFetchFunction(\n undefined,\n { status: 500 },\n)\n\n/**\n * FetchFunction that returns a fixed Response with broken JSON (missing bracket)\n */\nexport const brokenJSONFetchFunction: FetchFunction =\n fixedResponseFetchFunction('{\"data\": {\"message\": \"Missing bracket\"}', {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n\n/**\n * FetchFunction that returns a fixed Response with an unknown\n * Content-Type ('application/unknown')\n */\nexport const unknownContentTypeFetchFunction: FetchFunction =\n fixedResponseFetchFunction(undefined, {\n headers: { 'Content-Type': 'application/unknown' },\n status: 200,\n })\n\n/**\n * FetchFunction that returns a fixed Response that throws a Timeout error.\n */\nexport const timeoutFetchFunction: FetchFunction = (): Promise<Response> =>\n new Promise<Response>(() => {\n throw new Error('Connection failed ETIMEDOUT')\n })\n\n/**\n * FetchFunction that returns a fixed Response with an AggregateError.\n */\nexport const aggregateErrorFetchFunction = fixedResponseFetchFunction(\n '{\"errors\":[{\"message\":\"aaa The first error!, The second error!\", \"originalError\": {\"errors\": [{\"message\":\"The first error!\"}, {\"message\":\"The second error!\"} ] } }]}',\n {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n },\n)\n\n/**\n * FetchFunction that returns a fixed Response that GraphQL introspection is disabled.\n */\nexport const graphQLIntrospectionDisabledFetchFunction =\n fixedResponseFetchFunction(\n '{\"errors\": [ { \"message\": \"Introspection is disabled\"}],\"data\": null}',\n { status: 200 },\n )\n\n/**\n * FetchFunction that returns a fixed Response with an invalid GraphQL schema.\n */\nexport const graphQLInvalidSchemaFetchFunction = fixedResponseFetchFunction(\n '{\"data\": {\"__schema\":\"NotAGraphQLSchema\", ' +\n '\"_service\": {\"sdl\":\"NotAGraphQLSchema\"}}}',\n { status: 200 },\n)\n\n/**\n * FetchFunction that returns a fixed Response with an invalid GraphQL body.\n */\nexport const graphQLInvalidBodyFetchFunction = fixedResponseFetchFunction(\n '{\"message\": \"I am not GraphQL!\"}',\n { status: 200 },\n)\n\n// Exit function related types and functions\n\n/**\n * Type for a function that given an exit does not return anything.\n * @param {number} code The exit code to use\n * @returns {never} Does not return anything, may e.g. exit the process or throw an error\n */\nexport type ExitFunction = (code: number) => never\n\n/**\n * Exit function that does not exit the process but throws an error instead\n * Can be used in testing to avoid the tests exiting the application.\n * @param {number} code The exit code to be thrown in the error\n * @returns {never} Does not return anything but throws an error with the message\n * \"Exit function was called with code CODE\" where CODE is the given code.\n */\nexport const doNotExitFunction: ExitFunction = (code: number): never => {\n throw new Error(`Exit function was called with code ${code}`)\n}\n\n// Timeout function related types and functions\n\n/**\n * Type for a function that given a TimerHandler, optional timeout and arguments returns the timeout ID as number.\n * @param {TimerHandler} handler The TimerHandler to be called (i.e. in most cases a callback function)\n * @param {number} timeout The timeout in milliseconds\n * @param {any[]} timeoutArguments The arguments to be passed to the handler\n * @returns {number} The timeout ID as number\n */\nexport type TimeoutFunction = (\n handler: TimerHandler,\n timeout?: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...timeoutArguments: any[]\n) => number\n\n/**\n * TimeoutFunction that does not call the callback function but returns a fixed timeout ID 1.\n * Can be used in testing to avoid the tests waiting for the timeout to finish.\n * @returns {number} Fixed timeout ID 1\n */\nexport const noCallbackTimeoutFunction: TimeoutFunction = (): number => 1\n"
}
},
"schemaVersion": "1.0",
"thresholds": {
"high": 80,
"low": 60,
"break": null
},
"testFiles": {
"tests/index.test.ts": {
"tests": [
{
"id": "0",
"name": "Test date functions"
},
{
"id": "1",
"name": "Test fetch functions"
},
{
"id": "2",
"name": "Test exit functions"
},
{
"id": "3",
"name": "Test timeout functions"
},
{
"id": "4",
"name": "Test types match expected types of their default/original implementation"
}
],
"source": "import {\n aggregateErrorFetchFunction,\n badRequestFetchFunction,\n brokenJSONFetchFunction,\n DateFunction,\n doNotExitFunction,\n ExitFunction,\n FetchFunction,\n fixedDateFunction,\n fixedResponseFetchFunction,\n graphQLIntrospectionDisabledFetchFunction,\n graphQLInvalidBodyFetchFunction,\n graphQLInvalidSchemaFetchFunction,\n internalServerErrorFetchFunction,\n noCallbackTimeoutFunction,\n notFoundFetchFunction,\n nowDateFunction,\n testDateFunction,\n testDateString,\n timeoutFetchFunction,\n TimeoutFunction,\n unknownContentTypeFetchFunction,\n} from '@/index'\nimport { expect, test } from 'vitest'\n\n/**\n * Example Logger class to test the date functions.\n * The DateFunction is passed as an optional function parameter to the log\n * and prepareLogMessage functions in order to be able to set a custom DateFunction if necessary.\n */\nclass Logger {\n logEntries: string[] = []\n\n /**\n * Setting the default value to nowDateFunction will make it\n * easier to call the function without the caller providing a DateFunction argument\n */\n log(message: string, dateFunction: DateFunction = nowDateFunction()): void {\n const logEntry = this.prepareLogMessage(message, dateFunction)\n this.logEntries.push(logEntry)\n console.log(logEntry)\n }\n\n /**\n * prepareLogMessage prepares the log message and returns it as a string.\n * This will make it easier to test the output without having to spy on\n * the console.log function.\n */\n prepareLogMessage(\n message: string,\n dateFunction: DateFunction = nowDateFunction(),\n ): string {\n return `${dateFunction().toISOString()} : ${message}`\n }\n}\n\n/**\n * Example async function to test the fetch functions.\n * This function tries to fetch user data from a server and returns a string with the user data.\n * By providing an optional function parameter fetchFunction that is set to globalThis.fetch this\n * would try to fetch the user data from a server. In tests this function can be set to test\n * different scenarios like a successful fetch, a \"not found\" response or a timeout response.\n */\nasync function getUserById(\n id: string,\n fetchFunction: FetchFunction = globalThis.fetch,\n): Promise<string> {\n try {\n const userDataResponse = await fetchFunction(\n `https://localhost:3000/users/${id}`,\n )\n if (!userDataResponse.ok) {\n return `User was not found. Status is ${userDataResponse.status}`\n }\n return `User ${await userDataResponse.text()}`\n } catch (error) {\n return `Error: ${error}`\n }\n}\n\n/**\n * Second example async function to test the fetch functions (see above)\n * This function tries to work with JSON data so these scenarios can be tested.\n */\nasync function getJSONMessage(\n fetchFunction: FetchFunction = globalThis.fetch,\n): Promise<{ data: { message: string } }> {\n try {\n const messageResponse = await fetchFunction(\n 'https://localhost:3000/message/',\n )\n if (!messageResponse.ok) {\n return { data: { message: 'Message error!' } }\n }\n\n if (\n messageResponse.headers.get('Content-Type') !== 'application/json'\n ) {\n return {\n data: {\n message: 'Error: Content-Type is not application/json',\n },\n }\n }\n\n const message = await messageResponse.json()\n return message\n } catch (error) {\n return { data: { message: `Error: ${error}` } }\n }\n}\n\ntest('Test date functions', () => {\n const logger = new Logger()\n\n // Test that the fixed date function returns the correct date\n expect(\n logger.prepareLogMessage(\n 'I am a log message!',\n fixedDateFunction('2023-09-06T00:00:00Z'),\n ),\n ).toBe('2023-09-06T00:00:00.000Z : I am a log message!')\n\n // Test that the testDateFunction returns the test date\n expect(\n logger.prepareLogMessage('I am a log message!', testDateFunction),\n ).toBe(`${testDateString} : I am a log message!`)\n\n // Test that calling prepareLogMessage without a dateFunction argument does not run into an error\n expect(logger.prepareLogMessage('I am a log message!')).toContain(\n 'I am a log message!',\n )\n})\n\ntest('Test fetch functions', async () => {\n // Test that fixedResponseFetchFunction return the correct response\n expect(\n await getUserById(\n '1',\n fixedResponseFetchFunction('John Doe', { status: 200 }),\n ),\n ).toBe('User John Doe')\n\n // Test that badRequestFetchFunction is handled properly\n expect(await getUserById('1', badRequestFetchFunction)).toBe(\n 'User was not found. Status is 400',\n )\n\n // Test that notFoundFetchFunction is handled properly\n expect(await getUserById('1', notFoundFetchFunction)).toBe(\n 'User was not found. Status is 404',\n )\n\n // Test that internalServerErrorFetchFunction is handled properly\n expect(await getUserById('1', internalServerErrorFetchFunction)).toBe(\n 'User was not found. Status is 500',\n )\n\n // Test that timeoutFetchFunction is handled properly\n expect(await getUserById('1', timeoutFetchFunction)).toBe(\n 'Error: Error: Connection failed ETIMEDOUT',\n )\n\n // Test that aggregateErrorFetchFunction is handled properly\n expect(await getUserById('1', aggregateErrorFetchFunction)).toBe(\n 'User {\"errors\":[{\"message\":\"aaa The first error!, The second error!\", \"originalError\": {\"errors\": [{\"message\":\"The first error!\"}, {\"message\":\"The second error!\"} ] } }]}',\n )\n\n // Test that graphQLIntrospectionDisabledFetchFunction is handled properly\n expect(\n await getUserById('1', graphQLIntrospectionDisabledFetchFunction),\n ).toBe(\n 'User {\"errors\": [ { \"message\": \"Introspection is disabled\"}],\"data\": null}',\n )\n\n // Test that graphQLInvalidSchemaFetchFunction is handled properly\n expect(await getUserById('1', graphQLInvalidSchemaFetchFunction)).toBe(\n 'User {\"data\": {\"__schema\":\"NotAGraphQLSchema\", \"_service\": {\"sdl\":\"NotAGraphQLSchema\"}}}',\n )\n\n // Test that graphQLInvalidBodyFetchFunction is handled properly\n expect(await getUserById('1', graphQLInvalidBodyFetchFunction)).toBe(\n 'User {\"message\": \"I am not GraphQL!\"}',\n )\n\n // Test that fixedResponseFetchFunction with a JSON response return the correct response\n expect(\n await getJSONMessage(\n fixedResponseFetchFunction(\n '{\"data\": {\"message\": \"Hello world!\"}}',\n {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n },\n ),\n ),\n ).toEqual({ data: { message: 'Hello world!' } })\n\n // Test that brokenJSONFetchFunction is handled properly\n const brokenJSONResponse = await getJSONMessage(brokenJSONFetchFunction)\n expect(brokenJSONResponse.data.message).toContain('SyntaxError')\n\n // Test that unknownContentTypeFetchFunction is handled properly\n expect(await getJSONMessage(unknownContentTypeFetchFunction)).toEqual({\n data: { message: 'Error: Content-Type is not application/json' },\n })\n})\n\ntest('Test exit functions', () => {\n // Test that doNotExitFunction does not exit and returns the correct error message\n expect(() => doNotExitFunction(1)).toThrow(\n 'Exit function was called with code 1',\n )\n})\n\ntest('Test timeout functions', () => {\n const logger = new Logger()\n // noCallbackTimeoutFunction should return a fixed timeout ID 1\n expect(\n noCallbackTimeoutFunction(\n () => logger.log('This should not be executed!'),\n 1000,\n ),\n ).toBe(1)\n // Log call in callback function should not be executed\n expect(logger.logEntries.length).toBe(0)\n})\n\ntest('Test types match expected types of their default/original implementation', () => {\n /*\n * Note:\n * While this test might still pass for type mismatches,\n * the type check in \"check\" script will fail if the types do not match and cannot be casted\n */\n const defaultFetchFunction: FetchFunction = globalThis.fetch\n expect(defaultFetchFunction).toBeDefined()\n const defaultExitFunction: ExitFunction = process.exit\n expect(defaultExitFunction).toBeDefined()\n const defaultTimeoutFunction: TimeoutFunction = globalThis.setTimeout\n expect(defaultTimeoutFunction).toBeDefined()\n})\n"
}
},
"projectRoot": "C:\\ws_nodejs\\funpara",
"config": {
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"_comment": "This config was generated using 'stryker init'. Please take a look at: https://stryker-mutator.io/docs/stryker-js/configuration/ for more information.",
"packageManager": "npm",
"reporters": [
"html",
"clear-text",
"progress"
],
"testRunner": "vitest",
"testRunner_comment": "Take a look at https://stryker-mutator.io/docs/stryker-js/vitest-runner for information about the vitest plugin.",
"coverageAnalysis": "perTest",
"buildCommand": "npm run build",
"ignorers": [
"log-ignore"
],
"plugins": [
"@stryker-mutator/*",
"@sgohlke/stryker-log-ignorer"
],
"logignore": {
"objectNames": [
"logger"
]
},
"ignoreStatic": true,
"incremental": true,
"incrementalFile": "stryker-incremental.json",
"allowConsoleColors": true,
"checkers": [],
"checkerNodeArgs": [],
"commandRunner": {
"command": "npm test"
},
"clearTextReporter": {
"allowColor": true,
"allowEmojis": false,
"logTests": true,
"maxTestsToLog": 3,
"reportTests": true,
"reportMutants": true,
"reportScoreTable": true,
"skipFull": false
},
"dashboard": {
"baseUrl": "https://dashboard.stryker-mutator.io/api/reports",
"reportType": "full"
},
"dryRunOnly": false,
"eventReporter": {
"baseDir": "reports/mutation/events"
},
"ignorePatterns": [],
"force": false,
"fileLogLevel": "off",
"inPlace": false,
"logLevel": "info",
"maxConcurrentTestRunners": 9007199254740991,
"maxTestRunnerReuse": 0,
"mutate": [
"{src,lib}/**/!(*.+(s|S)pec|*.+(t|T)est).+(cjs|mjs|js|ts|mts|cts|jsx|tsx|html|vue|svelte)",
"!{src,lib}/**/__tests__/**/*.+(cjs|mjs|js|ts|mts|cts|jsx|tsx|html|vue|svelte)"
],
"mutator": {
"plugins": null,
"excludedMutations": []
},
"appendPlugins": [],
"htmlReporter": {
"fileName": "reports/mutation/mutation.html"
},
"jsonReporter": {
"fileName": "reports/mutation/mutation.json"
},
"disableTypeChecks": true,
"symlinkNodeModules": true,
"tempDirName": ".stryker-tmp",
"cleanTempDir": true,
"testRunnerNodeArgs": [],
"thresholds": {
"high": 80,
"low": 60,
"break": null
},
"timeoutFactor": 1.5,
"timeoutMS": 5000,
"dryRunTimeoutMinutes": 5,
"tsconfigFile": "tsconfig.json",
"warnings": true,
"disableBail": false,
"allowEmpty": false,
"vitest": {}
},
"framework": {
"name": "StrykerJS",
"version": "8.7.0",
"branding": {
"homepageUrl": "https://stryker-mutator.io",
"imageUrl": "data:image/svg+xml;utf8,%3Csvg viewBox='0 0 1458 1458' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' clip-rule='evenodd' stroke-linejoin='round' stroke-miterlimit='2'%3E%3Cpath fill='none' d='M0 0h1458v1458H0z'/%3E%3CclipPath id='a'%3E%3Cpath d='M0 0h1458v1458H0z'/%3E%3C/clipPath%3E%3Cg clip-path='url(%23a)'%3E%3Cpath d='M1458 729c0 402.655-326.345 729-729 729S0 1131.655 0 729C0 326.445 326.345 0 729 0s729 326.345 729 729' fill='%23e74c3c' fill-rule='nonzero'/%3E%3Cpath d='M778.349 1456.15L576.6 1254.401l233-105 85-78.668v-64.332l-257-257-44-187-50-208 251.806-82.793L1076.6 389.401l380.14 379.15c-19.681 367.728-311.914 663.049-678.391 687.599z' fill-opacity='.3'/%3E%3Cpath d='M753.4 329.503c41.79 0 74.579 7.83 97.925 25.444 23.571 18.015 41.69 43.956 55.167 77.097l11.662 28.679 165.733-58.183-14.137-32.13c-26.688-60.655-64.896-108.61-114.191-144.011-49.329-35.423-117.458-54.302-204.859-54.302-50.78 0-95.646 7.376-134.767 21.542-40.093 14.671-74.09 34.79-102.239 60.259-28.84 26.207-50.646 57.06-65.496 92.701-14.718 35.052-22.101 72.538-22.101 112.401 0 72.536 20.667 133.294 61.165 182.704 38.624 47.255 98.346 88.037 179.861 121.291 42.257 17.475 78.715 33.125 109.227 46.994 27.193 12.361 49.294 26.124 66.157 41.751 15.309 14.186 26.497 30.584 33.63 49.258 7.721 20.214 11.16 45.69 11.16 76.402 0 28.021-4.251 51.787-13.591 71.219-8.832 18.374-20.171 33.178-34.523 44.219-14.787 11.374-31.193 19.591-49.393 24.466-19.68 5.359-39.14 7.993-58.69 7.993-29.359 0-54.387-3.407-75.182-10.747-20.112-7.013-37.144-16.144-51.259-27.486-13.618-11.009-24.971-23.766-33.744-38.279-9.64-15.8-17.272-31.924-23.032-48.408l-10.965-31.376-161.669 60.585 10.734 30.124c10.191 28.601 24.197 56.228 42.059 82.748 18.208 27.144 41.322 51.369 69.525 72.745 27.695 21.075 60.904 38.218 99.481 51.041 37.777 12.664 82.004 19.159 132.552 19.159 49.998 0 95.818-8.321 137.611-24.622 42.228-16.471 78.436-38.992 108.835-67.291 30.719-28.597 54.631-62.103 71.834-100.642 17.263-38.56 25.923-79.392 25.923-122.248 0-54.339-8.368-100.37-24.208-138.32-16.29-38.759-38.252-71.661-65.948-98.797-26.965-26.418-58.269-48.835-93.858-67.175-33.655-17.241-69.196-33.11-106.593-47.533-35.934-13.429-65.822-26.601-89.948-39.525-22.153-11.868-40.009-24.21-53.547-37.309-11.429-11.13-19.83-23.678-24.718-37.664-5.413-15.49-7.98-33.423-7.98-53.577 0-40.883 11.293-71.522 37.086-90.539 28.443-20.825 64.985-30.658 109.311-30.658z' fill='%23f1c40f' fill-rule='nonzero'/%3E%3Cpath d='M720 0h18v113h-18zM1458 738v-18h-113v18h113zM720 1345h18v113h-18zM113 738v-18H0v18h113z'/%3E%3C/g%3E%3C/svg%3E"
},
"dependencies": {
"typescript": "5.7.2"
}
}
}