How to use parseStaticDir method in storybook-root

Best JavaScript code snippet using storybook-root

server-statics.test.ts

Source:server-statics.test.ts Github

copy

Full Screen

...4import { parseStaticDir } from '../server-statics';5fs.pathExists = jest.fn().mockReturnValue(true);6describe('parseStaticDir', () => {7 it('returns the static dir/path and default target', async () => {8 await expect(parseStaticDir('public')).resolves.toEqual({9 staticDir: './public',10 staticPath: path.resolve('public'),11 targetDir: './',12 targetEndpoint: '/',13 });14 await expect(parseStaticDir('foo/bar')).resolves.toEqual({15 staticDir: './foo/bar',16 staticPath: path.resolve('foo/bar'),17 targetDir: './',18 targetEndpoint: '/',19 });20 });21 it('returns the static dir/path and custom target', async () => {22 await expect(parseStaticDir('public:/custom-endpoint')).resolves.toEqual({23 staticDir: './public',24 staticPath: path.resolve('public'),25 targetDir: './custom-endpoint',26 targetEndpoint: '/custom-endpoint',27 });28 await expect(parseStaticDir('foo/bar:/custom-endpoint')).resolves.toEqual({29 staticDir: './foo/bar',30 staticPath: path.resolve('foo/bar'),31 targetDir: './custom-endpoint',32 targetEndpoint: '/custom-endpoint',33 });34 });35 it.skipWindows('supports absolute file paths - posix', async () => {36 await expect(parseStaticDir('/foo/bar')).resolves.toEqual({37 staticDir: '/foo/bar',38 staticPath: '/foo/bar',39 targetDir: './',40 targetEndpoint: '/',41 });42 });43 it.onWindows('supports absolute file paths - windows', async () => {44 await expect(parseStaticDir('C:\\foo\\bar')).resolves.toEqual({45 staticDir: path.resolve('C:\\foo\\bar'),46 staticPath: path.resolve('C:\\foo\\bar'),47 targetDir: './',48 targetEndpoint: '/',49 });50 });51 it.skipWindows('supports absolute file paths with custom endpoint - posix', async () => {52 await expect(parseStaticDir('/foo/bar:/custom-endpoint')).resolves.toEqual({53 staticDir: '/foo/bar',54 staticPath: '/foo/bar',55 targetDir: './custom-endpoint',56 targetEndpoint: '/custom-endpoint',57 });58 });59 it.onWindows('supports absolute file paths with custom endpoint - windows', async () => {60 await expect(parseStaticDir('C:\\foo\\bar:/custom-endpoint')).resolves.toEqual({61 staticDir: expect.any(String), // can't test this properly on unix62 staticPath: path.resolve('C:\\foo\\bar'),63 targetDir: './custom-endpoint',64 targetEndpoint: '/custom-endpoint',65 });66 await expect(parseStaticDir('C:\\foo\\bar:\\custom-endpoint')).resolves.toEqual({67 staticDir: expect.any(String), // can't test this properly on unix68 staticPath: path.resolve('C:\\foo\\bar'),69 targetDir: './custom-endpoint',70 targetEndpoint: '/custom-endpoint',71 });72 });73 it('pins relative endpoint at root', async () => {74 const normal = await parseStaticDir('public:relative-endpoint');75 expect(normal.targetEndpoint).toBe('/relative-endpoint');76 const windows = await parseStaticDir('C:\\public:relative-endpoint');77 expect(windows.targetEndpoint).toBe('/relative-endpoint');78 });79 it('checks that the path exists', async () => {80 fs.pathExists = jest.fn().mockReturnValueOnce(false);81 await expect(parseStaticDir('nonexistent')).rejects.toThrow(path.resolve('nonexistent'));82 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1storiesOf('Button', module)2 .addDecorator(parseStaticDir)3 .add('with text', () => (4 ));5storiesOf('Button', module)6 .addDecorator(parseStaticDir)7 .add('with text', () => (8 ));9storiesOf('Button', module)10 .addDecorator(parseStaticDir)11 .add('with text', () => (12 ));13storiesOf('Button', module)14 .addDecorator(parseStaticDir)15 .add('with text', () => (16 ));17storiesOf('Button', module)18 .addDecorator(parseStaticDir)19 .add('with text', () => (20 ));21storiesOf('Button', module)22 .addDecorator(parseStaticDir)23 .add('with text', () => (24 ));25storiesOf('Button', module)26 .addDecorator(parseStaticDir)27 .add('with text', () => (28 ));29storiesOf('Button', module)30 .addDecorator(parseStaticDir)31 .add('with text', () => (32 ));33storiesOf('Button', module)34 .addDecorator(parseStaticDir)35 .add('with text', () => (36 ));37storiesOf('Button', module)38 .addDecorator(parseStaticDir)39 .add('with text', () => (40 ));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseStaticDir } from 'storybook-root-decorator';2import { configure } from '@storybook/react';3import { addDecorator } from '@storybook/react';4const staticDir = parseStaticDir();5addDecorator((story) => (6 <link rel="stylesheet" href={`${staticDir}/styles.css`} />7 {story()}8));9configure(require.context('../src', true, /\.stories\.js$/), module);10import { parseStaticDir } from 'storybook-root-decorator';11import { configure } from '@storybook/react';12import { addDecorator } from '@storybook/react';13const staticDir = parseStaticDir();14addDecorator((story) => (15 <link rel="stylesheet" href={`${staticDir}/styles.css`} />16 {story()}17));18configure(require.context('../src', true, /\.stories\.js$/), module);19import { parseStaticDir } from 'storybook-root-decorator';20import { configure } from '@storybook/react';21import { addDecorator } from '@storybook/react';22const staticDir = parseStaticDir();23addDecorator((story) => (24 <link rel="stylesheet" href={`${staticDir}/styles.css`} />25 {story()}26));27configure(require.context('../src', true, /\.stories\.ts$/), module);28import { parseStaticDir } from 'storybook-root-decorator';29import { configure } from '@storybook/react';30import { addDecorator } from '@storybook/react';31const staticDir = parseStaticDir();32addDecorator((story) => (33 <link rel="stylesheet" href={`${

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseStaticDir } from 'storybook-root-decorator';2const staticDir = parseStaticDir();3import { withRootDecorator } from 'storybook-root-decorator';4configure(5 require.context(6);7addDecorator(withRootDecorator(staticDir));8import { withRootDecorator } from 'storybook-root-decorator';9configure(10 require.context(11);12addDecorator(withRootDecorator(staticDir));13import { withRootDecorator } from 'storybook-root-decorator';14configure(15 require.context(16);17addDecorator(withRootDecorator(staticDir));18import { withRootDecorator } from 'storybook-root-decorator';19configure(20 require.context(21);22addDecorator(withRootDecorator(staticDir));23import { withRootDecorator } from 'storybook-root-decorator';24configure(25 require.context(26);27addDecorator(withRootDecorator(staticDir));28import { withRootDecorator } from 'storybook-root-decorator';29configure(

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseStaticDir } from 'storybook-root-decorator';2import { addDecorator } from '@storybook/react';3import { withInfo } from '@storybook/addon-info';4import { withKnobs } from '@storybook/addon-knobs';5import 'storybook-addon-jsx/register';6const req = require.context('../src', true, /\.stories\.js$/);7function loadStories() {8 req.keys().forEach(filename => req(filename));9}10addDecorator(withInfo);11addDecorator(withKnobs);12addDecorator(parseStaticDir);13configure(loadStories, module);14import React from 'react';15import { storiesOf } from '@storybook/react';16import { withInfo } from '@storybook/addon-info';17import { withKnobs } from '@storybook/addon-knobs';18import { staticDir } from 'storybook-root-decorator';19import MyComponent from './MyComponent';20storiesOf('MyComponent', module)21 .addDecorator(withInfo)22 .addDecorator(withKnobs)23 .add('Default', () => (24 image={`${staticDir}/images/my-image.png`}25 ));26module.exports = './public';27module.exports = './public';

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseStaticDir } = require('storybook-root-cause');2const { storybook } = require('./storybook');3(async () => {4 const { staticDir } = await storybook({5 });6 const staticDirPath = await parseStaticDir(staticDir);7 console.log(staticDirPath);8})();9module.exports = {10 stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],11 core: {12 },13};14module.exports = {15 stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],16 core: {17 },18};19module.exports = {20 stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],21 core: {22 },23};24const { parseStorybook } = require('storybook-root-cause');25const { storybook } = require('./storybook');26(async () => {27 const { staticDir } = await storybook({28 });29 const staticDirPath = await parseStorybook(staticDir);30 console.log(staticDirPath);31})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path')2const { parseStaticDir } = require('storybook-root-decorator')3module.exports = {4 stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],5 webpackFinal: async (config) => {6 config.module.rules.push({7 test: /\.(png|jpe?g|gif|svg)$/i,8 {9 options: {10 }11 }12 })13 config.module.rules.push({14 test: /\.(woff|woff2|eot|ttf|otf)$/i,15 {16 options: {17 }18 }19 })20 config.module.rules.push({21 })22 config.module.rules.push({23 })24 config.module.rules.push({25 })26 config.module.rules.push({27 })28 }29}30const { parseStaticDir } = require('storybook-root-decorator')31const path = require('path')32const config = {33 parameters: {34 actions: { argTypesRegex: '^on[A-Z].*' },35 docs: {

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