1
votes

I just added test unit, and when I run it using npm run unit, I got the error and test will failed. But, when I run npm run dev everything looks fine, I don't know what the hack is happened. I think when I run with npm run unit, sass-loader cannot recognize the partial files and will throw new error variable undefined.

Here's my code https://github.com/rohmanhm/unobuilder/tree/test

Here is the error message.

✘ rohmanhm  ~/Desktop/Code/Works/unobuilder   test  sudo yarn unit yarn unit v0.20.3 $ cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run Hash: 6fdcbeffca85c85952cb Version: webpack 2.2.1 Time: 59663ms Asset Size Chunks Chunk Names static/fonts/lato100.ded7187.woff2 23.5 kB [emitted] static/img/icons.76d3910.svg 49.4 kB [emitted] static/fonts/lato300.100dadd.eot 32.7 kB [emitted] static/fonts/lato700.43a8fa5.eot 35.2 kB [emitted] static/fonts/lato900.4f7ab78.eot 33.8 kB [emitted] static/fonts/OpenSans-Bold.7ae9b8b.eot 110 kB [emitted] static/fonts/OpenSans-BoldItalic.ea07932.eot 128 kB [emitted] static/fonts/OpenSans-ExtraBold.561e4b6.eot 107 kB [emitted] static/fonts/OpenSans-ExtraBoldItalic.5f467e7.eot 124 kB [emitted] static/fonts/OpenSans-Italic.e487b7c.eot 131 kB [emitted] static/fonts/OpenSans-Light.8040375.eot 108 kB [emitted] static/fonts/OpenSans-LightItalic.6725fc4.eot 133 kB [emitted] static/fonts/OpenSans-Regular.a35546e.eot 106 kB [emitted] static/fonts/OpenSans-Semibold.0ea0450.eot 108 kB [emitted] static/fonts/OpenSans-SemiboldItalic.da06141.eot 131 kB [emitted] static/img/lato100.1e9336b.svg 233 kB [emitted] static/img/lato300.1aed0c8.svg 236 kB [emitted] static/img/lato700.cfdfec6.svg 250 kB [emitted] [big] static/img/lato900.030643b.svg 238 kB [emitted] static/img/OpenSans-Bold.d6291f8.svg 270 kB [emitted] [big] static/img/OpenSans-BoldItalic.a54aba8.svg 291 kB [emitted] [big] static/img/OpenSans-ExtraBold.c1deb2d.svg 272 kB [emitted] [big] static/img/OpenSans-ExtraBoldItalic.9704305.svg
290 kB [emitted] [big] static/img/OpenSans-Italic.d6671d4.svg 298 kB [emitted] [big] static/img/OpenSans-Light.d79f021.svg 264 kB [emitted] [big] static/img/OpenSans-LightItalic.b64e991.svg 298 kB [emitted] [big] static/img/OpenSans-Regular.f641a7d.svg 272 kB [emitted] [big] static/img/OpenSans-Semibold.66da250.svg 270 kB [emitted] [big] static/img/OpenSans-SemiboldItalic.ddc348f.svg 296 kB [emitted] [big] static/fonts/lato100.4abb6ba.ttf 76.1 kB [emitted] static/fonts/lato100.126c1aa.woff 33.3 kB [emitted] static/fonts/lato100.f8e1b1b.eot 30.2 kB [emitted] static/fonts/lato300.ad9795e.ttf 83.3 kB [emitted] static/fonts/lato300.6f934cd.woff 36.3 kB [emitted] static/fonts/lato300.3e86c49.woff2 25.4 kB [emitted] static/fonts/lato700.a30435e.ttf 82.4 kB [emitted] static/fonts/lato700.fd37395.woff 35.9 kB [emitted] static/fonts/lato700.649e18e.woff2 25.6 kB [emitted] static/fonts/lato900.01f5fcc.ttf 77 kB [emitted] static/fonts/lato900.c208c97.woff 34.4 kB [emitted] static/fonts/lato900.f377f44.woff2 25.4 kB [emitted] static/fonts/OpenSans-Bold.5a10091.ttf 110 kB [emitted] static/fonts/OpenSans-Bold.8926673.woff 63.6 kB [emitted] static/fonts/OpenSans-BoldItalic.c36b5ac.ttf 128 kB [emitted] static/fonts/OpenSans-BoldItalic.7be88e7.woff 73.6 kB [emitted] static/fonts/OpenSans-ExtraBold.5d29c43.ttf 107 kB [emitted] static/fonts/OpenSans-ExtraBold.3ae3245.woff 62.5 kB [emitted] static/fonts/OpenSans-ExtraBoldItalic.4595d7f.ttf 124 kB [emitted] static/fonts/OpenSans-ExtraBoldItalic.4f44077.woff 71.7 kB [emitted] static/fonts/OpenSans-Italic.9b30f13.ttf 131 kB [emitted] static/fonts/OpenSans-Italic.5250746.woff 76.1 kB [emitted] static/fonts/OpenSans-Light.ecb4572.ttf 107 kB [emitted] static/fonts/OpenSans-Light.963eb32.woff 62.8 kB [emitted] static/fonts/OpenSans-LightItalic.26f1e68.ttf 133 kB [emitted] static/fonts/OpenSans-LightItalic.97534dd.woff 76.4 kB [emitted] static/fonts/OpenSans-Regular.cd72963.ttf 106 kB [emitted] static/fonts/OpenSans-Regular.ac327c4.woff 63.7 kB [emitted] static/fonts/OpenSans-Semibold.b5a0ae8.ttf 108 kB [emitted] static/fonts/OpenSans-Semibold.56bfcae.woff 64.4 kB [emitted] static/fonts/OpenSans-SemiboldItalic.1c0b4eb.ttf 131 kB [emitted] static/fonts/OpenSans-SemiboldItalic.ec55f26.woff 75.6 kB [emitted] index.js 12.5 MB 0 [emitted] [big] index.js chunk {0} index.js (index.js) 5.22 MB [entry] [rendered] [5] ./src/utils.js 61.3 kB {0} [built] [11] (webpack)/buildin/global.js 509 bytes {0} [built] [12] ./src/store/mutation-types.js 11.8 kB {0} [built] [14] ./src/client.js 96.6 kB {0} [built] [57] ./~/vue/dist/vue.common.js 242 kB {0} [built] [153] ./~/function-bind/index.js 111 bytes {0} [built] [186] ./src ^./(?!main(.js)?$) 11.1 kB {0} [built]
[187] ./test/unit/specs .spec$ 177 bytes {0} [built] [463] ./src/assets/scss/layout/_properties.scss 1.21 kB {0} [optional] [built] [464] ./src/assets/scss/layout/_right_panel.scss 1.21 kB {0} [optional] [built] [465] ./src/assets/scss/layout/_screen_tools.scss 1.21 kB {0} [optional] [built] [466] ./src/assets/scss/layout/_top_panel.scss 1.2 kB {0} [optional] [built] [467] ./src/assets/scss/layout/_workspace.scss 1.2 kB {0} [optional] [built] [468] ./src/assets/scss/main.scss 1.16 kB {0} [optional] [built] [475] ./test/unit/index.js 505 bytes {0} [built] + 461 hidden modules

