mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-08 03:00:02 +00:00
fix(storybook__addon-storyshots): improve imageSnapshot options (#25504)
* fix(storybook__addon-storyshots): improve imageSnapshot options * fix(storybook__addon-storyshots): correct imageSnapshot signature
This commit is contained in:
committed by
Sheetal Nandi
parent
0c23284637
commit
27e6a748e9
11
types/storybook__addon-storyshots/index.d.ts
vendored
11
types/storybook__addon-storyshots/index.d.ts
vendored
@@ -6,7 +6,7 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import { StoryObject } from '@storybook/react';
|
||||
import { Page } from "puppeteer";
|
||||
import { Page, NavigationOptions, ScreenshotOptions } from "puppeteer";
|
||||
|
||||
export type Test = (options: {
|
||||
story: StoryObject;
|
||||
@@ -34,9 +34,12 @@ export interface ImageSnapshotOptions {
|
||||
}
|
||||
|
||||
export function imageSnapshot(options?: {
|
||||
storybookUrl: string;
|
||||
getMatchOptions: (options: ImageSnapshotOptions) => { failureThreshold: number, failureThresholdType: 'percent' };
|
||||
beforeScreenshot: (page: Page, options: ImageSnapshotOptions) => Promise<void>;
|
||||
storybookUrl?: string;
|
||||
getMatchOptions?: (options: ImageSnapshotOptions) => { failureThreshold: number, failureThresholdType: 'percent' };
|
||||
getScreenshotOptions?: (options: ImageSnapshotOptions) => ScreenshotOptions;
|
||||
beforeScreenshot?: (page: Page, options: ImageSnapshotOptions) => Promise<void>;
|
||||
getGotoOptions?: (options: ImageSnapshotOptions) => NavigationOptions;
|
||||
chromeExecutablePath?: string;
|
||||
}): Test;
|
||||
|
||||
export function multiSnapshotWithOptions(options: SnapshotOptions): Test;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import initStoryshots, { multiSnapshotWithOptions, snapshotWithOptions, getSnapshotFileName, renderOnly } from "@storybook/addon-storyshots";
|
||||
import initStoryshots, { multiSnapshotWithOptions, snapshotWithOptions, getSnapshotFileName, renderOnly, imageSnapshot } from "@storybook/addon-storyshots";
|
||||
import { shallow } from 'enzyme';
|
||||
import toJson from 'enzyme-to-json';
|
||||
import 'jest';
|
||||
@@ -26,6 +26,23 @@ initStoryshots({
|
||||
test: renderOnly
|
||||
});
|
||||
|
||||
initStoryshots({
|
||||
configPath: "",
|
||||
test: imageSnapshot({
|
||||
storybookUrl: "http://localhost:9002"
|
||||
})
|
||||
});
|
||||
|
||||
initStoryshots({
|
||||
configPath: "",
|
||||
test: imageSnapshot({
|
||||
storybookUrl: "http://localhost:9002",
|
||||
getScreenshotOptions: ({ context, url }) => ({ path: "/foo" }),
|
||||
getGotoOptions: ({ context, url }) => ({ timeout: 10 }),
|
||||
chromeExecutablePath: "/usr/local/bin/chrome"
|
||||
})
|
||||
});
|
||||
|
||||
initStoryshots({
|
||||
framework: 'react',
|
||||
configPath: '',
|
||||
|
||||
Reference in New Issue
Block a user