Skip to content

README: Suggest asset mocks #6169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/@vue/cli-plugin-unit-jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ node --inspect-brk ./node_modules/@vue/cli-service/bin/vue-cli-service.js test:u

Jest can be configured via `jest.config.js` in your project root, or the `jest` field in `package.json`.

### Asset Mocks

If you get a SyntaxError on an asset such as an image or stylesheet, you will need to configure mocks:

**jest.config.js**:

```
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/file-mock.js",
"\\.(css|sass)$": "<rootDir>/__mocks__/style-mock.js"
}
```

**/src/__mock__/file-mock.js**:

```js
module.exports = 'test-file-stub'
```

**/src/__mock__/style-mock.js**:

```js
module.exports = {}
```

## Installing in an Already Created Project

```sh
Expand Down