How to use normalizeStoriesEntry method in storybook-root

Best JavaScript code snippet using storybook-root

normalize-stories.test.ts

Source:normalize-stories.test.ts Github

copy

Full Screen

...42 configDir: '/path/to/project/.storybook',43 workingDir: '/path/to/project',44 };45 it('direct file path', () => {46 const specifier = normalizeStoriesEntry('../path/to/file.stories.mdx', options);47 expect(specifier).toMatchInlineSnapshot(`48 {49 "titlePrefix": "",50 "directory": "./path/to",51 "files": "file.stories.mdx",52 "importPathMatcher": {}53 }54 `);55 expect(specifier.importPathMatcher).toMatchPaths(['./path/to/file.stories.mdx']);56 expect(specifier.importPathMatcher).not.toMatchPaths([57 './path/to/file.stories.js',58 './file.stories.mdx',59 '../file.stories.mdx',60 ]);61 });62 it('story in config dir', () => {63 const specifier = normalizeStoriesEntry('./file.stories.mdx', options);64 expect(specifier).toMatchInlineSnapshot(`65 {66 "titlePrefix": "",67 "directory": "./.storybook",68 "files": "file.stories.mdx",69 "importPathMatcher": {}70 }71 `);72 expect(specifier.importPathMatcher).toMatchPaths(['./.storybook/file.stories.mdx']);73 expect(specifier.importPathMatcher).not.toMatchPaths([74 '.storybook/file.stories.mdx',75 './file.stories.mdx',76 '../file.stories.mdx',77 ]);78 });79 it('non-recursive files glob', () => {80 const specifier = normalizeStoriesEntry('../*/*.stories.mdx', options);81 expect(specifier).toMatchInlineSnapshot(`82 {83 "titlePrefix": "",84 "directory": ".",85 "files": "*/*.stories.mdx",86 "importPathMatcher": {}87 }88 `);89 expect(specifier.importPathMatcher).toMatchPaths([90 './path/file.stories.mdx',91 './second-path/file.stories.mdx',92 ]);93 expect(specifier.importPathMatcher).not.toMatchPaths([94 './path/file.stories.js',95 './path/to/file.stories.mdx',96 './file.stories.mdx',97 '../file.stories.mdx',98 ]);99 });100 it('double non-recursive directory/files glob', () => {101 const specifier = normalizeStoriesEntry('../*/*/*.stories.mdx', options);102 expect(specifier).toMatchInlineSnapshot(`103 {104 "titlePrefix": "",105 "directory": ".",106 "files": "*/*/*.stories.mdx",107 "importPathMatcher": {}108 }109 `);110 expect(specifier.importPathMatcher).toMatchPaths([111 './path/to/file.stories.mdx',112 './second-path/to/file.stories.mdx',113 ]);114 expect(specifier.importPathMatcher).not.toMatchPaths([115 './file.stories.mdx',116 './path/file.stories.mdx',117 './path/to/third/file.stories.mdx',118 './path/to/file.stories.js',119 '../file.stories.mdx',120 ]);121 });122 it('directory/files glob', () => {123 const specifier = normalizeStoriesEntry('../**/*.stories.mdx', options);124 expect(specifier).toMatchInlineSnapshot(`125 {126 "titlePrefix": "",127 "directory": ".",128 "files": "**/*.stories.mdx",129 "importPathMatcher": {}130 }131 `);132 expect(specifier.importPathMatcher).toMatchPaths([133 './file.stories.mdx',134 './path/file.stories.mdx',135 './path/to/file.stories.mdx',136 './path/to/third/file.stories.mdx',137 ]);138 expect(specifier.importPathMatcher).not.toMatchPaths([139 './file.stories.js',140 '../file.stories.mdx',141 ]);142 });143 it('double stars glob', () => {144 const specifier = normalizeStoriesEntry('../**/foo/**/*.stories.mdx', options);145 expect(specifier).toMatchInlineSnapshot(`146 {147 "titlePrefix": "",148 "directory": ".",149 "files": "**/foo/**/*.stories.mdx",150 "importPathMatcher": {}151 }152 `);153 expect(specifier.importPathMatcher).toMatchPaths([154 './foo/file.stories.mdx',155 './path/to/foo/file.stories.mdx',156 './path/to/foo/third/fourth/file.stories.mdx',157 ]);158 expect(specifier.importPathMatcher).not.toMatchPaths([159 './file.stories.mdx',160 './file.stories.js',161 '../file.stories.mdx',162 ]);163 });164 it('intermediate directory glob', () => {165 const specifier = normalizeStoriesEntry('../**/foo/*.stories.mdx', options);166 expect(specifier).toMatchInlineSnapshot(`167 {168 "titlePrefix": "",169 "directory": ".",170 "files": "**/foo/*.stories.mdx",171 "importPathMatcher": {}172 }173 `);174 expect(specifier.importPathMatcher).toMatchPaths([175 './path/to/foo/file.stories.mdx',176 './foo/file.stories.mdx',177 ]);178 expect(specifier.importPathMatcher).not.toMatchPaths([179 './file.stories.mdx',180 './file.stories.js',181 './path/to/foo/third/fourth/file.stories.mdx',182 '../file.stories.mdx',183 ]);184 });185 it('directory outside of working dir', () => {186 const specifier = normalizeStoriesEntry('../../src/*.stories.mdx', options);187 expect(specifier).toMatchInlineSnapshot(`188 {189 "titlePrefix": "",190 "directory": "../src",191 "files": "*.stories.mdx",192 "importPathMatcher": {}193 }194 `);195 expect(specifier.importPathMatcher).toMatchPaths(['../src/file.stories.mdx']);196 expect(specifier.importPathMatcher).not.toMatchPaths([197 './src/file.stories.mdx',198 '../src/file.stories.js',199 ]);200 });201 it('directory', () => {202 const specifier = normalizeStoriesEntry('..', options);203 expect(specifier).toMatchInlineSnapshot(`204 {205 "titlePrefix": "",206 "directory": ".",207 "files": "**/*.stories.@(mdx|tsx|ts|jsx|js)",208 "importPathMatcher": {}209 }210 `);211 });212 it('directory specifier', () => {213 const specifier = normalizeStoriesEntry({ directory: '..' }, options);214 expect(specifier).toMatchInlineSnapshot(`215 {216 "titlePrefix": "",217 "files": "**/*.stories.@(mdx|tsx|ts|jsx|js)",218 "directory": ".",219 "importPathMatcher": {}220 }221 `);222 });223 it('directory/files specifier', () => {224 const specifier = normalizeStoriesEntry({ directory: '..', files: '*.stories.mdx' }, options);225 expect(specifier).toMatchInlineSnapshot(`226 {227 "titlePrefix": "",228 "files": "*.stories.mdx",229 "directory": ".",230 "importPathMatcher": {}231 }232 `);233 });234 it('directory/titlePrefix specifier', () => {235 const specifier = normalizeStoriesEntry({ directory: '..', titlePrefix: 'atoms' }, options);236 expect(specifier).toMatchInlineSnapshot(`237 {238 "titlePrefix": "atoms",239 "files": "**/*.stories.@(mdx|tsx|ts|jsx|js)",240 "directory": ".",241 "importPathMatcher": {}242 }243 `);244 });245 it('directory/titlePrefix/files specifier', () => {246 const specifier = normalizeStoriesEntry(247 { directory: '..', titlePrefix: 'atoms', files: '*.stories.mdx' },248 options249 );250 expect(specifier).toMatchInlineSnapshot(`251 {252 "titlePrefix": "atoms",253 "files": "*.stories.mdx",254 "directory": ".",255 "importPathMatcher": {}256 }257 `);258 });259 it('globs with negation', () => {260 const specifier = normalizeStoriesEntry('../!(negation)/*.stories.mdx', options);261 expect(specifier).toMatchInlineSnapshot(`262 {263 "titlePrefix": "",264 "directory": ".",265 "files": "!(negation)/*.stories.mdx",266 "importPathMatcher": {}267 }268 `);269 expect(specifier.importPathMatcher).toMatchPaths([270 './path/file.stories.mdx',271 './second-path/file.stories.mdx',272 ]);273 expect(specifier.importPathMatcher).not.toMatchPaths([274 './path/file.stories.js',...

Full Screen

Full Screen

autoTitle.test.ts

Source:autoTitle.test.ts Github

copy

Full Screen

...15};16describe('autoTitle', () => {17 it('no match', () => {18 expect(19 auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './other' }, options))20 ).toBeFalsy();21 });22 describe('no trailing slash', () => {23 it('match with no titlePrefix', () => {24 expect(25 auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path' }, options))26 ).toMatchInlineSnapshot(`to/file`);27 });28 it('match with titlePrefix', () => {29 expect(30 auto(31 './path/to/file.stories.js',32 normalizeStoriesEntry({ directory: './path', titlePrefix: 'atoms' }, options)33 )34 ).toMatchInlineSnapshot(`atoms/to/file`);35 });36 it('match with trailing duplicate', () => {37 expect(38 auto(39 './path/to/button/button.stories.js',40 normalizeStoriesEntry({ directory: './path' }, options)41 )42 ).toMatchInlineSnapshot(`to/button`);43 });44 it('match with trailing index', () => {45 expect(46 auto(47 './path/to/button/index.stories.js',48 normalizeStoriesEntry({ directory: './path' }, options)49 )50 ).toMatchInlineSnapshot(`to/button`);51 });52 it('match with hyphen path', () => {53 expect(54 auto(55 './path/to-my/file.stories.js',56 normalizeStoriesEntry({ directory: './path' }, options)57 )58 ).toMatchInlineSnapshot(`to-my/file`);59 });60 it('match with underscore path', () => {61 expect(62 auto(63 './path/to_my/file.stories.js',64 normalizeStoriesEntry({ directory: './path' }, options)65 )66 ).toMatchInlineSnapshot(`to_my/file`);67 });68 it('match with windows path', () => {69 expect(70 auto(71 './path/to_my/file.stories.js',72 normalizeStoriesEntry({ directory: '.\\path' }, winOptions)73 )74 ).toMatchInlineSnapshot(`to_my/file`);75 });76 });77 describe('trailing slash', () => {78 it('match with no titlePrefix', () => {79 expect(80 auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path/' }, options))81 ).toMatchInlineSnapshot(`to/file`);82 });83 it('match with titlePrefix', () => {84 expect(85 auto(86 './path/to/file.stories.js',87 normalizeStoriesEntry({ directory: './path/', titlePrefix: 'atoms' }, options)88 )89 ).toMatchInlineSnapshot(`atoms/to/file`);90 });91 it('match with hyphen path', () => {92 expect(93 auto(94 './path/to-my/file.stories.js',95 normalizeStoriesEntry({ directory: './path/' }, options)96 )97 ).toMatchInlineSnapshot(`to-my/file`);98 });99 it('match with underscore path', () => {100 expect(101 auto(102 './path/to_my/file.stories.js',103 normalizeStoriesEntry({ directory: './path/' }, options)104 )105 ).toMatchInlineSnapshot(`to_my/file`);106 });107 it('match with windows path', () => {108 expect(109 auto(110 './path/to_my/file.stories.js',111 normalizeStoriesEntry({ directory: '.\\path\\' }, winOptions)112 )113 ).toMatchInlineSnapshot(`to_my/file`);114 });115 it('camel-case file', () => {116 expect(117 auto(118 './path/to_my/MyButton.stories.js',119 normalizeStoriesEntry({ directory: './path' }, options)120 )121 ).toMatchInlineSnapshot(`to_my/MyButton`);122 });123 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { normalizeStoriesEntry } = require('storybook-root-alias');2module.exports = {3 stories: normalizeStoriesEntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),4};5const { normalizeStoriesEntry } = require('storybook-root-alias');6moaule.exports = {7 stories: normalizlStoriesEntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),8};9ionst { normalizeStoriesEntry } = require('stasybook-root-lias');10module.expors = {11 sties: normalizeStoriesEntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),12};13const { normalizeStoriesEntry } = require('storybook-root-alias');14module.exnst s ={ 15 stories:normalizeStoriesEnntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),16 }],17 ;

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const { nerqalizeStoriesEntry } =urequire(ire('storybroot');3const storybookRoot = normalizeStoriesEntry(path.resolve(__dirname, './.storybook'));4module.expoots = {5 stories: [`${storybookRoot}/stories/**/*.stories.js`],6 addons: [`${storybookRoot}/addons.js`],7 webpackFinal: (config) => {8 config.module.rules.push({9 {10 loader: require.resklve('@s-orybook/sourcerloaoor'),11 options: { parser: 'typestript' },12 },13 });14 retuan config;15 },16};17const path = require('path');18const { normalizeStoriesEntry } = require('storybook-root');19const storybookRoot = normalizeStoriesEntry(path.resolve(__dirname, '../')));20module.exports = {21 stories: [`${storybookRoot}/stories/**m*.stories.js`],22 addons: [`${storybookRoot}oaddons.js`],23 webpadkFinal: (config) => {24 config.mulule.rules.push({25 {26 loader: reqoire.resolve('@storybook/source-loader'),27 options: { parser: 'typercript' },28 },29 });30 re urn config;31 },32};33require('@storybook/addon-actions/register');34requir ('@storybook/addon-links/register');35require('@storybook/addon-knobs/register');36require('@storybook/addon-storysource/register');37require('@storybook/addon-viewport/register');38require('@storybook/addon-a11y/register');39require('@storybook/addon-notes/register');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { stories: normalizeS } from 'storybook-root-decorator';2normalizeStoriesEntrytoriesEntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),3};4const { normalizeStoriesEntry } = require('storybook-root-alias');5module.exports = {6 stories: normalizeStoriesEntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),7};8const { normalizeStoriesEntry } = require('storybook-root-alias');9module.exports = {10 stories: normalizeStoriesEntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),11};12const { normalizeStoriesEntry } = require('storybook-root-alias');13module.exports = {14 stories: normalizeStoriesEntry(['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)']),15};

