summaryrefslogtreecommitdiff
path: root/doc/development/testing_guide/best_practices.md
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-10-16 12:37:52 -0500
committerEric Eastwood <contact@ericeastwood.com>2017-10-16 15:19:15 -0500
commit758fc7a7919ec427dde5ddd52f15f5cfaca1fea5 (patch)
treeae04d0a2131350090cef39a905857dc61d0a5016 /doc/development/testing_guide/best_practices.md
parent96d8c7fff114911faa7d3e1b6322c2b9e3377e9b (diff)
downloadgitlab-ce-758fc7a7919ec427dde5ddd52f15f5cfaca1fea5.tar.gz
Check for element before evaluate_scriptfeature/reliable-rspec-with-eval-script
Tip from https://robots.thoughtbot.com/write-reliable-asynchronous-integration-tests-with-capybara#directly-interacting-with-javascript
Diffstat (limited to 'doc/development/testing_guide/best_practices.md')
-rw-r--r--doc/development/testing_guide/best_practices.md2
1 files changed, 2 insertions, 0 deletions
diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md
index 613423dbd9a..624fad4c97c 100644
--- a/doc/development/testing_guide/best_practices.md
+++ b/doc/development/testing_guide/best_practices.md
@@ -35,6 +35,8 @@ Here are some things to keep in mind regarding test performance:
[Gotchas](../gotchas.md#dont-assert-against-the-absolute-value-of-a-sequence-generated-attribute)).
- Don't supply the `:each` argument to hooks since it's the default.
- On `before` and `after` hooks, prefer it scoped to `:context` over `:all`
+- When using `evaluate_script("$('.js-foo').testSomething()")`(or `execute_script`) which acts on a given element,
+ use a Capyabara matcher, `find('.js-foo')`, beforehand to ensure the element actually exists.
[four-phase-test]: https://robots.thoughtbot.com/four-phase-test