Skip to content

Commit

Permalink
fix(karma): fix App errors and consoleAppendfy
Browse files Browse the repository at this point in the history
  • Loading branch information
Walker Leite committed May 10, 2018
1 parent 7907f28 commit 1ef9df4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
16 changes: 16 additions & 0 deletions template/test/client/app.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Vue from 'vue';
{{#extended}}
import Vuex from 'vuex';
{{/extended}}
import App from '@/App.vue';

describe('App.vue', () => {
Expand All @@ -10,11 +13,24 @@ describe('App.vue', () => {
{{/extended}}

beforeEach((done) => {
{{#extended}}
Vue.use(Vuex);
{{/extended}}
Constructor = Vue.extend(App);
vm = new Constructor({
mounted: () => done(),
{{#extended}}
components: {routerView},
store: new Vuex.Store({
modules: {
async: {
namespaced: true,
actions: {
syncLoopback() {},
},
},
},
}),
{{/extended}}
});
vm.$mount();
Expand Down
8 changes: 6 additions & 2 deletions template/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 consoleAppendfy = file => through(function (buf, enc, next) {
const hook = `
const error = console.error;
console.error = function(warning, ...args) {
Expand All @@ -19,7 +19,11 @@ const consoleAppendfy = () => through(function (buf, enc, next) {
error.apply(console, [warning, ...args]);
};
`;
this.push(hook + buf.toString('utf8'));
if (/\.spec\.js$/.test(file)) {
this.push(hook + buf.toString('utf8'));
} else {
this.push(buf.toString('utf8'));
}
next();
});

Expand Down

0 comments on commit 1ef9df4

Please sign in to comment.