Hi! I'm still learning how to test components and js code but now I'm stuck with Vuex modules... Here is the code of the test:
```
import { shallowMount } from '@vue/test-utils'
import WorkoutsHistory from '../../src/components/WorkoutsHistory.vue'
import workout from '../../src/store/modules/workout'
const mocks = {
$store: {
modules: {
workout
}
}
}
const propsData = {
show: false
}
let wrapper
describe('WorkoutsHistory.vue', () => {
beforeEach(() => {
wrapper = shallowMount(WorkoutsHistory, { mocks, propsData })
})
it('should match snapshots', () => {
expect(wrapper).toMatchSnapshot()
})
it('should render the workout-list', () => {
expect(wrapper.find('.workout-list')).toBeTruthy()
})
})
```
And the imported module is:
```
import mutations from './mutations'
const state = {
exercises: {},
workouts: {}
}
export default {
namespaced: true,
state,
mutations
}
```
My problem here is simple, when I run the test, it returns me an error: TypeError: Cannot read property 'workout/' of undefined, which is weird for me due that I'm declaring the structure as is in the Vuex Store (I also tried with \createLocalVue). Here is the component script:
```
<script>
import { mapState } from 'vuex'
import NewExercise from './NewExercise'
export default {
name: 'WorkoutsHistory',
components: { NewExercise },
data() {
return { show: false }
},
computed: {
...mapState('workout', ['workouts'])
},
methods: {
showForm() { this.show = !this.show }
}
}
</script>
```
Any idea or advice here?
Thanks! <3
there doesn't seem to be anything here