Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-10-16 20:37:52 +0300
committerEric Eastwood <contact@ericeastwood.com>2017-10-19 22:01:15 +0300
commit43377979c6cfee922702a5dc6324fded96b1f111 (patch)
tree8ac0061a979a611c9927e04815a1df5a71d2d505 /doc/development/testing_guide/best_practices.md
parent96d8c7fff114911faa7d3e1b6322c2b9e3377e9b (diff)
Check for element before evaluate_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..7ddd02e6c73 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 beforehand (e.g. `find('.js-foo')`) to ensure the element actually exists.
[four-phase-test]: https://robots.thoughtbot.com/four-phase-test