Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3f98d65

Browse filesBrowse files
committed
Dos section
1 parent b78f16b commit 3f98d65
Copy full SHA for 3f98d65

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ npm run serve --stub
10551055

10561056
### Dos
10571057

1058-
* You can reuse any logic from real implementation in your stub by inheriting the stub from a real one. In this example, you can see the stub not completely overriding existing code, but rather mocking API call based on the username and password. The advantage is that logic inside real implementation is now running too, which might be important for you. Also, mocking axios is better than returning resolved promises because you might have registered an error interceptor (or any other interceptor) which you would like to see running too.
1058+
* You can reuse any logic from a real implementation in your stub by creating the stub based on the real code. In this example, you can see that the real implementation is not completely overrided by the stub, instead, it is mocking API calls based on the username and password. The advantage of this approach, is that the logic inside the real implementation can run alongside the stub, which might be important for you. Also, mocking axios is better than returning resolved promises because you might have registered an error interceptor (or any other interceptor) which you would like to see running too.
10591059

10601060
```js
10611061
import axios from 'axios';
@@ -1069,7 +1069,7 @@ export { AUTH_SERVICE_ID };
10691069
@Override(AUTH_SERVICE_ID)
10701070
export default class AuthServiceStub extends AuthService {
10711071
login (username, password) {
1072-
let axiosMock = new AxiosMockAdapter(axios);
1072+
const axiosMock = new AxiosMockAdapter(axios);
10731073
if (username === password) {
10741074
axiosMock.onPost('/api/login', { username, password }).replyOnce(200, 'random_token');
10751075
} else {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.