I'm currently trying to implement Unit Testing on NextJS Commerce using Jest for vendure provider.
My component: \components\auth\LoginView.tsx
import useLogin from '@framework/auth/use-login'
const login = useLogin()
const handleLogin = async (values: any) => {
try {
setLoading(true)
setMessage('')
await login({
...values,
})
setLoading(false)
closeModal()
} catch ({ errors }) {
// @ts-ignore
setLoading(false)
}
}
And my test file:
import { LoginView } from '@components/auth'
import { render, screen, waitFor } from '@testing-library/react'
describe('LoginView Component', () => {
it('renders without error', () => {
render(<LoginView />)
})
})
I only try to render the component but it keeps appearing the TypeError:
TypeError: (0 , _useLogin.default) is not a function for the line:
> const login = useLogin()
And similar error for different authentication functions like Forgot Password, Reset Password,... I even try to render Index file and it just doesn't render without error.
Any help will be greatly appreciated.