Best JavaScript code snippet using storybook-root
paths.test.ts
Source:paths.test.ts
1import path from 'path';2import { normalizeStoryPath } from '../paths';3describe('paths - normalizeStoryPath()', () => {4 it('returns a path starting with "./" unchanged', () => {5 const filename = `./src/Comp.story.js`;6 expect(normalizeStoryPath(filename)).toEqual(filename);7 });8 it('returns a path starting with "../" unchanged', () => {9 const filename = `../src/Comp.story.js`;10 expect(normalizeStoryPath(filename)).toEqual(filename);11 });12 it('adds "./" to a normalized relative path', () => {13 const filename = `src/Comp.story.js`;14 expect(normalizeStoryPath(filename)).toEqual(`./${filename}`);15 });16 it('adds "./" to a hidden folder', () => {17 const filename = `.storybook/Comp.story.js`;18 expect(normalizeStoryPath(filename)).toEqual(`./${filename}`);19 });20 it('adds "./" to a hidden file', () => {21 const filename = `.Comp.story.js`;22 expect(normalizeStoryPath(filename)).toEqual(`./${filename}`);23 });24 describe('windows paths', () => {25 it('returns a path starting with ".\\" unchanged', () => {26 const filename = `.\\src\\Comp.story.js`;27 expect(normalizeStoryPath(filename)).toEqual(filename);28 });29 it('returns a path starting with "..\\" unchanged', () => {30 const filename = `..\\src\\Comp.story.js`;31 expect(normalizeStoryPath(filename)).toEqual(filename);32 });33 it('adds ".{path.sep}" to a normalized relative path', () => {34 const filename = `src\\Comp.story.js`;35 expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);36 });37 it('adds ".{path.sep}" to a hidden folder', () => {38 const filename = `.storybook\\Comp.story.js`;39 expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);40 });41 it('adds ".{path.sep}" to a hidden file', () => {42 const filename = `.Comp.story.js`;43 expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);44 });45 });...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!