My Vue page code looks like this:
<template>
// Button that triggers the submit method
</template>
<script>
import { moveTo } from '@/lib/utils';
export default {
components: {
},
data() {
},
methods: {
async submit() {
moveTo(this, COMPLETE_ACTION.path, null);
},
},
};
</script>
Now, I'm facing an issue with my test file for this page. I am trying to use Jest to check and assert that the moveTo method is called with the correct parameters. However, I keep getting an error showing expected undefined but received an object. Here are some key points from the test file:
import * as dependency from '@/lib/utils';
dependency.moveTo = jest.fn();
// Triggering the button call which in turn calls the submit method on the page
expect(dependency.moveTo).toHaveBeenCalledWith(this, COMPLETE_ACTION.path, null);
I am confused about the context of this in this scenario and unsure about what I should pass in its place. It's worth noting that I am using the mount helper from Vue Test Utils.