Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit b25fc82

Browse files
committed
🚧 Attempts and fails to add storyshots
I'm going to have to call in the big guns.
1 parent 70d010d commit b25fc82

File tree

6 files changed

+67
-17
lines changed

6 files changed

+67
-17
lines changed

‎.storybook/config.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { configure } from '@storybook/react'
1+
// switched to commonjs, but this should work fine with ts too
2+
const { configure } = require('@storybook/react')
23

34
const req = require.context('../src', true, /story\.tsx?$/)
45

‎.storybook/webpack.config.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ module.exports = (config, env) => {
1010
exclude: /node_modules/,
1111
include: path.resolve(__dirname, '..', 'src'),
1212
})
13+
14+
// i tried adding url-loader and file-loader
15+
// but that only seems to break storybooks
16+
// rather than fix storyshots
1317

1418
myConfig.resolve.extensions.unshift('.tsx')
1519
myConfig.resolve.extensions.unshift('.ts')

‎package.json‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
"react-transition-group": "^2.2.1"
8080
},
8181
"devDependencies": {
82+
"@storybook/addon-actions": "^3.2.15",
83+
"@storybook/addon-links": "^3.2.15",
84+
"@storybook/addon-storyshots": "^3.2.15",
8285
"@storybook/react": "^3.2.15",
8386
"@types/electron-is-dev": "^0.3.0",
8487
"@types/electron-store": "^1.2.0",
@@ -92,19 +95,23 @@
9295
"coveralls": "^3.0.0",
9396
"electron": "^1.7.9",
9497
"electron-builder": "^19.45.4",
98+
"file-loader": "^1.1.5",
9599
"fuse-box": "^2.4.0",
96100
"husky": "^0.14.3",
97101
"jest": "^21.2.1",
98102
"jest-expect-contain-deep": "^1.0.1",
99103
"lint-staged": "^5.0.0",
100104
"npm-run-all": "^4.1.2",
101105
"prettier": "^1.8.2",
106+
"raf": "^3.4.0",
107+
"react-powerplug": "^0.1.2",
102108
"react-test-renderer": "^16.0.0",
103109
"ts-jest": "^21.2.1",
104110
"ts-loader": "^3.1.1",
105111
"ts-node": "^3.3.0",
106112
"tslint": "^5.8.0",
107-
"typescript": "~2.6.1"
113+
"typescript": "~2.6.1",
114+
"url-loader": "^0.6.2"
108115
},
109116
"jest": {
110117
"setupFiles": [
@@ -117,14 +124,15 @@
117124
"moduleFileExtensions": [
118125
"ts",
119126
"tsx",
120-
"js"
127+
"js",
128+
"json"
121129
],
122130
"coveragePathIgnorePatterns": [
123131
"/node_modules/",
124-
"/test/",
125132
"/out/",
126133
"/build/",
127134
"/dist/",
135+
"/test/",
128136
"/docs/"
129137
],
130138
"coverageThreshold": {

‎test/setup.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// import 'raf/polyfill'
2+
13
jest.mock('electron-window-state-manager', () => {
24
return jest.fn().mockImplementation(() => ({
35
saveState: jest.fn(),

‎test/storyshots.test.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// switched to js & common to rule out ts issues? should i don't think
2+
// it matters, the same error appears.
3+
const initStoryshots = require("@storybook/addon-storyshots").default
4+
5+
/**
6+
* Poor man's polyfill for raf.
7+
*/
8+
global.window = global
9+
window.addEventListener = () => {}
10+
window.requestAnimationFrame = () => {
11+
throw new Error("requestAnimationFrame is not supported in Node")
12+
}
13+
14+
/**
15+
* I believe we should be able to call initStoryshots() with just
16+
* the default parameters, but I was trying a few things to help
17+
* troubleshoot.
18+
*/
19+
const { resolve } = require("path")
20+
const configPath = resolve(__dirname, "..", ".storybook")
21+
initStoryshots({ configPath, framework: "react" })

‎yarn.lock‎

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
dependencies:
4444
"@storybook/addons" "^3.2.15"
4545

46+
"@storybook/addon-storyshots@^3.2.15":
47+
version "3.2.15"
48+
resolved "https://registry.yarnpkg.com/@storybook/addon-storyshots/-/addon-storyshots-3.2.15.tgz#98c26e0b429a4da03b0a5eeca12949af09c235b2"
49+
dependencies:
50+
babel-runtime "^6.26.0"
51+
global "^4.3.2"
52+
prop-types "^15.6.0"
53+
read-pkg-up "^3.0.0"
54+
4655
"@storybook/addons@^3.2.15":
4756
version "3.2.15"
4857
resolved "https://registry.yarnpkg.com/@storybook/addons/-/addons-3.2.15.tgz#120fc3e34454b9e6c779f25b945d354511168abc"
@@ -4818,7 +4827,7 @@ memorystream@^0.3.1:
48184827
version "0.3.1"
48194828
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
48204829

4821-
meow@^3.1.0, meow@^3.7.0:
4830+
meow@^3.1.0:
48224831
version "3.7.0"
48234832
resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb"
48244833
dependencies:
@@ -5130,14 +5139,6 @@ npm-run-path@^2.0.0:
51305139
dependencies:
51315140
path-key "^2.0.0"
51325141

5133-
npm-scripts-info@^0.3.6:
5134-
version "0.3.6"
5135-
resolved "https://registry.yarnpkg.com/npm-scripts-info/-/npm-scripts-info-0.3.6.tgz#14e7c78c1288bd6d82078769c7aa9583fc413c03"
5136-
dependencies:
5137-
chalk "^1.1.1"
5138-
meow "^3.7.0"
5139-
unquote "^1.1.0"
5140-
51415142
npm-which@^3.0.1:
51425143
version "3.0.1"
51435144
resolved "https://registry.yarnpkg.com/npm-which/-/npm-which-3.0.1.tgz#9225f26ec3a285c209cae67c3b11a6b4ab7140aa"
@@ -6032,6 +6033,12 @@ radium@^0.19.0:
60326033
inline-style-prefixer "^2.0.5"
60336034
prop-types "^15.5.8"
60346035

6036+
raf@^3.4.0:
6037+
version "3.4.0"
6038+
resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.0.tgz#a28876881b4bc2ca9117d4138163ddb80f781575"
6039+
dependencies:
6040+
performance-now "^2.1.0"
6041+
60356042
ramda@^0.25.0:
60366043
version "0.25.0"
60376044
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.25.0.tgz#8fdf68231cffa90bc2f9460390a0cb74a29b29a9"
@@ -6149,6 +6156,10 @@ react-modal@^3.1.2:
61496156
exenv "^1.2.0"
61506157
prop-types "^15.5.10"
61516158

6159+
react-powerplug@^0.1.2:
6160+
version "0.1.2"
6161+
resolved "https://registry.yarnpkg.com/react-powerplug/-/react-powerplug-0.1.2.tgz#070e97f7f064cf7a5e2f2db5d0003aae84adf1df"
6162+
61526163
react-simple-di@^1.2.0:
61536164
version "1.2.0"
61546165
resolved "https://registry.yarnpkg.com/react-simple-di/-/react-simple-di-1.2.0.tgz#dde0e5bf689f391ef2ab02c9043b213fe239c6d0"
@@ -6255,6 +6266,13 @@ read-pkg-up@^2.0.0:
62556266
find-up "^2.0.0"
62566267
read-pkg "^2.0.0"
62576268

6269+
read-pkg-up@^3.0.0:
6270+
version "3.0.0"
6271+
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07"
6272+
dependencies:
6273+
find-up "^2.0.0"
6274+
read-pkg "^3.0.0"
6275+
62586276
read-pkg@^1.0.0:
62596277
version "1.1.0"
62606278
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28"
@@ -7373,10 +7391,6 @@ unpipe@1.0.0, unpipe@~1.0.0:
73737391
version "1.0.0"
73747392
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
73757393

7376-
unquote@^1.1.0:
7377-
version "1.1.0"
7378-
resolved "https://registry.yarnpkg.com/unquote/-/unquote-1.1.0.tgz#98e1fc608b6b854c75afb1b95afc099ba69d942f"
7379-
73807394
unzip-response@^1.0.0:
73817395
version "1.0.2"
73827396
resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-1.0.2.tgz#b984f0877fc0a89c2c773cc1ef7b5b232b5b06fe"

0 commit comments

Comments
 (0)