/
errors.ts
1812 lines (1356 loc) · 66.3 KB
/
errors.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
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
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import AU from 'ansi_up'
/* eslint-disable no-console */
import chalk from 'chalk'
import _ from 'lodash'
import path from 'path'
import stripAnsi from 'strip-ansi'
import type { TestingType } from '@packages/types'
import type { BreakingErrResult } from '@packages/config'
import { humanTime, logError, parseResolvedPattern, pluralize } from './errorUtils'
import { errPartial, errTemplate, fmt, theme, PartialErr } from './errTemplate'
import { stackWithoutMessage } from './stackUtils'
import type { DependencyToInstall } from '@packages/scaffold-config'
import type { ClonedError, ConfigValidationFailureInfo, CypressError, ErrTemplateResult, ErrorLike } from './errorTypes'
const ansi_up = new AU()
ansi_up.use_classes = true
const displayRetriesRemaining = function (tries: number) {
const times = tries === 1 ? 'time' : 'times'
const lastTryNewLine = tries === 1 ? '\n' : ''
return fmt.meta(
`We will try connecting to it ${tries} more ${times}...${lastTryNewLine}`,
)
}
const getUsedTestsMessage = (limit: number, usedTestsMessage: string) => {
return _.isFinite(limit)
? fmt.off(`The limit is ${chalk.yellow(`${limit}`)} ${usedTestsMessage} results.`)
: fmt.off('')
}
export const warnIfExplicitCiBuildId = function (ciBuildId?: string | null) {
if (!ciBuildId) {
return null
}
return errPartial`\
It also looks like you also passed in an explicit ${fmt.flag('--ci-build-id')} flag.
This is only necessary if you are NOT running in one of our supported CI providers.
This flag must be unique for each new run, but must also be identical for each machine you are trying to --group or run in --parallel.\
`
}
/**
* All Cypress Errors should be defined here:
*
* The errors must return an "errTemplate", this is processed by the
*/
export const AllCypressErrors = {
CANNOT_TRASH_ASSETS: (arg1: Error) => {
return errTemplate`\
Warning: We failed to trash the existing run results.
This error will not alter the exit code.
${fmt.stackTrace(arg1)}`
},
CANNOT_REMOVE_OLD_BROWSER_PROFILES: (arg1: Error) => {
return errTemplate`\
Warning: We failed to remove old browser profiles from previous runs.
This error will not alter the exit code.
${fmt.stackTrace(arg1)}`
},
VIDEO_RECORDING_FAILED: (arg1: Error) => {
return errTemplate`\
Warning: We failed to record the video.
This error will not alter the exit code.
${fmt.stackTrace(arg1)}`
},
VIDEO_POST_PROCESSING_FAILED: (arg1: Error) => {
return errTemplate`\
Warning: We failed processing this video.
This error will not alter the exit code.
${fmt.stackTrace(arg1)}`
},
CHROME_WEB_SECURITY_NOT_SUPPORTED: (browser: string) => {
return errTemplate`\
Your project has set the configuration option: \`chromeWebSecurity\` to \`false\`.
This option will not have an effect in ${fmt.off(_.capitalize(browser))}. Tests that rely on web security being disabled will not run as expected.`
},
BROWSER_UNSUPPORTED_LAUNCH_OPTION: (browser: string, options: string[]) => {
return errTemplate`\
Warning: The following browser launch options were provided but are not supported by ${fmt.highlightSecondary(browser)}
${fmt.listItems(options)}`
},
BROWSER_NOT_FOUND_BY_NAME: (browser: string, foundBrowsersStr: string[]) => {
let canarySuffix: PartialErr | null = null
if (browser === 'canary') {
canarySuffix = errPartial`\
${fmt.off('\n\n')}
Note: In ${fmt.cypressVersion(`4.0.0`)}, Canary must be launched as ${fmt.highlightSecondary(`chrome:canary`)}, not ${fmt.highlightSecondary(`canary`)}.
See https://on.cypress.io/migration-guide for more information on breaking changes in 4.0.0.`
}
return errTemplate`\
Can't run because you've entered an invalid browser name.
Browser: ${fmt.highlight(browser)} was not found on your system or is not supported by Cypress.
Cypress supports the following browsers:
${fmt.listItems(['electron', 'chrome', 'chromium', 'chrome:canary', 'edge', 'firefox'])}
You can also use a custom browser: https://on.cypress.io/customize-browsers
Available browsers found on your system are:
${fmt.listItems(foundBrowsersStr)}${canarySuffix}`
},
BROWSER_NOT_FOUND_BY_PATH: (arg1: string, arg2: string) => {
return errTemplate`\
We could not identify a known browser at the path you provided: ${fmt.path(arg1)}
Read more about how to troubleshoot launching browsers: https://on.cypress.io/troubleshooting-launching-browsers
The output from the command we ran was:
${fmt.highlightSecondary(arg2)}`
},
NOT_LOGGED_IN: () => {
return errTemplate`\
You're not logged in.
Run ${fmt.highlight(`cypress open`)} to open the Desktop App and log in.`
},
TESTS_DID_NOT_START_RETRYING: (arg1: string) => {
return errTemplate`Timed out waiting for the browser to connect. ${fmt.off(arg1)}`
},
TESTS_DID_NOT_START_FAILED: () => {
return errTemplate`The browser never connected. Something is wrong. The tests cannot run. Aborting...`
},
CLOUD_CANCEL_SKIPPED_SPEC: () => {
return errTemplate`${fmt.off(`\n `)}This spec and its tests were skipped because the run has been canceled.`
},
CLOUD_API_RESPONSE_FAILED_RETRYING: (arg1: {tries: number, delay: number, response: Error}) => {
const time = pluralize('time', arg1.tries)
const delay = humanTime.long(arg1.delay, false)
return errTemplate`\
We encountered an unexpected error talking to our servers.
We will retry ${fmt.off(arg1.tries)} more ${fmt.off(time)} in ${fmt.off(delay)}...
The server's response was:
${fmt.highlightSecondary(arg1.response)}`
/* Because of fmt.listFlags() and fmt.listItems() */
/* eslint-disable indent */
},
CLOUD_CANNOT_PROCEED_IN_PARALLEL: (arg1: {flags: any, response: Error}) => {
return errTemplate`\
We encountered an unexpected error talking to our servers.
Because you passed the ${fmt.flag(`--parallel`)} flag, this run cannot proceed because it requires a valid response from our servers.
${fmt.listFlags(arg1.flags, {
group: '--group',
ciBuildId: '--ciBuildId',
})}
The server's response was:
${fmt.highlightSecondary(arg1.response)}`
},
CLOUD_CANNOT_PROCEED_IN_SERIAL: (arg1: {flags: any, response: Error}) => {
return errTemplate`\
We encountered an unexpected error talking to our servers.
${fmt.listFlags(arg1.flags, {
group: '--group',
ciBuildId: '--ciBuildId',
})}
The server's response was:
${fmt.highlightSecondary(arg1.response)}`
},
CLOUD_UNKNOWN_INVALID_REQUEST: (arg1: {flags: any, response: Error}) => {
return errTemplate`\
We encountered an unexpected error talking to our servers.
There is likely something wrong with the request.
${fmt.listFlags(arg1.flags, {
tags: '--tag',
group: '--group',
parallel: '--parallel',
ciBuildId: '--ciBuildId',
})}
The server's response was:
${fmt.highlightSecondary(arg1.response)}`
},
CLOUD_UNKNOWN_CREATE_RUN_WARNING: (arg1: {props: any, message: string}) => {
return errTemplate`\
Warning from Cypress Cloud: ${fmt.highlight(arg1.message)}
Details:
${fmt.meta(arg1.props)}`
},
CLOUD_STALE_RUN: (arg1: {runUrl: string, [key: string]: any}) => {
return errTemplate`\
You are attempting to pass the ${fmt.flag(`--parallel`)} flag to a run that was completed over 24 hours ago.
The existing run is: ${fmt.url(arg1.runUrl)}
You cannot parallelize a run that has been complete for that long.
${fmt.listFlags(arg1, {
tags: '--tag',
group: '--group',
parallel: '--parallel',
ciBuildId: '--ciBuildId',
})}
https://on.cypress.io/stale-run`
},
CLOUD_ALREADY_COMPLETE: (props: {runUrl: string}) => {
return errTemplate`\
The run you are attempting to access is already complete and will not accept new groups.
The existing run is: ${fmt.url(props.runUrl)}
When a run finishes all of its groups, it waits for a configurable set of time before finally completing. You must add more groups during that time period.
${fmt.listFlags(props, {
tags: '--tag',
group: '--group',
parallel: '--parallel',
ciBuildId: '--ciBuildId',
})}
https://on.cypress.io/already-complete`
},
CLOUD_PARALLEL_REQUIRED: (arg1: {runUrl: string}) => {
return errTemplate`\
You did not pass the ${fmt.flag(`--parallel`)} flag, but this run's group was originally created with the --parallel flag.
The existing run is: ${fmt.url(arg1.runUrl)}
${fmt.listFlags(arg1, {
tags: '--tag',
group: '--group',
parallel: '--parallel',
ciBuildId: '--ciBuildId',
})}
You must use the --parallel flag with this group.
https://on.cypress.io/parallel-required`
},
CLOUD_PARALLEL_DISALLOWED: (arg1: {runUrl: string}) => {
return errTemplate`\
You passed the ${fmt.flag(`--parallel`)} flag, but this run group was originally created without the --parallel flag.
The existing run is: ${fmt.url(arg1.runUrl)}
${fmt.listFlags(arg1, {
group: '--group',
parallel: '--parallel',
ciBuildId: '--ciBuildId',
})}
You can not use the --parallel flag with this group.
https://on.cypress.io/parallel-disallowed`
},
CLOUD_PARALLEL_GROUP_PARAMS_MISMATCH: (arg1: {runUrl: string, parameters: any, payload: any }) => {
let params: any = arg1.parameters
if (arg1.payload?.differentParams) {
params = {}
_.map(arg1.parameters, (value, key) => {
if (key === 'specs' && arg1.payload.differentSpecs?.length) {
const addedSpecs: string[] = []
const missingSpecs: string[] = []
_.forEach(arg1.payload.differentSpecs, (s) => {
if (value.includes(s)) {
addedSpecs.push(s)
} else {
missingSpecs.push(s)
}
})
params['differentSpecs'] = {
added: addedSpecs,
missing: missingSpecs,
}
} else if (arg1.payload.differentParams[key]?.expected) {
params[key] = `${value}.... (Expected: ${(arg1.payload.differentParams[key].expected)})`
} else {
params[key] = value
}
})
}
return errTemplate`\
You passed the ${fmt.flag(`--parallel`)} flag, but we do not parallelize tests across different environments.
This machine is sending different environment parameters than the first machine that started this parallel run.
The existing run is: ${fmt.url(arg1.runUrl)}
In order to run in parallel mode each machine must send identical environment parameters such as:
${fmt.listItems([
'specs',
'osName',
'osVersion',
'browserName',
'browserVersion (major)',
])}
This machine sent the following parameters:
${fmt.meta(params)}
https://on.cypress.io/parallel-group-params-mismatch`
},
CLOUD_RUN_GROUP_NAME_NOT_UNIQUE: (arg1: {runUrl: string, ciBuildId?: string | null}) => {
return errTemplate`\
You passed the ${fmt.flag(`--group`)} flag, but this group name has already been used for this run.
The existing run is: ${fmt.url(arg1.runUrl)}
${fmt.listFlags(arg1, {
group: '--group',
parallel: '--parallel',
ciBuildId: '--ciBuildId',
})}
If you are trying to parallelize this run, then also pass the ${fmt.flag(`--parallel`)} flag, else pass a different group name.
${warnIfExplicitCiBuildId(arg1.ciBuildId)}
https://on.cypress.io/run-group-name-not-unique`
},
DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS: () => {
return errTemplate`\
Deprecation Warning: The ${fmt.highlight(`before:browser:launch`)} plugin event changed its signature in ${fmt.cypressVersion(`4.0.0`)}
The event switched from yielding the second argument as an ${fmt.highlightSecondary(`array`)} of browser arguments to an options ${fmt.highlightSecondary(`object`)} with an ${fmt.highlightSecondary(`args`)} property.
We've detected that your code is still using the previous, deprecated interface signature.
This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args`
},
DUPLICATE_TASK_KEY: (arg1: string[]) => {
return errTemplate`\
Warning: Multiple attempts to register the following task(s):
${fmt.listItems(arg1, { color: 'yellow' })}
Only the last attempt will be registered.`
},
INDETERMINATE_CI_BUILD_ID: (arg1: Record<string, string>, arg2: string[]) => {
return errTemplate`\
You passed the ${fmt.flag(`--group`)} or ${fmt.flag(`--parallel`)} flag but we could not automatically determine or generate a ciBuildId.
${fmt.listFlags(arg1, {
group: '--group',
parallel: '--parallel',
})}
In order to use either of these features a ciBuildId must be determined.
The ciBuildId is automatically detected if you are running Cypress in any of the these CI providers:
${fmt.listItems(arg2)}
Because the ciBuildId could not be auto-detected you must pass the --ci-build-id flag manually.
https://on.cypress.io/indeterminate-ci-build-id`
},
RECORD_PARAMS_WITHOUT_RECORDING: (arg1: Record<string, string>) => {
return errTemplate`\
You passed the ${fmt.flag(`--ci-build-id`)}, ${fmt.flag(`--group`)}, ${fmt.flag(`--tag`)}, or ${fmt.flag(`--parallel`)} flag without also passing the ${fmt.flag(`--record`)} flag.
${fmt.listFlags(arg1, {
ciBuildId: '--ci-build-id',
tags: '--tag',
group: '--group',
parallel: '--parallel',
})}
These flags can only be used when recording to Cypress Cloud.
https://on.cypress.io/record-params-without-recording`
},
INCORRECT_CI_BUILD_ID_USAGE: (arg1: Record<string, string>) => {
return errTemplate`\
You passed the ${fmt.flag(`--ci-build-id`)} flag but did not provide either a ${fmt.flag(`--group`)} or ${fmt.flag(`--parallel`)} flag.
${fmt.listFlags(arg1, {
ciBuildId: '--ci-build-id',
})}
The --ci-build-id flag is used to either group or parallelize multiple runs together.
https://on.cypress.io/incorrect-ci-build-id-usage`
/* eslint-enable indent */
},
RECORD_KEY_MISSING: () => {
return errTemplate`\
You passed the ${fmt.flag(`--record`)} flag but did not provide us your Record Key.
You can pass us your Record Key like this:
${fmt.terminal(`cypress run --record --key <record_key>`)}
You can also set the key as an environment variable with the name: ${fmt.highlightSecondary(`CYPRESS_RECORD_KEY`)}
https://on.cypress.io/how-do-i-record-runs`
},
// TODO: make this relative path, not absolute
CANNOT_RECORD_NO_PROJECT_ID: (configFilePath: string) => {
return errTemplate`\
You passed the ${fmt.flag(`--record`)} flag but this project has not been setup to record.
This project is missing the ${fmt.highlight(`projectId`)} inside of: ${fmt.path(configFilePath)}
We cannot uniquely identify this project without this id.
You need to setup this project to record. This will generate a unique projectId.
Alternatively if you omit the ${fmt.flag(`--record`)} flag this project will run without recording.
https://on.cypress.io/recording-project-runs`
},
PROJECT_ID_AND_KEY_BUT_MISSING_RECORD_OPTION: (arg1: string) => {
return errTemplate`\
This project has been configured to record runs on our Cypress Cloud.
It currently has the projectId: ${fmt.highlight(arg1)}
You also provided your Record Key, but you did not pass the ${fmt.flag(`--record`)} flag.
This run will not be recorded.
If you meant to have this run recorded please additionally pass this flag:
${fmt.terminal('cypress run --record')}
If you don't want to record these runs, you can silence this warning:
${fmt.terminal('cypress run --record false')}
https://on.cypress.io/recording-project-runs`
},
CLOUD_INVALID_RUN_REQUEST: (arg1: {message: string, errors: string[], object: object}) => {
return errTemplate`\
Recording this run failed because the request was invalid.
${fmt.highlight(arg1.message)}
Errors:
${fmt.meta(arg1.errors)}
Request Sent:
${fmt.meta(arg1.object)}`
},
RECORDING_FROM_FORK_PR: () => {
return errTemplate`\
Warning: It looks like you are trying to record this run from a forked PR.
The ${fmt.highlight(`Record Key`)} is missing. Your CI provider is likely not passing private environment variables to builds from forks.
These results will not be recorded.
This error will not alter the exit code.`
},
CLOUD_CANNOT_UPLOAD_RESULTS: (apiErr: Error) => {
return errTemplate`\
Warning: We encountered an error while uploading results from your run.
These results will not be recorded.
This error will not alter the exit code.
${fmt.highlightSecondary(apiErr)}`
},
CLOUD_CANNOT_CREATE_RUN_OR_INSTANCE: (apiErr: Error) => {
return errTemplate`\
Warning: We encountered an error talking to our servers.
This run will not be recorded.
This error will not alter the exit code.
${fmt.highlightSecondary(apiErr)}`
},
CLOUD_RECORD_KEY_NOT_VALID: (recordKey: string, projectId: string) => {
return errTemplate`\
Your Record Key ${fmt.highlight(recordKey)} is not valid with this projectId: ${fmt.highlightSecondary(projectId)}
It may have been recently revoked by you or another user.
Please log into Cypress Cloud to see the valid Record Keys.
https://on.cypress.io/dashboard/projects/${fmt.off(projectId)}`
},
CLOUD_PROJECT_NOT_FOUND: (projectId: string, configFileBaseName: string) => {
return errTemplate`\
We could not find a Cypress Cloud project with the projectId: ${fmt.highlight(projectId)}
This ${fmt.highlightSecondary(`projectId`)} came from your ${fmt.path(configFileBaseName)} file or an environment variable.
Please log into Cypress Cloud and find your project.
We will list the correct projectId in the 'Settings' tab.
Alternatively, you can create a new project using the Desktop Application.
https://on.cypress.io/dashboard`
},
// TODO: make this relative path, not absolute
NO_PROJECT_ID: (configFilePath: string) => {
return errTemplate`Can't find ${fmt.highlight(`projectId`)} in the config file: ${fmt.path(configFilePath || '')}`
},
NO_PROJECT_FOUND_AT_PROJECT_ROOT: (projectRoot: string) => {
return errTemplate`Can't find a project at the path: ${fmt.path(projectRoot)}`
},
CANNOT_FETCH_PROJECT_TOKEN: () => {
return errTemplate`Can't find project's secret key.`
},
CANNOT_CREATE_PROJECT_TOKEN: () => {
return errTemplate`Can't create project's secret key.`
},
PORT_IN_USE_SHORT: (arg1: string | number) => {
return errTemplate`Port ${fmt.highlight(arg1)} is already in use.`
},
PORT_IN_USE_LONG: (arg1: string | number) => {
return errTemplate`\
Can't run project because port is currently in use: ${fmt.highlight(arg1)}
Assign a different port with the ${fmt.flag(`--port <port>`)} argument or shut down the other running process.`
},
ERROR_READING_FILE: (filePath: string, err: Error) => {
return errTemplate`\
Error reading from: ${fmt.path(filePath)}
${fmt.stackTrace(err)}`
},
ERROR_WRITING_FILE: (filePath: string, err: Error) => {
return errTemplate`\
Error writing to: ${fmt.path(filePath)}
${fmt.stackTrace(err)}`
},
NO_SPECS_FOUND: (folderPath: string, globPattern?: string[] | string | null) => {
// no glob provided, searched all specs
if (!globPattern) {
return errTemplate`\
Can't run because ${fmt.highlightSecondary(`no spec files`)} were found.
We searched for specs inside of this folder:
${fmt.listItem(folderPath)}`
}
const globPaths = _.castArray(globPattern).map((pattern) => {
const [resolvedBasePath, resolvedPattern] = parseResolvedPattern(folderPath, pattern)
return path.join(resolvedBasePath!, theme.yellow(resolvedPattern!))
})
const phrase = globPaths.length > 1 ? 'these glob patterns' : 'this glob pattern'
return errTemplate`\
Can't run because ${fmt.highlightSecondary(`no spec files`)} were found.
We searched for specs matching ${fmt.off(phrase)}:
${fmt.listItems(globPaths, { color: 'blue', prefix: ' > ' })}`
},
RENDERER_CRASHED: () => {
return errTemplate`\
We detected that the Chromium Renderer process just crashed.
This is the equivalent to seeing the 'sad face' when Chrome dies.
This can happen for a number of different reasons:
- You wrote an endless loop and you must fix your own code
- You are running Docker (there is an easy fix for this: see link below)
- You are running lots of tests on a memory intense application
- You are running in a memory starved VM environment
- There are problems with your GPU / GPU drivers
- There are browser bugs in Chromium
You can learn more including how to fix Docker here:
https://on.cypress.io/renderer-process-crashed`
},
BROWSER_CRASHED: (browser: string, code: string | number, signal: string) => {
return errTemplate`\
We detected that the ${fmt.highlight(browser)} process just crashed with code '${fmt.highlight(code)}' and signal '${fmt.highlight(signal)}'.
We have failed the current test and have relaunched ${fmt.highlight(browser)}.
This can happen for many different reasons:
- You wrote an endless loop and you must fix your own code
- You are running lots of tests on a memory intense application
- You are running in a memory starved VM environment
- There are problems with your GPU / GPU drivers
- There are browser bugs`
},
AUTOMATION_SERVER_DISCONNECTED: () => {
return errTemplate`The automation client disconnected. Cannot continue running tests.`
},
SUPPORT_FILE_NOT_FOUND: (supportFilePath: string) => {
return errTemplate`\
Your ${fmt.highlight(`supportFile`)} is missing or invalid: ${fmt.path(supportFilePath)}
The supportFile must be a .js, .ts, .coffee file or be supported by your preprocessor plugin (if configured).
Fix your support file, or set supportFile to ${fmt.highlightSecondary(`false`)} if a support file is not necessary for your project.
If you have just renamed the extension of your supportFile, restart Cypress.
https://on.cypress.io/support-file-missing-or-invalid`
},
DEFAULT_SUPPORT_FILE_NOT_FOUND: (supportFilePath: string) => {
return errTemplate`\
Your project does not contain a default ${fmt.highlight(`supportFile`)}. We expect a file matching ${fmt.path(supportFilePath)} to exist.
If a support file is not necessary for your project, set ${fmt.highlight(`supportFile`)} to ${fmt.highlightSecondary(`false`)}.
https://on.cypress.io/support-file-missing-or-invalid`
},
// TODO: make this relative path, not absolute
CONFIG_FILE_REQUIRE_ERROR: (configFilePath: string, err: Error) => {
return errTemplate`\
Your ${fmt.highlight(`configFile`)} is invalid: ${fmt.path(configFilePath)}
It threw an error when required, check the stack trace below:
${fmt.stackTrace(err)}
`
},
// TODO: make this relative path, not absolute
SETUP_NODE_EVENTS_IS_NOT_FUNCTION: (configFilePath: string, testingType: string, exported: any) => {
const code = errPartial`
{
${fmt.off(testingType)}: {
setupNodeEvents(on, config) {
${fmt.comment(`// configure tasks and plugins here`)}
}
}
}`
return errTemplate`\
Your ${fmt.highlight(`configFile`)} is invalid: ${fmt.path(configFilePath)}
The ${fmt.highlightSecondary(`${testingType}.setupNodeEvents()`)} function must be defined with the following signature:
${fmt.code(code)}
Instead we saw:
${fmt.stringify(exported)}
https://on.cypress.io/plugins-api
`
},
CONFIG_FILE_SETUP_NODE_EVENTS_ERROR: (configFilePath: string, testingType: TestingType, err: ErrorLike) => {
return errTemplate`
Your ${fmt.highlightSecondary(`configFile`)} threw an error from: ${fmt.path(configFilePath)}
The error was thrown while executing your ${fmt.highlight(`${testingType}.setupNodeEvents()`)} function:
${fmt.stackTrace(err)}
`
},
CONFIG_FILE_UNEXPECTED_ERROR: (configFilePath: string, err: ErrorLike) => {
return errTemplate`
Your ${fmt.highlight(`configFile`)} threw an error from: ${fmt.path(configFilePath)}
We stopped running your tests because your config file crashed.
${fmt.stackTrace(err)}
`
},
// TODO: make this relative path, not absolute
SETUP_NODE_EVENTS_INVALID_EVENT_NAME_ERROR: (configFilePath: string, invalidEventName: string, validEventNames: string[], err: Error) => {
return errTemplate`
Your ${fmt.highlightSecondary(`configFile`)} threw a validation error from: ${fmt.path(configFilePath)}
You must pass a valid event name when registering a plugin.
You passed: ${fmt.highlight(invalidEventName)}
The following are valid events:
${fmt.listItems(validEventNames)}
Learn more at https://docs.cypress.io/api/plugins/writing-a-plugin#config
${fmt.stackTrace(err)}
`
},
BUNDLE_ERROR: (filePath: string, arg2: string) => {
// IF YOU MODIFY THIS MAKE SURE TO UPDATE
// THE ERROR MESSAGE IN THE RUNNER TOO
return errTemplate`\
Oops...we found an error preparing this test file:
${fmt.listItem(filePath)}
The error was:
${fmt.highlight(arg2)}
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
- A missing file or dependency
- A syntax error in the file or one of its dependencies
Fix the error in your code and re-run your tests.`
},
// happens when there is an error in configuration file like "cypress.json"
// TODO: make this relative path, not absolute
CONFIG_VALIDATION_MSG_ERROR: (fileType: 'configFile' | null, fileName: string | null, validationMsg: string) => {
if (!fileType) {
return errTemplate`
An invalid configuration value was set:
${fmt.highlight(validationMsg)}`
}
return errTemplate`
Your ${fmt.highlight(fileType)} as ${fmt.path(fileName)} set an invalid value:
${fmt.highlight(validationMsg)}`
},
// TODO: make this relative path, not absolute
CONFIG_VALIDATION_ERROR: (fileType: 'configFile' | null, filePath: string | null, validationResult: ConfigValidationFailureInfo) => {
const { key, type, value, list } = validationResult
if (!fileType) {
return errTemplate`\
An invalid configuration value was set.
Expected ${fmt.highlight(key)} to be ${fmt.off(type)}.
Instead the value was: ${fmt.stringify(value)}`
}
if (list) {
return errTemplate`\
Your ${fmt.highlight(fileType)} at ${fmt.path(filePath)} set an invalid value:
The error occurred while validating the ${fmt.highlightSecondary(list)} list.
Expected ${fmt.highlight(key)} to be ${fmt.off(type)}.
Instead the value was: ${fmt.stringify(value)}`
}
return errTemplate`\
Your ${fmt.highlight(fileType)} at ${fmt.path(filePath)} set an invalid value:
Expected ${fmt.highlight(key)} to be ${fmt.off(type)}.
Instead the value was: ${fmt.stringify(value)}`
},
RENAMED_CONFIG_OPTION: (arg1: {name: string, newName: string}) => {
return errTemplate`\
The ${fmt.highlight(arg1.name)} configuration option you have supplied has been renamed.
Please rename ${fmt.highlight(arg1.name)} to ${fmt.highlightSecondary(arg1.newName)}`
},
CANNOT_CONNECT_BASE_URL: () => {
return errTemplate`\
Cypress failed to verify that your server is running.
Please start this server and then run Cypress again.`
},
CANNOT_CONNECT_BASE_URL_WARNING: (arg1: string) => {
return errTemplate`\
Cypress could not verify that this server is running:
${fmt.listItem(arg1)}
This server has been configured as your ${fmt.highlight(`baseUrl`)}, and tests will likely fail if it is not running.`
},
// TODO: test this
CANNOT_CONNECT_BASE_URL_RETRYING: (arg1: {attempt: number, baseUrl: string, remaining: number, delay: number}) => {
switch (arg1.attempt) {
case 1:
return errTemplate`\
Cypress could not verify that this server is running:
${fmt.listItem(arg1.baseUrl)}
We are verifying this server because it has been configured as your ${fmt.highlight(`baseUrl`)}.
Cypress automatically waits until your server is accessible before running tests.
${displayRetriesRemaining(arg1.remaining)}`
default:
return errTemplate`${displayRetriesRemaining(arg1.remaining)}`
}
},
// TODO: test this
INVALID_REPORTER_NAME: (arg1: {name: string, paths: string[], error: Error}) => {
return errTemplate`\
Error loading the reporter: ${fmt.highlight(arg1.name)}
We searched for the reporter in these paths:
${fmt.listItems(arg1.paths)}
Learn more at https://on.cypress.io/reporters
${fmt.stackTrace(arg1.error)}
`
},
// TODO: manually test this
NO_DEFAULT_CONFIG_FILE_FOUND: (arg1: string) => {
return errTemplate`\
Could not find a Cypress configuration file in this folder: ${fmt.path(arg1)}`
},
CONFIG_FILES_LANGUAGE_CONFLICT: (projectRoot: string, filesFound: string[]) => {
return errTemplate`
Could not load a Cypress configuration file because there are multiple matches.
We've found ${fmt.highlight(filesFound.length)} Cypress configuration files named
${fmt.highlight(filesFound.join(', '))} at the location below:
${fmt.listItem(projectRoot)}
Please delete the conflicting configuration files.
`
},
CONFIG_FILE_NOT_FOUND: (configFileBaseName: string, projectRoot: string) => {
return errTemplate`\
Could not find a Cypress configuration file.
We looked but did not find a ${fmt.highlight(configFileBaseName)} file in this folder: ${fmt.path(projectRoot)}`
},
INVOKED_BINARY_OUTSIDE_NPM_MODULE: () => {
return errTemplate`\
It looks like you are running the Cypress binary directly.
This is not the recommended approach, and Cypress may not work correctly.
Please install the ${fmt.highlight(`cypress`)} NPM package and follow the instructions here:
https://on.cypress.io/installing-cypress`
},
FREE_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: {link: string, usedTestsMessage: string, limit: number}) => {
return errTemplate`\
You've exceeded the limit of private test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)}
To continue recording tests this month you must upgrade your account. Please visit your billing to upgrade to another billing plan.
${fmt.off(arg1.link)}`
},
FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: {link: string, usedTestsMessage: string, gracePeriodMessage: string, limit: number}) => {
return errTemplate`\
You've exceeded the limit of private test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)}
Your plan is now in a grace period, which means your tests will still be recorded until ${fmt.off(arg1.gracePeriodMessage)}. Please upgrade your plan to continue recording tests on Cypress Cloud in the future.
${fmt.off(arg1.link)}`
},
PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: {link: string, usedTestsMessage: string, limit: number}) => {
return errTemplate`\
You've exceeded the limit of private test results under your current billing plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)}
To upgrade your account, please visit your billing to upgrade to another billing plan.
${fmt.off(arg1.link)}`
},
FREE_PLAN_EXCEEDS_MONTHLY_TESTS: (arg1: {link: string, usedTestsMessage: string, limit: number}) => {
return errTemplate`\
You've exceeded the limit of test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)}
To continue recording tests this month you must upgrade your account. Please visit your billing to upgrade to another billing plan.
${fmt.off(arg1.link)}`
},
FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS: (arg1: {link: string, usedTestsMessage: string, gracePeriodMessage: string, limit: number}) => {
return errTemplate`\
You've exceeded the limit of test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)}
Your plan is now in a grace period, which means you will have the full benefits of your current plan until ${fmt.highlight(arg1.gracePeriodMessage)}.
Please visit your billing to upgrade your plan.
${fmt.off(arg1.link)}`
},
PLAN_EXCEEDS_MONTHLY_TESTS: (arg1: {link: string, planType: string, usedTestsMessage: string, limit: number}) => {
return errTemplate`\
You've exceeded the limit of test results under your ${fmt.highlight(arg1.planType)} billing plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)}
To continue getting the full benefits of your current plan, please visit your billing to upgrade.
${fmt.off(arg1.link)}`
},
FREE_PLAN_IN_GRACE_PERIOD_PARALLEL_FEATURE: (arg1: {link: string, gracePeriodMessage: string}) => {
return errTemplate`\
${fmt.highlightSecondary(`Parallelization`)} is not included under your free plan.
Your plan is now in a grace period, which means your tests will still run in parallel until ${fmt.highlight(arg1.gracePeriodMessage)}. Please upgrade your plan to continue running your tests in parallel in the future.
${fmt.off(arg1.link)}`
},
PARALLEL_FEATURE_NOT_AVAILABLE_IN_PLAN: (arg1: {link: string}) => {
return errTemplate`\
${fmt.highlightSecondary(`Parallelization`)} is not included under your current billing plan.
To run your tests in parallel, please visit your billing and upgrade to another plan with parallelization.
${fmt.off(arg1.link)}`
},
PLAN_IN_GRACE_PERIOD_RUN_GROUPING_FEATURE_USED: (arg1: {link: string, gracePeriodMessage: string}) => {
return errTemplate`\
${fmt.highlightSecondary(`Grouping`)} is not included under your free plan.
Your plan is now in a grace period, which means your tests will still run with groups until ${fmt.highlight(arg1.gracePeriodMessage)}. Please upgrade your plan to continue running your tests with groups in the future.
${fmt.off(arg1.link)}`
},
RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN: (arg1: {link: string}) => {
return errTemplate`\
${fmt.highlightSecondary(`Grouping`)} is not included under your current billing plan.
To run your tests with groups, please visit your billing and upgrade to another plan with grouping.
${fmt.off(arg1.link)}`
},
// TODO: fix
FIXTURE_NOT_FOUND: (arg1: string, arg2: string[]) => {
return errTemplate`\
A fixture file could not be found at any of the following paths:
${fmt.listItem(arg1)}
${fmt.listItem(arg1)}.[ext]
Cypress looked for these file extensions at the provided path:
${fmt.listItem(arg2.join(', '))}
Provide a path to an existing fixture file.`
},
BAD_POLICY_WARNING: (policyKeys: string[]) => {
return errTemplate`\
Cypress detected policy settings on your computer that may cause issues.
The following policies were detected that may prevent Cypress from automating Chrome:
${fmt.listItems(policyKeys)}
For more information, see https://on.cypress.io/bad-browser-policy`
},
BAD_POLICY_WARNING_TOOLTIP: () => {
return errTemplate`Cypress detected policy settings on your computer that may cause issues with using this browser. For more information, see https://on.cypress.io/bad-browser-policy`
},
EXTENSION_NOT_LOADED: (browserName: string, extensionPath: string) => {
return errTemplate`\
${fmt.off(browserName)} could not install the extension at path: ${fmt.path(extensionPath)}
Please verify that this is the path to a valid, unpacked WebExtension.`
},
COULD_NOT_FIND_SYSTEM_NODE: (nodeVersion: string) => {
return errTemplate`\
${fmt.highlight(`nodeVersion`)} is set to ${fmt.highlightTertiary(`system`)} but Cypress could not find a usable Node executable on your ${fmt.highlightSecondary(`PATH`)}.
Make sure that your Node executable exists and can be run by the current user.
Cypress will use the built-in Node version ${fmt.highlightSecondary(nodeVersion)} instead.`
},
INVALID_CYPRESS_INTERNAL_ENV: (val: string) => {
return errTemplate`\
We have detected an unknown or unsupported ${fmt.highlightSecondary(`CYPRESS_INTERNAL_ENV`)} value: ${fmt.highlight(val)}
CYPRESS_INTERNAL_ENV is reserved for internal use and cannot be modified.`
},
CDP_VERSION_TOO_OLD: (minimumVersion: string, currentVersion: {major: number, minor: string | number}) => {