diff options
author | 2022-07-14 10:32:13 +0400 | |
---|---|---|
committer | 2022-07-14 10:32:13 +0400 | |
commit | 38a319d5a648978bf81e5a4c9548eab228af9665 (patch) | |
tree | 3a23e602e06edc57b02f4d37050f280e04360536 /src | |
parent | Wrap Tests In Act (diff) |
Fix Failing jest.spyOn
Version 1.2.206 of swc introduces a breaking change which makes
jest.spyOn not work with our configuration. The response from the swc
maintainer seems like a complete mess, so I won't touch it, and just use
something else.
See issue 5059 on https://github.com/swc-project/swc/issues
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/pages/LandingPage.test.tsx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tests/pages/LandingPage.test.tsx b/src/tests/pages/LandingPage.test.tsx index b2a5142..908feed 100644 --- a/src/tests/pages/LandingPage.test.tsx +++ b/src/tests/pages/LandingPage.test.tsx @@ -25,8 +25,12 @@ const testingForm: forms.Form = { submitted_text: null }; +jest.mock("../../api/forms", () => ({ + ...jest.requireActual("../../api/forms"), + getForms: jest.fn(() => Promise.resolve([testingForm])) +})); + test("renders landing page", async () => { - jest.spyOn(forms, "getForms").mockImplementation(() => Promise.resolve([testingForm])); act(() => { render(<LandingPage/>, {wrapper: MemoryRouter}); }); const headerBar = await screen.findByText(/Python Discord Forms/); expect(headerBar).toBeInTheDocument(); |