Skip to content

Commit 21809a0

Browse files
Jinjiangkazupon
authored andcommittedDec 11, 2017
[docs] updated status of inject-loader (close #892) (#1088)
1 parent 1e3dc16 commit 21809a0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎docs/en/workflow/testing-with-mocks.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ In a real world application, our components most likely have external dependenci
44

55
`vue-loader` provides a feature that allows you to inject arbitrary dependencies to a `*.vue` component, using [inject-loader](https://github.com/plasticine/inject-loader). The general idea is that instead of directly importing the component module, we use `inject-loader` to create a "module factory" function for that module. When this function gets called with an object of mocks, it returns an instance of the module with the mocks injected.
66

7+
> Note: You must disable `esModule` option in inject mode, or you will get an error.
8+
79
Suppose we have a component like this:
810

911
``` html
@@ -14,9 +16,9 @@ Suppose we have a component like this:
1416

1517
<script>
1618
// this dependency needs to be mocked
17-
import SomeService from '../service'
19+
const SomeService = require('../service')
1820
19-
export default {
21+
module.exports = {
2022
data () {
2123
return {
2224
msg: SomeService.msg
@@ -28,10 +30,8 @@ export default {
2830

2931
Here's how to import it with mocks:
3032

31-
> Note: inject-loader@3.x is currently unstable.
32-
3333
``` bash
34-
npm install inject-loader@^2.0.0 --save-dev
34+
npm install inject-loader --save-dev
3535
```
3636

3737
``` js

0 commit comments

Comments
 (0)
Please sign in to comment.