Skip to content

Commit

Permalink
fix(karma): throws when vue warns
Browse files Browse the repository at this point in the history
  • Loading branch information
Walker Leite committed May 10, 2018
1 parent 3e8da00 commit 7907f28
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"loopback-chai": "^2.3.0",
"mocha": "^3.4.2",
"sinon": "^2.3.8",
"through2": "^2.0.3",
"tmp": "0.0.33",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
Expand Down
18 changes: 17 additions & 1 deletion template/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@ import babelify from 'babelify';
import vueify from 'vueify';
import modulesify from 'css-modulesify';
import tmp from 'tmp';
import through from 'through2';
import {dirs} from '../gulp-tasks/config';
import {customSass} from '../gulp-tasks/compilers';

const cssBundleFile = tmp.fileSync();

// Just hook window.console to throw vue warn
const consoleAppendfy = () => through(function (buf, enc, next) {
const hook = `
const error = console.error;
console.error = function(warning, ...args) {
if (/(Vue warn)/.test(warning)) {
throw new Error(warning);
}
error.apply(console, [warning, ...args]);
};
`;
this.push(hook + buf.toString('utf8'));
next();
});

export default (config) => {
vueify.compiler.applyConfig({
sass: {
Expand All @@ -31,7 +47,7 @@ export default (config) => {
browserify: {
output: cssBundleFile.name,
debug: true,
transform: [babelify, vueify],
transform: [consoleAppendfy, babelify, vueify],
plugin: [[modulesify, {
global: true,
generateScopedName(name, filename) {
Expand Down

0 comments on commit 7907f28

Please sign in to comment.