Commit b60b68f
misc: warn when a --spec pattern matches no spec files (#34023)
* fix(run): warn when a --spec pattern matches no spec files
When a user provides multiple spec patterns via `--spec` and one or more
patterns don't match any files, Cypress now emits a warning for each
unmatched pattern instead of silently skipping them.
Fixes #22645
* fix(run): clarify SPEC_FILE_NOT_FOUND warning message
Distinguish the per-pattern warning from the NO_SPECS_FOUND error by
making it explicit that the pattern was ignored and other specs will
still run.
* chore: add changelog entry for --spec unmatched pattern warning
* chore: move changelog entry into existing Misc section
* chore: add SPEC_FILE_NOT_FOUND to schema.graphql and visual snapshot
- Add SPEC_FILE_NOT_FOUND to ErrorTypeEnum in schema.graphql (required
whenever a new key is added to AllCypressErrors in errors.ts per AGENTS.md)
- Add SPEC_FILE_NOT_FOUND.ansi visual snapshot for the new warning type
* fix(getUnmatchedPatterns): guard against undefined spec relative paths
Integration tests mock ctx.project._specs with plain strings rather than
SpecWithRelativeRoot objects, so s.relative is undefined. Filter those out
before passing to minimatch to prevent "Cannot read properties of undefined
(reading 'split')" crashes in tests that don't exercise the --spec warning path.
* fix(getUnmatchedPatterns): handle Windows path separators and absolute paths
relativeSpecPattern uses a hardcoded '/' separator so it cannot strip an
absolute Windows path (e.g. C:\project\cypress\e2e\foo.cy.ts stays absolute).
Likewise, path.relative returns backslash-separated paths on Windows while
minimatch treats backslashes as escape characters, not path separators.
Two fixes:
- run.ts: fall back to path.relative() for any pattern still absolute after
relativeSpecPattern, preventing false SPEC_FILE_NOT_FOUND warnings on Windows
- getUnmatchedPatterns: normalize all paths to forward slashes before minimatch
so the comparison is correct on all platforms
* feat(run): consolidate multiple unmatched --spec warnings into one
When multiple --spec patterns match nothing, emit a single
SPEC_FILE_NOT_FOUND warning listing all unmatched patterns together
rather than one warning per pattern.
- errors.ts: SPEC_FILE_NOT_FOUND now accepts string | string[] and uses
fmt.listItems so all unmatched paths appear under one header
- run.ts: replace per-pattern warning loop with a single warning call
- Add multiplePatterns snapshot variant to visualSnapshotErrors.spec.ts
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e0fe6e0 commit b60b68f
9 files changed
Lines changed: 115 additions & 0 deletions
File tree
- cli
- packages
- data-context
- schemas
- src/sources
- test/unit/sources
- errors
- src
- test
- __snapshots__
- server/lib/modes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1300 | 1300 | | |
1301 | 1301 | | |
1302 | 1302 | | |
| 1303 | + | |
1303 | 1304 | | |
1304 | 1305 | | |
1305 | 1306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
540 | 555 | | |
541 | 556 | | |
542 | 557 | | |
| |||
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
898 | 898 | | |
899 | 899 | | |
900 | 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 | + | |
901 | 955 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
761 | 776 | | |
762 | 777 | | |
763 | 778 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
631 | 637 | | |
632 | 638 | | |
633 | 639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1164 | 1164 | | |
1165 | 1165 | | |
1166 | 1166 | | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1167 | 1179 | | |
1168 | 1180 | | |
1169 | 1181 | | |
| |||
0 commit comments