-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Only spawn a browser when using the feature
macro, not normal test
s
#795
Only spawn a browser when using the feature
macro, not normal test
s
#795
Conversation
This fixes an unintended behavior where having `use Wallaby.Feature` at the top of your module would cause a browser to be spawned for every test in the module, not just `feature` tests. The result is that if you had a large test module, most of which used the normal `test` macro and one of which used the `feature` macro, every test would take a minimum of a third of a second or more. I also took the liberty to check and see in the `setup` block if we already had a `:session`, and if so, avoid spawning a second. I don't *think* anyone was relying on the behavior where a second browser was being spawned if you had `use Wallaby.Feature` at both the top of the module and a `describe` block. Resolves elixir-wallaby#794
lib/wallaby/feature.ex
Outdated
|
||
# If you have `use Wallaby.Feature` at the top of your test module, | ||
# then also within a `describe` block, we only want to set up one session. | ||
already_has_session? = is_map_key(context, :session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not deal with this in this pull request and do a second one.
This might be better to emit a warning rather than be silent.
lib/wallaby/feature.ex
Outdated
end) | ||
|> unquote(__MODULE__).Utils.build_setup_return() | ||
# Only set up a session if this is a feature test (using the `feature` macro). | ||
feature_test? = context[:feature] == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here you want to check context[:test_type] == :feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I would just inline this. It's self explanatory.
The tests might fail a bunch but you don't have to worry about it. |
Changes made! |
This fixes an unintended behavior where having
use Wallaby.Feature
at the top of your module would cause a browser to be spawned for every test in the module, not justfeature
tests. The result is that if you had a large test module, most of which used the normaltest
macro and one of which used thefeature
macro, every test would take a minimum of a third of a second or more.I also took the liberty to check and see in thesetup
block if we already had a:session
, and if so, avoid spawning a second. I don't think anyone was relying on the behavior where a second browser was being spawned if you haduse Wallaby.Feature
at both the top of the module and adescribe
block.Resolves #794