UNPKG

orphic-cypress

Version:

Set of utilities and typescript transformers to cover storybook stories with cypress component tests

49 lines (48 loc) 1.31 kB
/** * @module transformers */ import * as ts from "typescript"; /** * Transform a typescript stories file by adding `executeCyTests` to the bottom * with all exports explicitly passed in and the default recreated to be passed * in as 'default' prop. * * In webpack, can use with ts-loader like so * ```ts * { * test: /\.[jt]sx?$/, * exclude: [/node_modules/], * use: [ * { * loader: "ts-loader", * options: { * happyPackMode: true, * transpileOnly: true, * ...(useIsolatedComponentFiles && { * getCustomTransformers: () => ({ * before: [transformIsolatedComponentFiles()], * }), * }), * }, * }, * ], * } * ``` * * To include mdx files as tests, add this to module rules * ```ts * { * test: /\.mdx$/, * use: [ * <above ts-loader config>, * { * loader: require.resolve("@storybook/mdx1-csf/loader"), * options: { skipCsf }, * }, * ], * }, * ``` * see {@link bundlers.cypressWebpackConfigMdx} for an abstraction to do just that, * as well as load non-story mdx and md files. */ export declare const transformIsolatedComponentFiles: (executeCyTestsLocation?: string, storyPattern?: string | RegExp) => ts.TransformerFactory<ts.SourceFile>;