Getting 'orderBy' undefined error when testing Vue component using lodash with Jest Getting 'orderBy' undefined error when testing Vue component using lodash with Jest vue.js vue.js

Getting 'orderBy' undefined error when testing Vue component using lodash with Jest


I could fix a similar issue (with the help of this article).TLDR:Add to your component spec a "localVue" and then use lodash with this localVue instance:

import YourComponent from '@/YourComponent.vue'import { createLocalVue, mount, config } from '@vue/test-utils'import VueLodash from 'vue-lodash'import lodash from 'lodash'const localVue = createLocalVue()localVue.use(VueLodash, { lodash })...const wrapper = mount(YourComponent, {  localVue})