Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mock filename when running all specs #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mhssmnn
Copy link
Contributor

@mhssmnn mhssmnn commented Dec 22, 2020

When running all specs, the mocks are recorded in a new file called "All Specs". This pull request attempts to find the filename based on the currentTest invocation details. AFAIK currentTest.invocationDetails is an undocumented api (Cypress adds it to mocha's Test instance). However this really helps when you want to run all specs on a CI server, but still maintain individual mock files.

Cypress v5.4.0

@Nanciee
Copy link
Owner

Nanciee commented Jan 4, 2021

@mhssmnn Thanks for the PR! Would this change how any existing tests are stored? I want to make sure this is properly marked if it is a breaking change.

@mhssmnn
Copy link
Contributor Author

mhssmnn commented Jan 5, 2021

@Nanciee Thanks for the plugin :). Yes it will be a breaking change.

If you ran all the tests before it would create/use a file called All Specs.json, whereas now it would use the individual testFile.spec.json that is created for each individual test file. I wasn't sure if this was the intended behavior, but this is definitely how I'd prefer it.

Also, see my note that it uses undocumented api to get the test filename, so it may break in the future. We could always start a discussion with the Cypress folks to see if they would support a way of getting the current test file when running all the tests.

@mhssmnn
Copy link
Contributor Author

mhssmnn commented Jan 5, 2021

Just realised that Cypress has experimental support for listening to before:spec events, which include the spec filename as an argument. So it's probably wise to move to using that once it's out of experimental stage.

@mhssmnn mhssmnn force-pushed the suite-based-mock-filenames branch 4 times, most recently from 5d44d66 to 2fde873 Compare August 23, 2021 23:29
When running all specs, the mocks are recorded in a new file called "All Specs". This tries to find the filename based on the currentTest invocation details.

Remove unused const

cleanup: store fixtures subfolder name
@mhssmnn mhssmnn force-pushed the suite-based-mock-filenames branch from 2fde873 to f4a645a Compare July 11, 2022 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants