Skip to content

Commit 1ef9df4

Browse files
author
Walker Leite
committed
fix(karma): fix App errors and consoleAppendfy
1 parent 7907f28 commit 1ef9df4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

template/test/client/app.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import Vue from 'vue';
2+
{{#extended}}
3+
import Vuex from 'vuex';
4+
{{/extended}}
25
import App from '@/App.vue';
36

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

1215
beforeEach((done) => {
16+
{{#extended}}
17+
Vue.use(Vuex);
18+
{{/extended}}
1319
Constructor = Vue.extend(App);
1420
vm = new Constructor({
1521
mounted: () => done(),
1622
{{#extended}}
1723
components: {routerView},
24+
store: new Vuex.Store({
25+
modules: {
26+
async: {
27+
namespaced: true,
28+
actions: {
29+
syncLoopback() {},
30+
},
31+
},
32+
},
33+
}),
1834
{{/extended}}
1935
});
2036
vm.$mount();

template/test/karma.conf.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {customSass} from '../gulp-tasks/compilers';
99
const cssBundleFile = tmp.fileSync();
1010

1111
// Just hook window.console to throw vue warn
12-
const consoleAppendfy = () => through(function (buf, enc, next) {
12+
const consoleAppendfy = file => through(function (buf, enc, next) {
1313
const hook = `
1414
const error = console.error;
1515
console.error = function(warning, ...args) {
@@ -19,7 +19,11 @@ const consoleAppendfy = () => through(function (buf, enc, next) {
1919
error.apply(console, [warning, ...args]);
2020
};
2121
`;
22-
this.push(hook + buf.toString('utf8'));
22+
if (/\.spec\.js$/.test(file)) {
23+
this.push(hook + buf.toString('utf8'));
24+
} else {
25+
this.push(buf.toString('utf8'));
26+
}
2327
next();
2428
});
2529

0 commit comments

Comments
 (0)