如何在webpack捆绑的lib中模拟依赖项?

时间:2018-05-07 23:30:29

标签: jestjs

以下代码段说明了我的问题:

// 1. This uses 'external-web-components'
import Dep1 from '@/components/Dep1'

// 2. This module is webpack bundled
const ExternalComponents = require('external-web-components')
Vue.use(ExternalComponents)

describe('Test dep1', function () {
    it.only('It should do something', function () {


        // 3. 'external-web-components' uses this. How to mock it?
        // This doesnt work...
        jest.mock('vue-directive-tooltip', () => ({}))

        const wrapper = mount(Dep1)
    })
})

有人知道如何解决这个问题吗?

0 个答案:

没有答案