Open
Description
import React from "preact/compat";
import { act, renderHook } from "@testing-library/preact-hooks";
// works:
// import React from "react";
// import { act, renderHook } from "@testing-library/react-hooks";
function useTest() {
let [state, dispatch] = React.useReducer((state, action) => {
throw new Error("X");
});
return {
load() {
dispatch();
},
};
}
test("test", async () => {
let { result, waitForNextUpdate } = renderHook(() => useTest());
act(async () => {
result.current.load();
});
expect(result.error.message).toBe("X");
});
With Preact, this fails because the error is thrown.
With React, result.error
is populated.
Metadata
Metadata
Assignees
Labels
No labels