Remove @storybook/addon-storyshots types (#41583)

* [@storybook/addon-storyshots] remove typings as they're now provided by the package directly

TS migrate of the package was done in https://github.com/storybookjs/storybook/pull/7674

* [@storybook/addon-storyshots-puppeteer] remove typings as they're now provided by the package directly

TS migrate of the package was done in https://github.com/storybookjs/storybook/pull/7674
This commit is contained in:
Gaëtan Maisse
2020-01-15 03:47:02 -05:00
committed by Eli Barzilay
parent 05ce9387b2
commit dfbf2d1966
10 changed files with 12 additions and 281 deletions
+12
View File
@@ -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",
-28
View File
@@ -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 <https://github.com/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<void>;
getGotoOptions?: (ctx: Context) => DirectNavigationOptions;
customizePage?: (page: Page) => Promise<void>;
getCustomBrowser?: () => Promise<Browser>;
}
export function imageSnapshot(customConfig?: CustomConfig): ({ context }: { context: StoryContext }) =>
Promise<void>;
@@ -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' }),
}),
});
@@ -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"
]
}
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }
-70
View File
@@ -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 <https://github.com/bradleyayers>
// Yama-Tomo <https://github.com/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<void>;
export type RenderTree = (
story: IStorybookStory,
context: StoryContext,
options?: SnapshotOptions,
) => undefined | void | Promise<void>;
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<Rendered>(
// tslint:disable-next-line no-unnecessary-generics
options?: InitOptions<Rendered>,
): void;
export interface InitOptions<Rendered = any> {
configPath?: string;
suite?: string;
storyKindRegex?: RegExp;
storyNameRegex?: RegExp;
framework?: string;
test?: Test;
renderer?: (node: JSX.Element) => Rendered;
serializer?: (rendered: Rendered) => any;
integrityOptions?: {};
}
export {};
@@ -1,6 +0,0 @@
{
"private": true,
"dependencies": {
"@storybook/react": "^5.2.0"
}
}
@@ -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<ShallowWrapper>({
renderer: shallow,
serializer: toJson,
});
@@ -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"
]
}
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }