Enable test isolation
I had experimented with turning this off in order to improve test performance, and apparently that ended up being merged. Now if we're to do component testing, we'll be changing things globally on the document, so isolation is very much necessary.
This commit is contained in:
@@ -25,8 +25,6 @@ import { useCallViewKeyboardShortcuts } from "../src/useCallViewKeyboardShortcut
|
|||||||
// Test Explanation:
|
// Test Explanation:
|
||||||
// - The main objective is to test `useCallViewKeyboardShortcuts`.
|
// - The main objective is to test `useCallViewKeyboardShortcuts`.
|
||||||
// The TestComponent just wraps a button around that hook.
|
// The TestComponent just wraps a button around that hook.
|
||||||
// - We need to set `userEvent` to the `{document = window.document}` since we are testing the
|
|
||||||
// `useCallViewKeyboardShortcuts` hook here. Which is listening to window.
|
|
||||||
|
|
||||||
interface TestComponentProps {
|
interface TestComponentProps {
|
||||||
setMicrophoneMuted: (muted: boolean) => void;
|
setMicrophoneMuted: (muted: boolean) => void;
|
||||||
@@ -52,7 +50,7 @@ const TestComponent: FC<TestComponentProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
test("spacebar unmutes", async () => {
|
test("spacebar unmutes", async () => {
|
||||||
const user = userEvent.setup({ document: window.document });
|
const user = userEvent.setup();
|
||||||
let muted = true;
|
let muted = true;
|
||||||
render(
|
render(
|
||||||
<TestComponent
|
<TestComponent
|
||||||
@@ -71,7 +69,7 @@ test("spacebar unmutes", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("spacebar prioritizes pressing a button", async () => {
|
test("spacebar prioritizes pressing a button", async () => {
|
||||||
const user = userEvent.setup({ document: window.document });
|
const user = userEvent.setup();
|
||||||
|
|
||||||
const setMuted = vi.fn();
|
const setMuted = vi.fn();
|
||||||
const onClick = vi.fn();
|
const onClick = vi.fn();
|
||||||
@@ -86,7 +84,7 @@ test("spacebar prioritizes pressing a button", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("unmuting happens in place of the default action", async () => {
|
test("unmuting happens in place of the default action", async () => {
|
||||||
const user = userEvent.setup({ document: window.document });
|
const user = userEvent.setup();
|
||||||
const defaultPrevented = vi.fn();
|
const defaultPrevented = vi.fn();
|
||||||
// In the real application, we mostly just want the spacebar shortcut to avoid
|
// In the real application, we mostly just want the spacebar shortcut to avoid
|
||||||
// scrolling the page. But to test that here in JSDOM, we need some kind of
|
// scrolling the page. But to test that here in JSDOM, we need some kind of
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ export default defineConfig((configEnv) =>
|
|||||||
classNameStrategy: "non-scoped",
|
classNameStrategy: "non-scoped",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
isolate: false,
|
|
||||||
setupFiles: ["src/vitest.setup.ts"],
|
setupFiles: ["src/vitest.setup.ts"],
|
||||||
coverage: {
|
coverage: {
|
||||||
reporter: ["html", "json"],
|
reporter: ["html", "json"],
|
||||||
|
|||||||
Reference in New Issue
Block a user