Vue Component Tests Can Now Run in a Real Browser Without jsdom
Most Vue component tests run in Node using jsdom, a simulated DOM that never renders CSS or calculates layout, meaning a passing test can still hide visual bugs. Developer and twd-js co-maintainer found that calling render() from @testing-library/vue inside a TWD test worked seamlessly in an actual browser environment. Since TWD runs tests inside the dev server's live page, components mount against a real DOM with genuine sizing, positioning, and CSS applied. A small helper function called componentHost() temporarily detaches the app root to prevent conflicts between the running app and the test-rendered component. The approach requires no changes to the app itself and leverages existing Testing Library APIs, simply swapping a simulated DOM for a real one.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in