Releases: dferber90/jsdom-screenshot
Releases · dferber90/jsdom-screenshot
v4.0.0
v3.2.0
Features
It's now possible to pass targetSelector
to generateImage
to specify which element to take a screenshot of.
import React from "react";
import { generateImage, setDefaultOptions } from "jsdom-screenshot";
import { render } from "react-testing-library";
import { SomeComponent } from "<your-code>";
it("should have no visual regressions", async () => {
// display: "table" prevents div from using full width,
// so the screenshot would not cover the full width here
render(
<div data-testid="root" style={{ display: "table" }}>
<SomeComponent />
</div>
);
const image = await generateImage({
targetSelector: "[data-testid=root]"
});
expect(image).toMatchImageSnapshot();
});
See README for more information.
Tests
Added primitive smoke-tests.
v3.1.1
v3.1.0
v3.0.2
v3.0.1
v3.0.0
Changed
- 51cc6e9 rename
waitForResources
towaitUntilNetworkIdle
and default tofalse
- 06b5b6b rename
options.publicPaths
tooptions.serve
- 84cd5d2 rename
options.requestInterception
tooptions.intercept
Upgrade guide
await generateImage({
- waitForResources: true,
- publicPaths: ['asstes'],
- requestInterception: () => {},
+ waitUntilNetworkIdle: true,
+ serve: ['asstes'],
+ intercept: () => {},
})
When you were relying on remote resources but they your setup did not specify this, then you need to declare it explicitly now.
await generateImage({
+ waitUntilNetworkIdle: true
})
v2.1.0
Added
- ac598f2 Add local webserver and
options.publicPath
option
Instead of using the page.goto(`data:text/html,${html}`)
approach of puppeteer/puppeteer#728 (comment) jsdom-screenshot
now starts its own webserver to serve the html
. This enables serving local assets for the screenshot. It further enables intercepting requests to local assets. See the updated README for more information.