Raise exception when using :focus tag to avoid skipping RSpec tests#167
Merged
Raise exception when using :focus tag to avoid skipping RSpec tests#167
:focus tag to avoid skipping RSpec tests#167Conversation
:focus tag to avoid skipping RSpec tests:focus tag to avoid skipping RSpec tests
raise exception only when inclusion rule includes :focus tag
fa9b817 to
6fdc177
Compare
shadre
reviewed
Mar 23, 2022
shadre
reviewed
Mar 24, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raise exception only when RSpec inclusion rule includes
:focustag.problem description
When tests can be skipped by RSpec?
The problem occurs when at least one of the test files has
:focustag. And when you useFor instance, if a test file has content like this:
Then this sets RSpec filter to
focus: true. You can see in RSpec output this:Run options: include {:focus=>true}and as a result we can see in the RSpec output:
All examples were filtered outso tests without the tag are skipped.All further test files fetched from Queue are going to be skipped due to this filter
:focus => true.solution
Using the
:focustag should be a temporary change in the development environment when you only want to run tests with the:focustag. In the CI environment, it is not recommended to use:focustag because this can lead to skipping test cases. Especially it can lead to skipping random test file paths without:focustag in the Knapsack Pro Queue Mode when the test files are loaded after the test file with:focustag. Please remove:focustags from your test files and commit the change and push to the repository. RSpec provides aliasesfit,fdescribeandfcontextas a shorthand forit,describeandcontextwith:focusmetadata, making it easy to temporarily focus an example or group by prefixing anf. Please remove all occurrences of it or use an alternative solution: https://knapsackpro.com/faq/question/why-is-rspec-skipping-some-of-the-tests#if-you-have-too-many-test-files-with-focus-tag-and-you-dont-want-to-remove-the-tag-manually