From 54a1c0c5f6e6cb9ca078c884c45447b95fada29f Mon Sep 17 00:00:00 2001 From: Filipp Riabchun Date: Sat, 23 Nov 2019 22:12:37 +0100 Subject: [PATCH 1/3] Fix image snapshots setup in official-storybook --- .../storyshots/storyshots-core/package.json | 1 + .../storyshots-core/src/api/index.ts | 4 +- .../src/api/snapshotsTestsTemplate.ts | 18 +++++---- .../src/frameworks/configure.ts | 18 ++++++--- .../storyshots-core/src/typings.d.ts | 1 + .../storyshots/storyshots-puppeteer/README.md | 5 +++ .../src/ImageSnapshotConfig.ts | 2 + .../storyshots-puppeteer/src/imageSnapshot.ts | 21 +++++++--- .../storyshots-image.runner.js | 2 +- examples/official-storybook/package.json | 3 ++ lib/api/src/version.ts | 2 +- lib/core/package.json | 2 +- lib/core/server.js | 2 + lib/core/src/client/preview/start.js | 2 +- .../server/preview/iframe-webpack.config.js | 32 ++-------------- .../src/server/preview/to-require-context.js | 30 +++++++++++++++ scripts/babel-jest.js | 2 +- yarn.lock | 38 +++++++++++++++---- 18 files changed, 123 insertions(+), 62 deletions(-) create mode 100644 lib/core/src/server/preview/to-require-context.js diff --git a/addons/storyshots/storyshots-core/package.json b/addons/storyshots/storyshots-core/package.json index 1c85a0800b72..7018d8c01134 100644 --- a/addons/storyshots/storyshots-core/package.json +++ b/addons/storyshots/storyshots-core/package.json @@ -35,6 +35,7 @@ "@jest/transform": "^24.9.0", "@storybook/addons": "5.3.0-beta.5", "@storybook/client-api": "5.3.0-beta.5", + "@storybook/core": "5.3.0-beta.5", "@types/glob": "^7.1.1", "@types/jest": "^24.0.16", "@types/jest-specific-snapshot": "^0.5.3", diff --git a/addons/storyshots/storyshots-core/src/api/index.ts b/addons/storyshots/storyshots-core/src/api/index.ts index 855a157c8241..e77be5ede88f 100644 --- a/addons/storyshots/storyshots-core/src/api/index.ts +++ b/addons/storyshots/storyshots-core/src/api/index.ts @@ -12,11 +12,11 @@ type TestMethod = 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll'; const methods: TestMethod[] = ['beforeAll', 'beforeEach', 'afterEach', 'afterAll']; function callTestMethodGlobals( - testMethod: { [key in TestMethod]?: Function } & { [key in string]: any } + testMethod: { [key in TestMethod]?: Function & { timeout?: number } } & { [key in string]: any } ) { methods.forEach(method => { if (typeof testMethod[method] === 'function') { - global[method](testMethod[method]); + global[method](testMethod[method], testMethod[method].timeout); } }); } diff --git a/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts b/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts index 84185930f765..55f197980b50 100644 --- a/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts +++ b/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts @@ -18,15 +18,19 @@ function snapshotTest({ item, asyncJest, framework, testMethod, testMethodParams context, ...testMethodParams, }) - ) + ), + testMethod.timeout ); } else { - it(name, () => - testMethod({ - story: item, - context, - ...testMethodParams, - }) + it( + name, + () => + testMethod({ + story: item, + context, + ...testMethodParams, + }), + testMethod.timeout ); } } diff --git a/addons/storyshots/storyshots-core/src/frameworks/configure.ts b/addons/storyshots/storyshots-core/src/frameworks/configure.ts index 7bdd0a5b2077..53e500186e45 100644 --- a/addons/storyshots/storyshots-core/src/frameworks/configure.ts +++ b/addons/storyshots/storyshots-core/src/frameworks/configure.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import glob from 'glob'; +import { toRequireContext } from '@storybook/core/server'; import { ClientApi } from './Loader'; import { StoryshotsOptions } from '../api/StoryshotsOptions'; @@ -64,9 +64,16 @@ function getConfigPathParts(input: string): Output { if (main) { const { stories = [] } = require.requireActual(main); - const result = stories.reduce((acc: string[], i: string) => [...acc, ...glob.sync(i)], []); - - output.stories = result; + output.stories = stories.map( + (pattern: string | { path: string; recursive: boolean; match: string }) => { + const { path: basePath, recursive, match } = toRequireContext(pattern); + return require.context( + path.resolve(configDir, basePath), + recursive, + new RegExp(match.slice(1, -1)) + ); + } + ); } return output; @@ -94,8 +101,7 @@ function configure( }); if (stories && stories.length) { - // eslint-disable-next-line global-require, import/no-dynamic-require - storybook.configure(() => stories.map(f => require(f)), false); + storybook.configure(stories, false); } } diff --git a/addons/storyshots/storyshots-core/src/typings.d.ts b/addons/storyshots/storyshots-core/src/typings.d.ts index 46e3fd86ed8f..65251d3abdd5 100644 --- a/addons/storyshots/storyshots-core/src/typings.d.ts +++ b/addons/storyshots/storyshots-core/src/typings.d.ts @@ -2,3 +2,4 @@ declare module 'global'; declare module 'jest-preset-angular/*'; declare module 'preact-render-to-json'; declare module 'react-test-renderer*'; +declare module '@storybook/core/server'; diff --git a/addons/storyshots/storyshots-puppeteer/README.md b/addons/storyshots/storyshots-puppeteer/README.md index 6a8d87d530d9..c56afe0132cd 100644 --- a/addons/storyshots/storyshots-puppeteer/README.md +++ b/addons/storyshots/storyshots-puppeteer/README.md @@ -196,6 +196,11 @@ initStoryshots({ }); ``` +### Specifying setup and tests timeout + +By default, `@storybook/addon-storyshots-puppeteer` uses 15 second timeouts for browser setup and test functions. +Those can be customized with `setupTimeout` and `testTimeout` parameters. + ### Integrate image storyshots with regular app You may want to use another Jest project to run your image snapshots as they require more resources: Chrome and Storybook built/served. diff --git a/addons/storyshots/storyshots-puppeteer/src/ImageSnapshotConfig.ts b/addons/storyshots/storyshots-puppeteer/src/ImageSnapshotConfig.ts index 2d835cd140ac..01a8ef2829b6 100644 --- a/addons/storyshots/storyshots-puppeteer/src/ImageSnapshotConfig.ts +++ b/addons/storyshots/storyshots-puppeteer/src/ImageSnapshotConfig.ts @@ -15,4 +15,6 @@ export interface ImageSnapshotConfig { getGotoOptions: (options: { context: Context; url: string }) => DirectNavigationOptions; customizePage: (page: Page) => Promise; getCustomBrowser: () => Promise; + setupTimeout: number; + testTimeout: number; } diff --git a/addons/storyshots/storyshots-puppeteer/src/imageSnapshot.ts b/addons/storyshots/storyshots-puppeteer/src/imageSnapshot.ts index 4d4b5e286a10..626f3b9e825c 100644 --- a/addons/storyshots/storyshots-puppeteer/src/imageSnapshot.ts +++ b/addons/storyshots/storyshots-puppeteer/src/imageSnapshot.ts @@ -1,4 +1,4 @@ -import puppeteer, { Browser, Page } from 'puppeteer'; +import { Browser, Page } from 'puppeteer'; import { toMatchImageSnapshot } from 'jest-image-snapshot'; import { logger } from '@storybook/node-logger'; import { constructUrl } from './url'; @@ -21,6 +21,8 @@ const defaultConfig: ImageSnapshotConfig = { getGotoOptions: noop, customizePage: asyncNoop, getCustomBrowser: undefined, + setupTimeout: 15000, + testTimeout: 15000, }; export const imageSnapshot = (customConfig: Partial = {}) => { @@ -33,6 +35,8 @@ export const imageSnapshot = (customConfig: Partial = {}) = getGotoOptions, customizePage, getCustomBrowser, + setupTimeout, + testTimeout, } = { ...defaultConfig, ...customConfig }; let browser: Browser; // holds ref to browser. (ie. Chrome) @@ -75,19 +79,22 @@ export const imageSnapshot = (customConfig: Partial = {}) = expect(image).toMatchImageSnapshot(getMatchOptions({ context, url })); }; + testFn.timeout = testTimeout; - testFn.afterAll = () => { + testFn.afterAll = async () => { if (getCustomBrowser && page) { - return page.close(); + await page.close(); + } else if (browser) { + await browser.close(); } - - return browser.close(); }; - testFn.beforeAll = async () => { + const beforeAll = async () => { if (getCustomBrowser) { browser = await getCustomBrowser(); } else { + // eslint-disable-next-line global-require + const puppeteer = require('puppeteer'); // add some options "no-sandbox" to make it work properly on some Linux systems as proposed here: https://github.com/Googlechrome/puppeteer/issues/290#issuecomment-322851507 browser = await puppeteer.launch({ args: ['--no-sandbox ', '--disable-setuid-sandbox', '--disable-dev-shm-usage'], @@ -97,6 +104,8 @@ export const imageSnapshot = (customConfig: Partial = {}) = page = await browser.newPage(); }; + beforeAll.timeout = setupTimeout; + testFn.beforeAll = beforeAll; return testFn; }; diff --git a/examples/official-storybook/image-snapshots/storyshots-image.runner.js b/examples/official-storybook/image-snapshots/storyshots-image.runner.js index 71df59607983..7f95e14267ef 100644 --- a/examples/official-storybook/image-snapshots/storyshots-image.runner.js +++ b/examples/official-storybook/image-snapshots/storyshots-image.runner.js @@ -20,7 +20,7 @@ if (!fs.existsSync(pathToStorybookStatic)) { } else { initStoryshots({ suite: 'Image snapshots', - storyKindRegex: /^Addons\|Storyshots/, + storyKindRegex: /^Addons\/Storyshots/, framework: 'react', configPath: path.join(__dirname, '..'), test: imageSnapshot({ diff --git a/examples/official-storybook/package.json b/examples/official-storybook/package.json index b6233edab039..5ebab2fc34a7 100644 --- a/examples/official-storybook/package.json +++ b/examples/official-storybook/package.json @@ -61,5 +61,8 @@ "ts-loader": "^6.0.0", "uuid": "^3.3.2", "webpack": "^4.33.0" + }, + "optionalDependencies": { + "puppeteer": "^2.0.0" } } diff --git a/lib/api/src/version.ts b/lib/api/src/version.ts index f424fc8d01d1..7ea61ab7e509 100644 --- a/lib/api/src/version.ts +++ b/lib/api/src/version.ts @@ -1 +1 @@ -export const version = '5.3.0-beta.3'; +export const version = '5.3.0-beta.5'; diff --git a/lib/core/package.json b/lib/core/package.json index 845376493f5e..f14e9acc3a27 100644 --- a/lib/core/package.json +++ b/lib/core/package.json @@ -66,7 +66,6 @@ "find-up": "^4.1.0", "fs-extra": "^8.0.1", "glob-base": "^0.3.0", - "glob-regex": "^0.3.2", "global": "^4.3.2", "html-webpack-plugin": "^4.0.0-beta.2", "inquirer": "^7.0.0", @@ -74,6 +73,7 @@ "ip": "^1.1.5", "json5": "^2.1.1", "lazy-universal-dotenv": "^3.0.1", + "micromatch": "^4.0.2", "node-fetch": "^2.6.0", "open": "^7.0.0", "pnp-webpack-plugin": "1.5.0", diff --git a/lib/core/server.js b/lib/core/server.js index be6f058f4b64..df31111fa934 100644 --- a/lib/core/server.js +++ b/lib/core/server.js @@ -2,6 +2,7 @@ const defaultWebpackConfig = require('./dist/server/preview/base-webpack.config' const serverUtils = require('./dist/server/utils/template'); const buildStatic = require('./dist/server/build-static'); const buildDev = require('./dist/server/build-dev'); +const toRequireContext = require('./dist/server/preview/to-require-context'); const managerPreset = require.resolve('./dist/server/manager/manager-preset'); @@ -11,4 +12,5 @@ module.exports = { ...buildStatic, ...buildDev, ...serverUtils, + ...toRequireContext, }; diff --git a/lib/core/src/client/preview/start.js b/lib/core/src/client/preview/start.js index dd979e68939b..2a622f023367 100644 --- a/lib/core/src/client/preview/start.js +++ b/lib/core/src/client/preview/start.js @@ -361,7 +361,7 @@ export default function start(render, { decorateStory } = {}) { }); } else { const exported = loadable(); - if (Array.isArray(exported) && !exported.find(obj => !obj.default)) { + if (Array.isArray(exported) && exported.every(obj => obj.default != null)) { currentExports = new Map(exported.map(fileExports => [fileExports, null])); } else if (exported) { logger.warn( diff --git a/lib/core/src/server/preview/iframe-webpack.config.js b/lib/core/src/server/preview/iframe-webpack.config.js index 59198cb07ff2..6ce4caa9c601 100644 --- a/lib/core/src/server/preview/iframe-webpack.config.js +++ b/lib/core/src/server/preview/iframe-webpack.config.js @@ -9,14 +9,11 @@ import CoreJSUpgradeWebpackPlugin from 'corejs-upgrade-webpack-plugin'; import VirtualModulePlugin from 'webpack-virtual-modules'; import resolveFrom from 'resolve-from'; -import toRegex from 'glob-regex'; -import globBase from 'glob-base'; import babelLoader from '../common/babel-loader'; -import { nodeModulesPaths, loadEnv } from '../config/utils'; -import { getPreviewHeadHtml, getPreviewBodyHtml } from '../utils/template'; - -const isObject = val => val != null && typeof val === 'object' && Array.isArray(val) === false; +import { loadEnv, nodeModulesPaths } from '../config/utils'; +import { getPreviewBodyHtml, getPreviewHeadHtml } from '../utils/template'; +import { toRequireContextString } from './to-require-context'; const reactPaths = {}; try { @@ -26,27 +23,6 @@ try { // } -const toRequireContext = input => { - switch (true) { - case typeof input === 'string': { - const { base, glob } = globBase(input); - const regex = toRegex(glob) - .toString() - .replace('^([^\\/]+)', ''); - - return `require.context('${base}', true, ${regex})`; - } - case isObject(input): { - const { path: p, recursive: r, match: m } = input; - return `require.context('${p}', ${r}, ${m})`; - } - - default: { - throw new Error('the provided input cannot be transformed into a require.context'); - } - } -}; - export default ({ configDir, babelOptions, @@ -77,7 +53,7 @@ export default ({ [path.resolve(path.join(configDir, `generated-entry.js`))]: ` import { configure, addDecorator, addParameters } from '@storybook/${framework}'; - configure([${stories.map(toRequireContext).join(',')} + configure([${stories.map(toRequireContextString).join(',')} ], module); `, }) diff --git a/lib/core/src/server/preview/to-require-context.js b/lib/core/src/server/preview/to-require-context.js new file mode 100644 index 000000000000..1a5bf611e8d0 --- /dev/null +++ b/lib/core/src/server/preview/to-require-context.js @@ -0,0 +1,30 @@ +import globBase from 'glob-base'; +import { makeRe } from 'micromatch'; + +const isObject = val => val != null && typeof val === 'object' && Array.isArray(val) === false; +export const toRequireContext = input => { + switch (true) { + case typeof input === 'string': { + const { base, glob } = globBase(input); + const regex = makeRe(glob) + .toString() + // webpack prepends the relative path with './' + .replace(/^\/\^/, '/^\\.\\/') + .replace(/\?:\^/g, '?:'); + + return { path: base, recursive: glob.startsWith('**'), match: regex }; + } + case isObject(input): { + return input; + } + + default: { + throw new Error('the provided input cannot be transformed into a require.context'); + } + } +}; + +export const toRequireContextString = input => { + const { path: p, recursive: r, match: m } = toRequireContext(input); + return `require.context('${p}', ${r}, ${m})`; +}; diff --git a/scripts/babel-jest.js b/scripts/babel-jest.js index 5844aae3b18c..630e2f8033a0 100644 --- a/scripts/babel-jest.js +++ b/scripts/babel-jest.js @@ -2,5 +2,5 @@ const path = require('path'); const babelJest = require('babel-jest'); module.exports = babelJest.createTransformer({ - configFile: path.resolve('.babelrc'), + configFile: path.resolve(__dirname, '../.babelrc'), }); diff --git a/yarn.lock b/yarn.lock index 28373599224e..65f9e0abc156 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13381,7 +13381,7 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -extract-zip@1.6.7: +extract-zip@1.6.7, extract-zip@^1.6.6: version "1.6.7" resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9" integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k= @@ -14648,11 +14648,6 @@ glob-promise@3.4.0: dependencies: "@types/glob" "*" -glob-regex@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/glob-regex/-/glob-regex-0.3.2.tgz#27348f2f60648ec32a4a53137090b9fb934f3425" - integrity sha512-m5blUd3/OqDTWwzBBtWBPrGlAzatRywHameHeekAZyZrskYouOGdNB8T/q6JucucvJXtOuyHIn0/Yia7iDasDw== - glob-to-regexp@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" @@ -15773,6 +15768,14 @@ https-proxy-agent@^2.2.1, https-proxy-agent@^2.2.3: agent-base "^4.3.0" debug "^3.1.0" +https-proxy-agent@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz#b8c286433e87602311b01c8ea34413d856a4af81" + integrity sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg== + dependencies: + agent-base "^4.3.0" + debug "^3.1.0" + https@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https/-/https-1.0.0.tgz#3c37c7ae1a8eeb966904a2ad1e975a194b7ed3a4" @@ -24185,7 +24188,7 @@ progress@^1.1.8: resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" integrity sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74= -progress@^2.0.0, progress@^2.0.3: +progress@^2.0.0, progress@^2.0.1, progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== @@ -24343,6 +24346,11 @@ proxy-addr@~2.0.4, proxy-addr@~2.0.5: forwarded "~0.1.2" ipaddr.js "1.9.0" +proxy-from-env@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" + integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4= + proxy-middleware@latest: version "0.15.0" resolved "https://registry.yarnpkg.com/proxy-middleware/-/proxy-middleware-0.15.0.tgz#a3fdf1befb730f951965872ac2f6074c61477a56" @@ -24528,6 +24536,20 @@ punycode@^1.2.4, punycode@^1.3.2, punycode@^1.4.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= +puppeteer@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-2.0.0.tgz#0612992e29ec418e0a62c8bebe61af1a64d7ec01" + integrity sha512-t3MmTWzQxPRP71teU6l0jX47PHXlc4Z52sQv4LJQSZLq1ttkKS2yGM3gaI57uQwZkNaoGd0+HPPMELZkcyhlqA== + dependencies: + debug "^4.1.0" + extract-zip "^1.6.6" + https-proxy-agent "^3.0.0" + mime "^2.0.3" + progress "^2.0.1" + proxy-from-env "^1.0.0" + rimraf "^2.6.1" + ws "^6.1.0" + purgecss@^1.4.0: version "1.4.1" resolved "https://registry.yarnpkg.com/purgecss/-/purgecss-1.4.1.tgz#d362e63eb1ed9dd1fa1554b9fd7accb8d54e56dc" @@ -32508,7 +32530,7 @@ ws@^5.1.1, ws@^5.2.0: dependencies: async-limiter "~1.0.0" -ws@^6.0.0, ws@^6.1.2, ws@^6.2.1: +ws@^6.0.0, ws@^6.1.0, ws@^6.1.2, ws@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb" integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA== From 76c3f3a6403aeeac6175a4d086c7b35c087f0d52 Mon Sep 17 00:00:00 2001 From: Filipp Riabchun Date: Mon, 25 Nov 2019 03:48:48 +0100 Subject: [PATCH 2/3] Use `global.__requireContext` directly --- addons/storyshots/storyshots-core/package.json | 1 + .../storyshots-core/src/frameworks/configure.ts | 10 ++++++++-- addons/storyshots/storyshots-core/src/typings.d.ts | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/storyshots/storyshots-core/package.json b/addons/storyshots/storyshots-core/package.json index 7018d8c01134..4b5555534e28 100644 --- a/addons/storyshots/storyshots-core/package.json +++ b/addons/storyshots/storyshots-core/package.json @@ -39,6 +39,7 @@ "@types/glob": "^7.1.1", "@types/jest": "^24.0.16", "@types/jest-specific-snapshot": "^0.5.3", + "babel-plugin-require-context-hook": "^1.0.0", "core-js": "^3.0.1", "glob": "^7.1.3", "global": "^4.3.2", diff --git a/addons/storyshots/storyshots-core/src/frameworks/configure.ts b/addons/storyshots/storyshots-core/src/frameworks/configure.ts index 53e500186e45..fd2689eb27d2 100644 --- a/addons/storyshots/storyshots-core/src/frameworks/configure.ts +++ b/addons/storyshots/storyshots-core/src/frameworks/configure.ts @@ -1,9 +1,13 @@ import fs from 'fs'; import path from 'path'; import { toRequireContext } from '@storybook/core/server'; +import registerRequireContextHook from 'babel-plugin-require-context-hook/register'; +import global from 'global'; import { ClientApi } from './Loader'; import { StoryshotsOptions } from '../api/StoryshotsOptions'; +registerRequireContextHook(); + const isFile = (file: string): boolean => { try { return fs.lstatSync(file).isFile(); @@ -67,8 +71,10 @@ function getConfigPathParts(input: string): Output { output.stories = stories.map( (pattern: string | { path: string; recursive: boolean; match: string }) => { const { path: basePath, recursive, match } = toRequireContext(pattern); - return require.context( - path.resolve(configDir, basePath), + // eslint-disable-next-line no-underscore-dangle + return global.__requireContext( + configDir, + basePath, recursive, new RegExp(match.slice(1, -1)) ); diff --git a/addons/storyshots/storyshots-core/src/typings.d.ts b/addons/storyshots/storyshots-core/src/typings.d.ts index 65251d3abdd5..f334e98658b3 100644 --- a/addons/storyshots/storyshots-core/src/typings.d.ts +++ b/addons/storyshots/storyshots-core/src/typings.d.ts @@ -3,3 +3,4 @@ declare module 'jest-preset-angular/*'; declare module 'preact-render-to-json'; declare module 'react-test-renderer*'; declare module '@storybook/core/server'; +declare module 'babel-plugin-require-context-hook/register'; From 3b8f00e27c129264f4012186cf63f2a2e53422ae Mon Sep 17 00:00:00 2001 From: Filipp Riabchun Date: Mon, 25 Nov 2019 03:50:43 +0100 Subject: [PATCH 3/3] fix version --- addons/storyshots/storyshots-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/storyshots/storyshots-core/package.json b/addons/storyshots/storyshots-core/package.json index 59bc58365259..b3d45aa99c40 100644 --- a/addons/storyshots/storyshots-core/package.json +++ b/addons/storyshots/storyshots-core/package.json @@ -35,7 +35,7 @@ "@jest/transform": "^24.9.0", "@storybook/addons": "5.3.0-beta.6", "@storybook/client-api": "5.3.0-beta.6", - "@storybook/core": "5.3.0-beta.5", + "@storybook/core": "5.3.0-beta.6", "@types/glob": "^7.1.1", "@types/jest": "^24.0.16", "@types/jest-specific-snapshot": "^0.5.3",