-
Notifications
You must be signed in to change notification settings - Fork 400
Document the new test setup with Jest #2451
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. r+wc
I have some thoughts about yarn dev
and questions about the "defaults" for the tests, but everything looks good and I like the usage of yarn everywhere!
Maybe see about making jest test o
the actual default and addressing calling it the default in the docs? As I don't think it truly is.
| npm run unittest:run | Executes unittests (requires `unittest:server`) | | ||
| npm run servertest | Runs the servertests | | ||
* type `yarn` to install all dependencies | ||
* type `yarn dev:amo` to start a dev server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if yarn dev
should be the shortcut to start the AMO dev server given it's the main app here and what I'd venture most devs spend most of their time on.
Sort of unrelated to this change, I know, but just thinking aloud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting idea. I also wondered about us considering making the addons-frontend repo a single app and binning the separation between the disco pane and amo once admin is gone. It would remove a number of complications though we would need to retain them as separate entry points from a webpack perspective. That's a discussion for another time though.
adding test files or changing existing code. As you save each file, [jest][] | ||
will only run tests related to the code you change. | ||
* If you had typed `a` when you first started then [jest][] will continue to | ||
run the full suite even when you change specific files. Type `o` to switch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to launch in o
mode by default? That seems to be the best mode for development and it might be nice if yarn test
or even yarn test:dev
started in that mode without the interactive prompt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does sort of do that if you run watch without pressing anything, since it seems to look at what changed since the last commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to launch in o mode by default?
It does launch in this mode by default :) However, if you press the a
key (which intuitively is what I thought to do) then it will switch you out of the o
mode so just don't do that.
|
||
If you don't want to run the entire unit test suite, first you have to start a | ||
unittest server: | ||
By default, `yarn test` will only run a subset of tests that relate to the code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this isn't really true, right? By default yarn test
opens the prompt and doesn't really have a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned, that depends. It seems to default to running anything it finds since the last commit. But if there is nothing it just sits there waiting for a prompt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat. I didn't realise that. Might be worth quickly pointing that out in the docs then, but that sounds good.
Alternatively, you can start the test runner with a | ||
[specific file or regular expression](https://facebook.github.io/jest/docs/en/cli.html#jest-regexfortestfiles), | ||
like: | ||
```` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought these were usually three tildes for a block code section, not four.
README.md
Outdated
The uncovered lines will be shown in the right column but you can open | ||
the full report in a browser: | ||
|
||
open coverage/lcov-report/index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works on Mac OS, for what it's worth. Also might be nice to be consistent with block code style as the other ones use the tilde.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW looks like a "open coverage" key option will be available directly from jest in the not too distant.
README.md
Outdated
}; | ||
```` | ||
|
||
When you start up your front-end discover pane server, it will now apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "front-end Discovery Pane" instead of "discover pane".
README.md
Outdated
* Universal rendering via node | ||
* Unit tests with high coverage (aiming for 100%) | ||
|
||
[jest]: http://facebook.github.io/jest/docs/en/getting-started.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be only available under http
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, that's weird, GitHub pages I thought had HTTPS 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, that's weird, GitHub pages I thought had HTTPS 😞
Ah no you were right! For some reason I tried https://facebook.github.io/jest/docs/en/getting-started.html and got the http version, maybe that was the awesome bar correcting me if I'd been linked to that in the past? ¯\_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An https link works for me. Sure, I can change it.
### Starting the server | ||
|
||
Now that the component is setup we can run `npm start dev:search` and navigate to | ||
Now that the component is setup we can run `yarn dev:search` and navigate to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this page is very out of date since it still references the search app which is now admin (which we're likely deleting). But c'est la vie!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I would remove any references to search (and admin) since it won't work the app is called admin, and the app is very close to being deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole guide is based around the search app. I'm not going to spend time on updating it for this patch. TBH I was just replacing all instances of npm run
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I just sort of was pointing it out to keep in mind... no need to update it right now, there are other issues for that.
Sorry for the noise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw yarn dev:search
won't even run though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/mozilla/addons-frontend/issues/2223 would be a good place to fix up this guide
README.md
Outdated
* Node 6.x LTS | ||
* You need [Node](https://nodejs.org/) 6.x which is the current | ||
[LTS](https://github.com/nodejs/LTS) (long term support) release. | ||
* To make life easier, also install [yarn](https://yarnpkg.com/en/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're pushing yarn as the command runner and dep installer it would make sense to make it sound a bit less optional (or alternatively clarify how to run commands with npm run
in its place)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
ahhhh, cool :-)
|
Oh, yeah, it’ll do that.
|
Fixes mozilla/addons#10415