Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
130 views
in Technique[技术] by (71.8m points)

javascript - How to use compiler-included Vue build on tests using Jest for a Vue CLI app?

Following the instruction on Vue CLI docs, we can use the compiler-included Vue build adding the following code on vue.config.js:

module.exports = {
  runtimeCompiler: true
}

It works perfectly. However, when running unit tests with Jest, components that have the template attribute are not properly compiled and I see a commented function instead (running wrapper.html()).

I tried to declare the compiler-included Vue build in the Jest config file (as follows) but no success.

module.exports = {
  moduleNameMapper: {
    'vue$': 'vue/dist/vue.common.js'
  }
}

Does anyone know how to properly config the compiler-included Vue build on tests for an application created with Vue CLI? Thanks!

question from:https://stackoverflow.com/questions/65945305/how-to-use-compiler-included-vue-build-on-tests-using-jest-for-a-vue-cli-app

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...