How to use webpackIncludeGlob method in storybook-root

Best JavaScript code snippet using storybook-root

to-importFn.ts

Source: to-importFn.ts Github

copy

Full Screen

1import dedent from 'ts-dedent';2import type { NormalizedStoriesSpecifier } from '../​types';3import { globToRegexp } from './​glob-to-regexp';4export function webpackIncludeRegexp(specifier: NormalizedStoriesSpecifier) {5 const { directory, files } = specifier;6 /​/​ It appears webpack passes *something* similar to the absolute path to the file7 /​/​ on disk (prefixed with something unknown) to the matcher.8 /​/​ We don't want to include the absolute path in our bundle, so we will just pull any leading9 /​/​ `./​` or `../​` off our directory and match on that.10 /​/​ It's imperfect as it could match extra things in extremely unusual cases, but it'll do for now.11 /​/​ NOTE: directory is "slashed" so will contain only `/​` (no `\`), even on windows12 const directoryWithoutLeadingDots = directory.replace(/​^(\.+\/​)+/​, '/​');13 const webpackIncludeGlob = ['.', '..'].includes(directory)14 ? files15 : `${directoryWithoutLeadingDots}/​${files}`;16 const webpackIncludeRegexpWithCaret = globToRegexp(webpackIncludeGlob);17 /​/​ picomatch is creating an exact match, but we are only matching the end of the filename18 return new RegExp(webpackIncludeRegexpWithCaret.source.replace(/​^\^/​, ''));19}20export function toImportFnPart(specifier: NormalizedStoriesSpecifier) {21 const { directory, importPathMatcher } = specifier;22 return dedent`23 async (path) => {24 if (!${importPathMatcher}.exec(path)) {25 return;26 }27 const pathRemainder = path.substring(${directory.length + 1});28 return import(29 /​* webpackChunkName: "[request]" */​30 /​* webpackInclude: ${webpackIncludeRegexp(specifier)} */​31 '${directory}/​' + pathRemainder32 );33 }34 `;35}36export function toImportFn(stories: NormalizedStoriesSpecifier[]) {37 return dedent`38 const importers = [39 ${stories.map(toImportFnPart).join(',\n')}40 ];41 export async function importFn(path) {42 for (let i = 0; i < importers.length; i++) {43 const moduleExports = await importers[i](path);44 if (moduleExports) {45 return moduleExports;46 }47 }48 }49 `;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { webpackIncludeGlob } from 'storybook-root-config';2import { configure, addDecorator } from '@storybook/​react';3import { withOptions } from '@storybook/​addon-options';4import { withKnobs } from '@storybook/​addon-knobs';5import { withA11y } from '@storybook/​addon-a11y';6import { withInfo } from '@storybook/​addon-info';7import { withNotes } from '@storybook/​addon-notes';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { configure } from '@storybook/​react';2import { webpackIncludeGlob } from 'storybook-root-decorator';3const req = webpackIncludeGlob(require.context('../​src/​components', true, /​\.stories\.js$/​));4function loadStories() {5 req.keys().forEach(filename => req(filename));6}7configure(loadStories, module);8import { configure } from '@storybook/​react';9import { webpackExcludeGlob } from 'storybook-root-decorator';10const req = webpackExcludeGlob(require.context('../​src/​components', true, /​\.stories\.js$/​));11function loadStories() {12 req.keys().forEach(filename => req(filename));13}14configure(loadStories, module);15import { rootDecorator } from 'storybook-root-decorator';16import { storiesOf } from '@storybook/​react';17storiesOf('MyComponent', module)18 .addDecorator(rootDecorator)19 .add('default', () => <MyComponent /​>);

Full Screen

Using AI Code Generation

copy

Full Screen

1{2 "compilerOptions": {3 "paths": {4 }5 }6}7{8 "scripts": {9 },10 "devDependencies": {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { webpackIncludeGlob } from 'storybook-root-config';2import path from 'path';3const rootPath = path.resolve(__dirname, '../​../​');4export const includePaths = webpackIncludeGlob(rootPath, ['src/​**/​*']);5const { includePaths } = require('../​test');6module.exports = {7};8import { configureWebpack } from 'storybook-root-config';9export const parameters = {10 actions: { argTypesRegex: '^on[A-Z].*' },11};12 (Story) => {13 return <Story /​>;14 },15];16export const webpackFinal = configureWebpack();

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Write End-To-End Tests Using Cypress App Actions

When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.

What will come after “agile”?

I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

Why does DevOps recommend shift-left testing principles?

Companies are using DevOps to quickly respond to changing market dynamics and customer requirements.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful