diff options
author | Martin Hanzel <martin@hanzel.io> | 2019-09-05 12:56:17 +0000 |
---|---|---|
committer | Paul Slaughter <pslaughter@gitlab.com> | 2019-09-05 12:56:17 +0000 |
commit | bd20aeb64c4eed117831556c54b40ff4aee9bfd1 (patch) | |
tree | 6a94bdd21bc56943f159e9422249c41a0713823c /spec/frontend/notes | |
parent | 914af2f516acfa05cead52e438a35464abb4ac1d (diff) | |
download | gitlab-ce-bd20aeb64c4eed117831556c54b40ff4aee9bfd1.tar.gz |
Add helpers to wait for axios requests
Add two methods to the axios_utils Jest mock:
- `waitFor(url)`, which returns a Promise that resolves when the
next request to `url` finishes.
- `waitForAll()`, which returns a Promise that resolves when all
pending requests finish.
Diffstat (limited to 'spec/frontend/notes')
-rw-r--r-- | spec/frontend/notes/old_notes_spec.js | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/spec/frontend/notes/old_notes_spec.js b/spec/frontend/notes/old_notes_spec.js index b57041cf4d1..96133c601aa 100644 --- a/spec/frontend/notes/old_notes_spec.js +++ b/spec/frontend/notes/old_notes_spec.js @@ -49,17 +49,12 @@ describe('Old Notes (~/notes.js)', () => { setTestTimeoutOnce(4000); }); - afterEach(done => { + afterEach(() => { // The Notes component sets a polling interval. Clear it after every run. // Make sure to use jest.runOnlyPendingTimers() instead of runAllTimers(). jest.clearAllTimers(); - setImmediate(() => { - // Wait for any requests to resolve, otherwise we get failures about - // unmocked requests. - mockAxios.restore(); - done(); - }); + return axios.waitForAll().finally(() => mockAxios.restore()); }); it('loads the Notes class into the DOM', () => { |