The project is generated using vue init webpack my-project, which is the vue webpack template
Add bootstrap scss package
Add
import './style/bootstrap.scss';
npm run dev and npm run build are both normal
But when npm run unit reports an error, a lot of errors appear similar to
font-size: $font-size-small;
^
Undefined variable: "$font-size-small".
mistake
I’m very confused:
1 Why the unit test alone reports an error
2 Try to remove the added import './style/bootstrap.scss'; in main.js, the page coming out of npm run dev has no style , but the npm run unit error is still
PHP中文网2017-05-18 11:01:10
There is the following statement in test/unit/index.js
// require all src files except main.js for coverage.
// you can also change this to match only the subset of files that
// you want coverage for .
const srcContext = require.context('../../src', true, /^./(?!main(.js)?$)/)
Changed to
const srcContext = require.context('../../src', true, /^./(style$)/)
Problem Solved
It should be that in order to test the code coverage, karma originally loaded all files except main.js. I removed the style instead