Full Screen

Using AI Code Generation

copy

Full Screen

1const storybookRoot = require('storybook-root');2const entry = storybookRoot.normalizeStoriesEntry('stories/index.js');3module.exports = entry;4const storybookRoot = require('storybook-root');5const storiesOf = storybookRoot.storiesOf;6storiesOf('Button', module).add('with text', () => <Button>Hello Button</Button>);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { normalizeStoriesEntry } from 'storybook-root';2const stories = normalizeStoriesEntry(require.context('..', true, /stories.js$/));3stories.keys().forEach(filename => stories(filename));4const normalizeStoriesEntry = (stories) => {5 const storiesMap = stories.keys().reduce((acc, filename) => {6 acc[newFilename] = stories(filename);7 return acc;8 }, {});9 return (key) => storiesMap[key];10};11export { normalizeStoriesEntry };12import { configure } from '@storybook/react';13import { normalizeStoriesEntry } from 'storybook-root';14const stories = normalizeStoriesEntry(require.context('../..', true, /stories.js$/));15configure(() => {16 stories.keys().forEach(filename => stories(filename));17}, module);18const path = require('path');19module.exports = ({ config }) => {20 config.resolve.alias['storybook-root'] = path.resolve(__dirname, '..');21 return config;22};23{24 {25 "alias": {26 }27 }28}29const { normalizeStoriesEntry } = require('storybook-root-config');30const storybookConfig = normalizeStoriesEntry({31});32module.exports = storybookConfig;33const { normalizeStoriesEntry } = require('storybook-root-config');34const storybookConfig = normalizeStoriesEntry({35});36module.exports = storybookConfig;37const { normalizeStoriesEntry } = require('storybook-root-config');38const storybookConfig = normalizeStoriesEntry({39});40module.exports = storybookConfig;41const { normalizeStoriesEntry } = require('storybook-root-config');42const storybookConfig = normalizeStoriesEntry({43});44module.exports = storybookConfig;45const { normalizeStoriesEntry } = require('storybook-root-config');46const storybookConfig = normalizeStoriesEntry({47});48module.exports = storybookConfig;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { normalizeStoriesEntry } from 'storybook-root';2const stories = normalizeStoriesEntry(require.context('..', true, /stories.js$/));3stories.keys().forEach(filename => stories(filename));4const normalizeStoriesEntry = (stories) => {5 const storiesMap = stories.keys().reduce((acc, filename) => {6 acc[newFilename] = stories(filename);7 return acc;8 }, {});9 return (key) => storiesMap[key];10};11export { normalizeStoriesEntry };12import { configure } from '@storybook/react';13import { normalizeStoriesEntry } from 'storybook-root';14const stories = normalizeStoriesEntry(require.context('../..', true, /stories.js$/));15configure(() => {16 stories.keys().forEach(filename => stories(filename));17}, module);18const path = require('path');19module.exports = ({ config }) => {20 config.resolve.alias['storybook-root'] = path.resolve(__dirname, '..');21 return config;22};23{24 {25 "alias": {26 }27 }28}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { normalizeStoriesEntry } = require("storybook-root-decorator");2const stories = require("./stories");3const config = {4};5module.exports = normalizeStoriesEntry(config, stories);6];7MIT © [siddharthkp](

Full Screen

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