This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It seems to work with Create React App 2. Flawlessly even.
- Loading branch information
Showing
11 changed files
with
1,379 additions
and
2,559 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { configure, addDecorator } from '@storybook/react'; | ||
import { RootThemeProvider } from '../src/components/App/RootThemeProvider'; | ||
import './styles.css'; | ||
|
||
const themeDecorator = story => ( | ||
<RootThemeProvider>{story()}</RootThemeProvider> | ||
); | ||
addDecorator(themeDecorator); | ||
|
||
// This condition actually should detect if it's an Node environment | ||
// https://stackoverflow.com/questions/38332094/how-can-i-mock-webpacks-require-context-in-jest/42191018#42191018 | ||
if (typeof require.context === 'undefined') { | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
require.context = ( | ||
base = '.', | ||
scanSubDirectories = false, | ||
regularExpression = /\.js$/ | ||
) => { | ||
const files = {}; | ||
|
||
function readDirectory(directory) { | ||
fs.readdirSync(directory).forEach(file => { | ||
const fullPath = path.resolve(directory, file); | ||
|
||
if (fs.statSync(fullPath).isDirectory()) { | ||
if (scanSubDirectories) readDirectory(fullPath); | ||
|
||
return; | ||
} | ||
|
||
if (!regularExpression.test(fullPath)) return; | ||
|
||
files[fullPath] = true; | ||
}); | ||
} | ||
|
||
readDirectory(path.resolve(__dirname, base)); | ||
|
||
function Module(file) { | ||
return require(file); | ||
} | ||
|
||
Module.keys = () => Object.keys(files); | ||
|
||
return Module; | ||
}; | ||
} | ||
|
||
const req = require.context('../src', true, /\.stories\.tsx$/); | ||
|
||
configure(() => { | ||
req.keys().forEach(filename => req(filename)); | ||
}, module); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import initStoryshots, { renderOnly } from '@storybook/addon-storyshots'; | ||
|
||
const configPath = './storybook'; | ||
const configPath = './.storybook'; | ||
initStoryshots({ suite: 'Smoke StoryShots', configPath, test: renderOnly }); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.