Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
136 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 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...