diff --git a/notNeededPackages.json b/notNeededPackages.json index 593ff21e2a..8eb39185e9 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -4650,6 +4650,18 @@ "sourceRepoURL": "https://github.com/storybooks/storybook", "asOfVersion": "5.2.0" }, + { + "libraryName": "@storybook/addon-storyshots", + "typingsPackageName": "storybook__addon-storyshots", + "sourceRepoURL": "https://github.com/storybooks/storybook", + "asOfVersion": "5.3.0" + }, + { + "libraryName": "@storybook/addon-storyshots-puppeteer", + "typingsPackageName": "storybook__addon-storyshots-puppeteer", + "sourceRepoURL": "https://github.com/storybooks/storybook", + "asOfVersion": "5.3.0" + }, { "libraryName": "@storybook/addon-viewport", "typingsPackageName": "storybook__addon-viewport", diff --git a/types/storybook__addon-storyshots-puppeteer/index.d.ts b/types/storybook__addon-storyshots-puppeteer/index.d.ts deleted file mode 100644 index 2c0a957b75..0000000000 --- a/types/storybook__addon-storyshots-puppeteer/index.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Type definitions for @storybook/addon-storyshots-puppeteer 5.1 -// Project: https://github.com/storybookjs/storybook/tree/master/addons/storyshots, https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-puppeteer -// Definitions by: Yama-Tomo -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 - -import { StoryContext } from '@storybook/addon-storyshots'; -import { MatchImageSnapshotOptions } from 'jest-image-snapshot'; -import { ScreenshotOptions, Page, DirectNavigationOptions, Browser } from 'puppeteer'; - -export interface Context { - context: StoryContext; - url: string; -} - -export interface CustomConfig { - storybookUrl?: string; - chromeExecutablePath?: string; - getMatchOptions?: (ctx: Context) => MatchImageSnapshotOptions; - getScreenshotOptions?: (ctx: Context) => ScreenshotOptions; - beforeScreenshot?: (page: Page, ctx: Context) => Promise; - getGotoOptions?: (ctx: Context) => DirectNavigationOptions; - customizePage?: (page: Page) => Promise; - getCustomBrowser?: () => Promise; -} - -export function imageSnapshot(customConfig?: CustomConfig): ({ context }: { context: StoryContext }) => - Promise; diff --git a/types/storybook__addon-storyshots-puppeteer/storybook__addon-storyshots-puppeteer-tests.ts b/types/storybook__addon-storyshots-puppeteer/storybook__addon-storyshots-puppeteer-tests.ts deleted file mode 100644 index 4f0d5469c4..0000000000 --- a/types/storybook__addon-storyshots-puppeteer/storybook__addon-storyshots-puppeteer-tests.ts +++ /dev/null @@ -1,23 +0,0 @@ -import initStoryshots from '@storybook/addon-storyshots'; -import { imageSnapshot } from '@storybook/addon-storyshots-puppeteer'; -import { connect } from 'puppeteer'; - -initStoryshots({ - test: imageSnapshot(), -}); - -initStoryshots({ - test: imageSnapshot({ - storybookUrl: 'http://localhost:9002', - chromeExecutablePath: '/usr/local/bin/chrome', - getMatchOptions: () => ({ - failureThreshold: 0.2, - failureThresholdType: 'percent', - }), - getScreenshotOptions: () => ({ path: '/foo' }), - beforeScreenshot: page => page.setViewport({ width: 300, height: 100 }), - getGotoOptions: () => ({ timeout: 10 }), - customizePage: page => page.setViewport({ width: 300, height: 100 }), - getCustomBrowser: () => connect({ browserWSEndpoint: 'ws://yourUrl' }), - }), -}); diff --git a/types/storybook__addon-storyshots-puppeteer/tsconfig.json b/types/storybook__addon-storyshots-puppeteer/tsconfig.json deleted file mode 100644 index d9b6f6a40d..0000000000 --- a/types/storybook__addon-storyshots-puppeteer/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": ["es6"], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "paths": { - "@storybook/addon-storyshots": [ - "storybook__addon-storyshots" - ], - "@storybook/addon-storyshots-puppeteer": [ - "storybook__addon-storyshots-puppeteer" - ] - }, - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "esModuleInterop": true - }, - "files": [ - "index.d.ts", - "storybook__addon-storyshots-puppeteer-tests.ts" - ] -} diff --git a/types/storybook__addon-storyshots-puppeteer/tslint.json b/types/storybook__addon-storyshots-puppeteer/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/storybook__addon-storyshots-puppeteer/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } diff --git a/types/storybook__addon-storyshots/index.d.ts b/types/storybook__addon-storyshots/index.d.ts deleted file mode 100644 index b8646387db..0000000000 --- a/types/storybook__addon-storyshots/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -// Type definitions for @storybook/addon-storyshots 5.1 -// Project: https://github.com/storybookjs/storybook/tree/master/addons/storyshots, https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-core -// Definitions by: Bradley Ayers -// Yama-Tomo -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 - -import { IStorybookStory } from '@storybook/react/dist/client/preview/types'; - -export type Test = (options: { - story: IStorybookStory; - context: StoryContext; - renderShallowTree: RenderTree; - renderTree: RenderTree; - snapshotFileName: string; -}) => undefined | void | Promise; - -export type RenderTree = ( - story: IStorybookStory, - context: StoryContext, - options?: SnapshotOptions, -) => undefined | void | Promise; - -export interface SnapshotOptionsObject { - createNodeMock?: (element: any) => any; -} - -export interface SnapshotOptionsFn { - (story: IStorybookStory): SnapshotOptionsObject; -} - -export type SnapshotOptions = SnapshotOptionsObject | SnapshotOptionsFn; - -export interface StoryContext { - kind: string; - story: string; -} - -export function multiSnapshotWithOptions(options: SnapshotOptions): Test; - -export const shallowSnapshot: Test; - -export const snapshot: Test; - -export function snapshotWithOptions(options: SnapshotOptions): Test; - -export const renderOnly: Test; - -export function renderWithOptions(options?: SnapshotOptions): Test; - -export function getSnapshotFileName(context: StoryContext): string; - -export default function initStoryshots( - // tslint:disable-next-line no-unnecessary-generics - options?: InitOptions, -): void; - -export interface InitOptions { - configPath?: string; - suite?: string; - storyKindRegex?: RegExp; - storyNameRegex?: RegExp; - framework?: string; - test?: Test; - renderer?: (node: JSX.Element) => Rendered; - serializer?: (rendered: Rendered) => any; - integrityOptions?: {}; -} - -export {}; diff --git a/types/storybook__addon-storyshots/package.json b/types/storybook__addon-storyshots/package.json deleted file mode 100644 index 59d1bb7a55..0000000000 --- a/types/storybook__addon-storyshots/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "@storybook/react": "^5.2.0" - } -} diff --git a/types/storybook__addon-storyshots/storybook__addon-storyshots-tests.ts b/types/storybook__addon-storyshots/storybook__addon-storyshots-tests.ts deleted file mode 100644 index e7c8905b88..0000000000 --- a/types/storybook__addon-storyshots/storybook__addon-storyshots-tests.ts +++ /dev/null @@ -1,96 +0,0 @@ -import initStoryshots, { - getSnapshotFileName, - multiSnapshotWithOptions, - renderOnly, - renderWithOptions, - snapshotWithOptions, -} from "@storybook/addon-storyshots"; -import { shallow, ShallowWrapper } from 'enzyme'; -import toJson from 'enzyme-to-json'; -import 'jest'; -import 'jest-specific-snapshot'; - -initStoryshots(); - -initStoryshots({ - integrityOptions: { cwd: '' }, - test: multiSnapshotWithOptions({}), -}); - -initStoryshots({ - test: ({ story, context }) => { - const snapshotFileName = getSnapshotFileName(context); - const storyElement = story.render() as JSX.Element; - const shallowTree = shallow(storyElement); - - if (snapshotFileName) { - expect(toJson(shallowTree)).toMatchSpecificSnapshot(snapshotFileName); - } - } -}); - -initStoryshots({ - configPath: "", - test: renderOnly -}); - -initStoryshots({ - configPath: "", - test: renderWithOptions() -}); - -initStoryshots({ - configPath: "", - test: renderWithOptions({ - createNodeMock: () => undefined, - }) -}); - -initStoryshots({ - configPath: '', - test: renderWithOptions(story => ({ - createNodeMock: () => { - story.name; - return undefined; - }, - })), -}); - -initStoryshots({ - framework: 'react', - configPath: '', - test: snapshotWithOptions({ - createNodeMock: (element) => { - if (element.type === 'div') { - return { scrollWidth: 123 }; - } - return null; - } - }) -}); - -initStoryshots({ - configPath: 'config/storybook', - suite: 'storybook snapshots', - storyNameRegex: /^(?!NOTEST )/, - test: function renderWithoutSnapshotting({ story, context, renderTree }) { - const result = renderTree(story, context, { createNodeMock }); - const unmount = (tree: any) => typeof tree.unmount === 'function' && tree.unmount(); - return result instanceof Promise ? result.then(unmount) : unmount(result); - - function createNodeMock() { - return { - addEventListener: () => undefined, - getClientRects: () => [], - getBoundingClientRect: () => ({}), - getElementsByClassName: () => [], - }; - } - }, -}); - -// Ensure renderer is compatible with serializer -initStoryshots({ - renderer: shallow, - serializer: toJson, -}); diff --git a/types/storybook__addon-storyshots/tsconfig.json b/types/storybook__addon-storyshots/tsconfig.json deleted file mode 100644 index ddb344e695..0000000000 --- a/types/storybook__addon-storyshots/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "dom", - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "paths": { - "@storybook/addon-storyshots": [ - "storybook__addon-storyshots" - ] - }, - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "esModuleInterop": true - }, - "files": [ - "index.d.ts", - "storybook__addon-storyshots-tests.ts" - ] -} diff --git a/types/storybook__addon-storyshots/tslint.json b/types/storybook__addon-storyshots/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/storybook__addon-storyshots/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" }