Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should call `screen.capture` with timestamp and custom path", async () => {
// GIVEN
const screenShotPath = join("test", "path", "to");
const screenShotFileName = "screenshot";
const screenShotFileExt = ".png";
screen.capture = jest.fn(() => Promise.resolve("filename"));
// WHEN
await ScreenApi.takeScreenshotWithTimestamp(`${join(screenShotPath, screenShotFileName)}${screenShotFileExt}`);
// THEN
expect(screen.capture).toBeCalledTimes(1);
expect(screen.capture).toBeCalledWith(screenShotFileName, FileType.PNG, screenShotPath, expect.stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}_/), "");
});
});
it("should call `screen.capture` with fallback `cwd()`", async () => {
// GIVEN
const screenShotFileName = "screenshot";
const screenShotFileExt = ".png";
screen.capture = jest.fn(() => Promise.resolve("filename"));
// WHEN
await ScreenApi.takeScreenshot(`${screenShotFileName}${screenShotFileExt}`);
// THEN
expect(screen.capture).toBeCalledTimes(1);
expect(screen.capture).toBeCalledWith(screenShotFileName, FileType.PNG, cwd());
});