How to Test Next.js's getServerSideProps with jest

Solution 1:

You can resort to type casting when passing the context object to getServerSideProps in your test.

it("check on good case", () => {
    const context = {
        params: { id: "fjdks" } as ParsedUrlQuery
    };
    const value = getServerSideProps(context as GetServerSidePropsContext);
    expect(value).toEqual({props: {businessName: "Name", businessID: "fjdks"}});
});