Replies: 2 comments
-
|
Both jsdom and happy-dom allow you to directly access the DOM. You can do something like this: Alternatively, you might want to use https://testing-library.com/ for your library of choice (react, vue, etc...). It introduces a |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
What I normally do with testing-library is: import "@testing-library/jest-dom";
import { render } from "@testing-library/vue";
import MyComponent from "./MyComponent.vue";
describe("MyComponent", () => {
it("shows the correct title", () => {
const { getByRole } = render(MyComponent);
expect(getByRole("heading", { name: "Hello, World!" })).toBeVisible();
});
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How can I test whether an HTML element exist after rendering a component? I'm trying to add a test case which can test whether my component is generating 2
imageelements and whether they're being placed side by side.Beta Was this translation helpful? Give feedback.
All reactions