亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - vue official example code, when processing scss files during unit testing, an error is reported
高洛峰
高洛峰 2017-05-18 10:59:10
0
1
600

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';

to the main.js file

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

高洛峰
高洛峰

擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級(jí)軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...

reply all(1)
洪濤

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template