Skip to content
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

Add tests for CLI #1767

Merged
merged 28 commits into from
Sep 9, 2017
Merged

Add tests for CLI #1767

merged 28 commits into from
Sep 9, 2017

Conversation

Hypnosphi
Copy link
Member

@Hypnosphi Hypnosphi commented Aug 30, 2017

Fixes #1746

How to test

yarn bootstrap -- --core
yarn test:cli
yarn bootstrap -- --reset --core
nvm use 4
yarn test:cli

@Hypnosphi Hypnosphi changed the base branch from master to release/3.3 August 30, 2017 00:55
@Hypnosphi
Copy link
Member Author

Speaking of node 4/6 testing on CI, the trick is that we should bootstrap with node 8 (as it's the version we support for contributing), and then run tests with an older version. I tried to use some docker images with nvm, but had no success in that (see for instance https://circleci.com/gh/storybooks/storybook/9091).

@codecov
Copy link

codecov bot commented Aug 30, 2017

Codecov Report

Merging #1767 into release/3.3 will decrease coverage by 0.85%.
The diff coverage is 0%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release/3.3    #1767      +/-   ##
===============================================
- Coverage        23.32%   22.46%   -0.86%     
===============================================
  Files              281      321      +40     
  Lines             6045     6276     +231     
  Branches           706      789      +83     
===============================================
  Hits              1410     1410              
- Misses            4127     4269     +142     
- Partials           508      597      +89
Impacted Files Coverage Δ
lib/cli/test/snapshots/react_native/index.ios.js 0% <0%> (ø)
...react_native/storybook/stories/CenterView/style.js 0% <0%> (ø)
lib/cli/lib/has_yarn.js 0% <0%> (ø) ⬆️
...test/snapshots/react_native/storybook/storybook.js 0% <0%> (ø)
lib/cli/test/fixtures/meteor/client/main.js 0% <0%> (ø)
lib/cli/lib/detect.js 0% <0%> (ø) ⬆️
lib/cli/test/fixtures/sfc_vue/src/main.js 0% <0%> (ø)
...ib/cli/test/fixtures/react_native/index.android.js 0% <0%> (ø)
...already_has_storybook/src/registerServiceWorker.js 0% <0%> (ø)
...t_native/storybook/stories/Button/index.android.js 0% <0%> (ø)
... and 96 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8052c61...dad58b0. Read the comment docs.

"regenerator": true
}]
]
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hypnosphi Hypnosphi added cli help wanted maintenance User-facing maintenance tasks labels Aug 30, 2017
@ndelangen
Copy link
Member

Why do we have to test on older node versions?

@Hypnosphi
Copy link
Member Author

How about because node 4 is maintained until April 2018?

},
"repository": {
"type": "git",
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"pretest": "cd test && ./update_fixtures.sh",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set this up so this is a jest project, like how the examples/react-native-vanilla is set up?

This would allow running the tests along with all the other unit tests!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look

Copy link
Member Author

@Hypnosphi Hypnosphi Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the other unit tests!

These tests are not unit, they're end-to-end =)

},
"devDependencies": {
"check-node-version": "2.1.0",
"npx": "9.6.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere within our code? I can't find it in this diff.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for running fresh CR(N)A without installing globally (yarn create unfortunately does the global install): https://github.com/storybooks/storybook/blob/cac45b496463180d957780d5ca0a142321658626/lib/cli/test/update_fixtures.sh#L14

@@ -0,0 +1,41 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs tests?
I don't understand what's going on here.

Can't we write jest tests and run them in jest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this needs to be this way, we need a good documentation on what this code does, either in a readme.md or above code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can, but it's much easier to do those manipulations in bash then in js, plus it's straightforward to reproduce particular steps: you just copypaste them to your console. My inspiration were CRA's e2e tests: https://github.com/facebookincubator/create-react-app/tree/master/tasks

Copy link
Member Author

@Hypnosphi Hypnosphi Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a section to CONTRIBUTING.md, and some inline comments here

@Hypnosphi
Copy link
Member Author

I think the rest can be addressed in separate PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants