Skip to content

Add addon jest #2295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Nov 23, 2017
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f6df222
initial commit
renaudtertrais Nov 9, 2017
1db27cb
v0.0.1
renaudtertrais Nov 9, 2017
b1db164
Add new TODOS item + add know issue when deploying in README
renaudtertrais Nov 10, 2017
1433160
RENAME package & SYNC version with monorepo
ndelangen Nov 11, 2017
812c054
Merge branch 'master' into add-addon-jest
danielduan Nov 12, 2017
f1f869c
Remove eslint files and yarn.lock
renaudtertrais Nov 12, 2017
e66e375
Merge branch 'master' into add-addon-jest
ndelangen Nov 13, 2017
3af0b87
REMOVE dev setup on package && Linting
ndelangen Nov 13, 2017
f38a027
Linting
ndelangen Nov 13, 2017
37d3748
CHANGE jest config to exclude the example (failing) jest test for add…
ndelangen Nov 13, 2017
b4c0d31
lockfile
ndelangen Nov 14, 2017
758c195
Merge branch 'master' into add-addon-jest
ndelangen Nov 14, 2017
d004bd7
Merge branch 'master' into add-addon-jest
ndelangen Nov 14, 2017
3c8c783
FIX review comment
ndelangen Nov 14, 2017
1073760
Merge branch 'master' into add-addon-jest
danielduan Nov 14, 2017
d185d1a
Add addon-jest to examples/cra-kitchen-sink
renaudtertrais Nov 14, 2017
cc1eef2
Merge branch 'master' into add-addon-jest
ndelangen Nov 16, 2017
2d17ece
WIP
ndelangen Nov 16, 2017
b42538e
IMPROVE parsing of failureMessage
ndelangen Nov 17, 2017
e310ec2
IMPROVE styling & parsing of failureMessage
ndelangen Nov 18, 2017
3320ee3
Merge branch 'master' into add-addon-jest
Hypnosphi Nov 18, 2017
6648656
IMPROVE jest failureMessages
ndelangen Nov 18, 2017
663d5ae
Merge branch 'add-addon-jest' of github.com:storybooks/storybook into…
ndelangen Nov 18, 2017
ab0d84d
IMRPOVE styling
ndelangen Nov 18, 2017
d0d0494
Merge branch 'master' into add-addon-jest
Hypnosphi Nov 18, 2017
045bca1
REFACTOR to glamorous
ndelangen Nov 18, 2017
24b1982
no message
ndelangen Nov 18, 2017
1f2edf0
FIX links in readme
ndelangen Nov 19, 2017
6dbbb34
IMPROVE README
ndelangen Nov 19, 2017
793b76e
CLEANUP: remove unneeded component
ndelangen Nov 19, 2017
80bc824
IMPROVE readme
ndelangen Nov 21, 2017
d3ceba4
Merge branch 'master' into add-addon-jest
ndelangen Nov 21, 2017
59fff75
DELETE unneeded file
ndelangen Nov 21, 2017
7d95fae
Merge branch 'master' into add-addon-jest
ndelangen Nov 23, 2017
eb33a3e
CHANGE @storybook/addons to peerDependency && update versions
ndelangen Nov 23, 2017
7206c93
UPDATE snapshots
ndelangen Nov 23, 2017
9d83982
UPDATE snapshots
ndelangen Nov 23, 2017
70d3424
Merge branch 'master' into add-addon-jest
ndelangen Nov 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
IMPROVE README
  • Loading branch information
ndelangen committed Nov 19, 2017

Unverified

This user has not yet uploaded their public signing key.
commit 6dbbb344e22ad24442a3af089f33baf04842fa07
35 changes: 16 additions & 19 deletions addons/jest/README.md
Original file line number Diff line number Diff line change
@@ -34,33 +34,32 @@ Add it the result file to `.gitignore`:
.jest-test-results.json
```

**Known issue**: if you use a deploy script using for example `gh-pages`, be sure to not put
the `test` script that write the result in part of the script process (in `predeploy` for example).
Instead use a different script:
## Generating the test results

You should run jest before you start storybook and have the json file generated prior.
During development you will likely start jest in watch-mode
and so the json file will be re-generated every time code or tests change.

```sh
npm run test:generate-output -- --watch
```

This change will then be HMR (hot module reloaded) using webpack and displayed by this addon.

If you want to pre-run jest automaticly during development or a static build,
you may need to consider that if your tests fail, the script receives a non-0 exit code and will exit.
You could create a `prebuild:storybook` npm script, which will never fail by appending `|| true`:
```json
"scripts": {
"test:output": "jest --json --outputFile=.jest-test-results.json",
"test:generate-output": "jest --json --outputFile=.jest-test-results.json || true",
"test": "jest",
"prebuild:storybook": "npm run test",
"prebuild:storybook": "npm run test:generate-output",
"build:storybook": "build-storybook -c .storybook -o build/",
"predeploy": "npm run build:storybook",
"deploy": "gh-pages -d build/",
}
```

Then in dev use:

```sh
npm run test:output -- --watch
```

When deploying:

```sh
npm run deploy
```

### Register

Register addon at `.storybook/addons.js`
@@ -113,8 +112,6 @@ import '@storybook/addon-jest/register';
import '@storybook/addon-jest/styles';
```

If you already use `storybook-readme` addon, you do not need to import it.

## TODO

- [ ] Add coverage