vue组件中使用lodash库导致jest报错

来源:2-10 钩子函数的作用域

慕婉清5985935

2023-06-04

 myComponent.vue › should display the correct count

    TypeError: Cannot read properties of undefined (reading 'isEmpty')

      231 |       }
      232 |       if (draggable) {
    > 233 |         if (!this.$lodash.isEmpty(a)```
lodash  在vue中时正常引入的
写回答

1回答

慕婉清5985935

提问者

2023-06-05

需设置 jest.setup.js 并在jest.config.js 中配置

setupFiles: ['<rootDir>/jest.setup.js']


0
0

前端要学的测试课 从Jest入门到 TDD/BDD双实战

自动化测试实战 Vue / React 项目,让技术水平和架构思维双提升

1434 学习 · 350 问题

查看课程