summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hanzel <mhanzel@gitlab.com>2019-07-18 16:18:04 +0200
committerMartin Hanzel <mhanzel@gitlab.com>2019-07-18 16:18:04 +0200
commit569d825092654fc74ccb12f2dcd3dc86c00233be (patch)
tree67179b6e24a712fec943f1705871f12aed40762e
parente6ff8abc8e0e63dd1f5224e99fd38b2ba9717b6a (diff)
downloadgitlab-ce-569d825092654fc74ccb12f2dcd3dc86c00233be.tar.gz
Add docs about waiting for requests
-rw-r--r--doc/development/testing_guide/frontend_testing.md10
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/development/testing_guide/frontend_testing.md b/doc/development/testing_guide/frontend_testing.md
index c909745b1ab..980f701d58d 100644
--- a/doc/development/testing_guide/frontend_testing.md
+++ b/doc/development/testing_guide/frontend_testing.md
@@ -505,6 +505,16 @@ glob otherwise your shell may split it into multiple arguments:
yarn karma -f 'spec/javascripts/ide/**/file_spec.js'
```
+## Test helpers
+
+### Wait until axios requests finish
+The axios utils module located in `~/lib/utils/axios_utils` contains two helper methods for tests that spawn HTTP requests. These are very useful if you don't have a handle to the request's Promise, for example when a Vue component does a request as part of its lifecycle.
+
+- `waitFor(url, callback)`: Runs `callback` after a request to `url` finishes (either successfully or unsuccessfully).
+- `waitForAll(callback)`: Runs `callback` once all pending requests have finished. If no requests are pending, runs `callback` on the next tick.
+
+Both functions run `callback` on the next tick after the requests finish (using `setImmediate()`), to allow any `.then()` or `.catch()` handlers to run.
+
## RSpec feature integration tests
Information on setting up and running RSpec integration tests with