Skip to content

Commit

Permalink
Enhance jest and storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
jupl committed Jul 22, 2020
1 parent 83caf7a commit bd2900b
Show file tree
Hide file tree
Showing 8 changed files with 1,030 additions and 585 deletions.
6 changes: 5 additions & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"coveragePathIgnorePatterns": ["/node_modules/", "story", "stories"],
"moduleNameMapper": {
"^~/(.*)": "<rootDir>/$1"
},
"preset": "@jupl/ts",
"setupFiles": ["dotenv/config"],
"setupFilesAfterEnv": ["<rootDir>/test/setup.ts"],
"testPathIgnorePatterns": ["/node_modules/", "/\\.cache/"]
"testPathIgnorePatterns": ["/node_modules/", "/\\.cache/"],
"transformIgnorePatterns": [
"node_modules/(?!(@storybook/addon-storyshots)/)"
]
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint:fix": "yarn run lint:fix:file .",
"lint:fix:file": "yarn run lint:file --fix",
"server": "parcel serve src/+dist/*",
"server:story": "start-storybook -c story",
"server:story": "start-storybook -c story -p 9001",
"start": "yarn run build:prod",
"test": "jest",
"test:update": "yarn run test --update-snapshot",
Expand All @@ -30,6 +30,8 @@
"devDependencies": {
"@babel/core": "^7.10.5",
"@jupl/ts": "^0.8.0",
"@storybook/addon-knobs": "^5.3.19",
"@storybook/addon-storyshots": "^5.3.19",
"@storybook/react": "^5.2.8",
"@types/jest": "^26.0.5",
"@types/react": "^16.9.43",
Expand All @@ -39,12 +41,13 @@
"babel-preset-react-app": "^9.1.2",
"cross-env": "^7.0.2",
"eslint": "^7.5.0",
"jest": "^26.1.0",
"jest": "^25.5.4",
"jest-styled-components": "^7.0.2",
"parcel": "^2.0.0-nightly.341",
"postcss-modules": "^3.2.0",
"postcss-preset-env": "^6.7.0",
"prettier": "^2.0.5",
"react-test-renderer": "^16.13.1",
"trash-cli": "^3.0.0",
"ts-node": "^8.10.2",
"tsconfig-paths": "^3.9.0",
Expand Down
3 changes: 3 additions & 0 deletions src/__snapshots__/storyshots.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Main|App default 1`] = `"Hello, world."`;
2 changes: 1 addition & 1 deletion src/main/components/app/story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import {storiesOf} from '@storybook/react'
import React from 'react'
import {MainApp} from '.'

storiesOf('MainApp', module).add('default', () => <MainApp />)
storiesOf('Main|App', module).add('default', () => <MainApp />)
3 changes: 3 additions & 0 deletions src/storyshots.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import initStoryshots from '@storybook/addon-storyshots'

initStoryshots({configPath: 'story'})
2 changes: 2 additions & 0 deletions story/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const TSConfigPathsPlugin = require('tsconfig-paths-webpack-plugin')

type Configuration = import('webpack').Configuration

exports.addons = ['@storybook/addon-knobs/register']

exports.stories = [
'../src/**/story.tsx',
'../src/**/stories.tsx',
Expand Down
2 changes: 2 additions & 0 deletions story/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {withKnobs} from '@storybook/addon-knobs'
import {addDecorator} from '@storybook/react'
import React from 'react'
import {RecoilRoot} from 'recoil'
import {Normalize} from 'styled-normalize'

addDecorator(withKnobs)
addDecorator(storyFn => (
<>
<Normalize />
Expand Down
Loading

0 comments on commit bd2900b

Please sign in to comment.