-
Hi , i have component used with how can i test that component with @remix-run/testing ? Given below code block import { useOutletContext } from '@remix-run/react';
export default function Comp() {
const {revokeAuthToken} = useOutletContext()
return <div>Hello</div>
} And it test , it got similar that import { unstable_createRemixStub as createRemixStub } from "@remix-run/testing"; // I stil using 1.19.3
import {Outlet} from "@remix-run/react";
import {json} from "@remix-run/node"
import Comp from "./Comp"
const RemixStub = createRemixStub([
{
path: "/partners",
Component: Comp,
loader() {
return json({ message: "hello" });
},
}])
cy.mount(<RemixStub/>) it print the error What do i missing ? |
Beta Was this translation helpful? Give feedback.
Answered by
kiliman
Nov 8, 2023
Replies: 1 comment 1 reply
-
You need a parent route that sets |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
neviaumi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need a parent route that sets
<Outlet context>
. YourComp
is trying to get context that doesn't exist yet. Your tests need to set the same conditions as your production code.