WARNING in ./src/components/panel/RightPanelProperties.vue There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanelProperties.vue Used by 2 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/src /^./(?!main(.js)?$)/ * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/rightPanelProperties.vue Used by 1 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/babel-loader/lib/index.js!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanel.vue

WARNING in ./src/components/panel/RightPanelSwitcher.vue There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanelSwitcher.vue Used by 2 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/src /^./(?!main(.js)?$)/ * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/rightPanelSwitcher.vue Used by 1 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/babel-loader/lib/index.js!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanel.vue

WARNING in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/panel/RightPanelProperties.vue There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/babel-loader/lib/index.js!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanelProperties.vue Used by 1 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanelProperties.vue * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/babel-loader/lib/index.js!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/rightPanelProperties.vue Used by 1 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/rightPanelProperties.vue

WARNING in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/panel/RightPanelSwitcher.vue There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/babel-loader/lib/index.js!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanelSwitcher.vue Used by 1 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/RightPanelSwitcher.vue * /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/babel-loader/lib/index.js!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/rightPanelSwitcher.vue Used by 1 module(s), i. e. /Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/vue-loader/index.js??ref--1!/Users/rohmanhm/Desktop/Code/Works/unobuilder/node_modules/eslint-loader/index.js??ref--0!/Users/rohmanhm/Desktop/Code/Works/unobuilder/src/components/panel/rightPanelSwitcher.vue

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/base.scss Module build failed: @include OpenSans; ^ No mixin named OpenSans

