Finding spec files in cypress can be easy when we know how to search for them using the below commands.
Table of Content
- Finding Spec File Using Config Settings
- Finding Spec File Against Branch
- Finding Spec File Against Parent Commit
- Finding Spec Files Count
- Finding Spec Files By Filtering Tag
- Finding Spec Files By Test Names
- Test Tags Filter Multiple
1. Finding Spec File Using Config Settings
npx find-cypress-specs
- Prints all spec files separated by commas.
2. Finding Spec File Against Branch
npx find-cypress-specs --branch main
- This prints all specs we can add --branch parameter to only isolate and print the specs changed against that origin/branch.
3. Finding Spec File Against Parent Commit:
npx find-cypress-specs --branch main --parent
- When dealing with a long-term branch, changed files may not want to be seen in the main branch.
- --parent can be passed only to pick the modified and added specs in the current branch.
4. Finding Spec Files Count:
npx find-cypress-specs --branch main --count
- Prints the number of spec files changed against branch origin/main.
5. Finding Spec Files By Filtering Tag:
npx find-cypress-specs --branch main --tagged @test,@tester1
- All changes specs can be filtered and report only the changes specs and include tags.
- Print specs changes against origin/main and tests or suites inside tagged @test or @tester1.
6. Test Names:
npx find-cypress-specs --names
- It can also print spec files with suit and test names.
7. Test Tags, Filter, Multiple:
npx find-cypress-specs --tags
- Fetches the tags table count of individual tests using the --tags argument.
npx find-cypress-specs --names --tagged <single tag>4
- Finds specs and tests filtered by a single specified tag.
npx find-cypress-specs --names --tagged <single tag>
- Finds specs based on the provided multiple tags using --tagged argument.