BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9e28ca9d
Commit
9e28ca9d
authored
Jan 23, 2018
by
Winnie Hellmann
Committed by
Filipa Lacerda
Jan 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document advantages of axios-mock-adapter
parent
4dc42845
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
axios.md
doc/development/fe_guide/axios.md
+16
-3
No files found.
doc/development/fe_guide/axios.md
View file @
9e28ca9d
...
...
@@ -27,10 +27,23 @@ This exported module should be used instead of directly using `axios` to ensure
});
```
## Mock axios response
o
n tests
## Mock axios response
i
n tests
To help us mock the responses we
need we use
[
axios-mock-adapter
][
axios-mock-adapter
]
To help us mock the responses we
are using
[
axios-mock-adapter
][
axios-mock-adapter
]
.
Advantages over
[
`spyOn()`
]
:
-
no need to create response objects
-
does not allow call through (which we want to avoid)
-
simple API to test error cases
-
provides
`replyOnce()`
to allow for different responses
We have also decided against using
[
axios interceptors
]
because they are not suitable for mocking.
[
axios interceptors
]:
https://github.com/axios/axios#interceptors
[
`spyOn()`
]:
https://jasmine.github.io/api/edge/global.html#spyOn
### Example
```
javascript
import
axios
from
'~/lib/utils/axios_utils'
;
...
...
@@ -54,7 +67,7 @@ To help us mock the responses we need we use [axios-mock-adapter][axios-mock-ada
});
```
### Mock poll requests
o
n tests with axios
### Mock poll requests
i
n tests with axios
Because polling function requires a header object, we need to always include an object as the third argument:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment