Add workaround for Vue test utils setProps

see https://github.com/vuejs/vue-test-utils/issues/631#issuecomment-421108344
This commit is contained in:
Winnie Hellmann 2019-01-25 10:54:54 +01:00
parent 965dbbd24c
commit a71d02bb16

View file

@ -21,6 +21,16 @@ Vue.config.productionTip = false;
let hasVueWarnings = false; let hasVueWarnings = false;
Vue.config.warnHandler = (msg, vm, trace) => { Vue.config.warnHandler = (msg, vm, trace) => {
// The following workaround is necessary, so we are able to use setProps from Vue test utils
// see https://github.com/vuejs/vue-test-utils/issues/631#issuecomment-421108344
const currentStack = new Error('').stack;
const isInVueTestUtils = currentStack
.split('\n')
.some(line => line.startsWith(' at VueWrapper.setProps ('));
if (isInVueTestUtils) {
return;
}
hasVueWarnings = true; hasVueWarnings = true;
fail(`${msg}${trace}`); fail(`${msg}${trace}`);
}; };