Backtrace: src/assets/scss/base/_fields.scss:22 in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/base/_fields.scss (line 22, column 16) @ ./src/assets/scss/base.scss 4:14-148 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout.scss Module build failed: background-color: lighten($warm-grey, 20); ^ Undefined variable: "$warm-grey". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_base.scss (line 7, column 29) @ ./src/assets/scss/layout.scss 4:14-150 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/base/_fields.scss Module build failed: [class*='#{$prefix}-fields-'] { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/base/_fields.scss (line 1, column 12) @ ./src/assets/scss/base/_fields.scss 4:14-157 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/canvas/_elements.scss Module build failed: .#{$prefix}:not(.preview--mode) { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/canvas/_elements.scss (line 1, column 4) @ ./src/assets/scss/canvas/_elements.scss 4:14-159 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/base/_fonts.scss Module build failed: src: url('#{$assets_path}/fonts/lato/lato100.eot'); /* IE9 Compat Modes */ ^ Undefined variable: "$assets-path". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/base/_fonts.scss (line 6, column 52) @ ./src/assets/scss/base/_fonts.scss 4:14-156 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_accordion.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_accordion.scss (line 1, column 4) @ ./src/assets/scss/layout/_accordion.scss 4:14-160 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_canvas_tools.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_canvas_tools.scss (line 3, column 4) @ ./src/assets/scss/layout/_canvas_tools.scss 4:14-163 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_base.scss Module build failed: background-color: lighten($warm-grey, 20); ^ Undefined variable: "$warm-grey". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_base.scss (line 7, column 29) @ ./src/assets/scss/layout/_base.scss 4:14-155 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_left_panel.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_left_panel.scss (line 1, column 4) @ ./src/assets/scss/layout/_left_panel.scss 4:14-161 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_properties.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_properties.scss (line 1, column 4) @ ./src/assets/scss/layout/_properties.scss 4:14-161 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_right_panel.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_right_panel.scss (line 1, column 4) @ ./src/assets/scss/layout/_right_panel.scss 4:14-162 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_screen_tools.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_screen_tools.scss (line 1, column 4) @ ./src/assets/scss/layout/_screen_tools.scss 4:14-163 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_top_panel.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_top_panel.scss (line 1, column 4) @ ./src/assets/scss/layout/_top_panel.scss 4:14-160 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./src/assets/scss/layout/_workspace.scss Module build failed: .#{$prefix} { ^ Undefined variable: "$prefix". in /Users/rohmanhm/Desktop/Code/Works/unobuilder/src/assets/scss/layout/_workspace.scss (line 1, column 4) @ ./src/assets/scss/layout/_workspace.scss 4:14-160 @ ./src ^./(?!main(.js)?$) @ ./test/unit/index.js 02 03 2017 16:16:01.321:INFO [karma]: Karma v1.5.0 server started at http://0.0.0.0:9876/ 02 03 2017 16:16:01.328:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency 02 03 2017 16:16:01.510:INFO [launcher]: Starting browser PhantomJS 02 03 2017 16:16:09.946:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket iTpEd0seJoQ2f3fcAAAA with id 5748459 02 03 2017 16:16:19.949:WARN [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Disconnected (1 times), because no message in 10000 ms. PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR Disconnected, because no message in 10000 ms.

PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 DISCONNECTED (10.013 secs / 0 secs)

error Command failed with exit code 1.

Please help me to resolve this problems. Thanks.

1
Read the error message – you have multiple undefined variables and mixins.Wing
yes I know, but when I run with npm run dev it's run smoothly. With the same configRohman HM

1 Answers

-1
votes

Fixed by replace from true to false 👍🏼

from const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)

to const srcContext = require.context('../../src', false, /^\.\/(?!main(\.js)?$)/)