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 smoke tests and harness #352

Closed
wants to merge 17 commits into from
Closed

Add smoke tests and harness #352

wants to merge 17 commits into from

Conversation

kangax
Copy link
Member

@kangax kangax commented Dec 21, 2016

TODO:

  • Make it possible to call multiple smoke() calls. Right now they're async.
  • Automate check for pass/fail (e.g. specify the phrase pattern for each project that denotes success)
  • Add support for passing Babili options
  • Use glob for when there's multiple files to minify
  • Test with both es2015 and without
  • Figure out why npm install in draft-js errors out (Error on npm install facebookarchive/draft-js#891)
  • Figure out how to test React (either dist or non-dist files)
  • Figure out why npm install output is not piped to stdout
  • Test Babel repo itself (seems pretty involved; unsure what to minify)
  • Do reverse check that minified code is being tested; introduce bug in minifier and ensure test fails
  • Add caching (so that we don't run npm run build etc. if it was just built)
  • Add support for multiple passes of minification?
  • Being able to see exactly which plugins result in faulty minification (this could be a time-consuming process though, not sure how to make it work)
  • Add vue.js

@kangax
Copy link
Member Author

kangax commented Dec 21, 2016

@sebmarkbage @gaearon quick question: it looks like React doesn't use build/react.js (or others) for testing? What would I need to minify to ensure tests still pass with minified distribution file?

@gaearon
Copy link
Member

gaearon commented Dec 21, 2016

We can't run existing tests against the minified file easily because we import some internal modules in tests. We've been trying to do this less (as we're working on a Fiber rewrite) but we still do it in some places.

It would be nice to have a way to do it though. For example we could keep a whitelist of tests that are safe to run against the production bundle, and add a script that tells jest to use build/react(-dom).js (or react(-dom).min.js in production mode—which is what you’re interested in) for React and ReactDOM imports. But it's going to be quite a bit of work to figure out so I'm not sure if you're interested.

For a smoke test you could use these lines but run them against minified builds.

@kangax
Copy link
Member Author

kangax commented Dec 21, 2016

Thanks, Dan. Let me see what I can do with this.

@boopathi boopathi added the Tag: Internal Pull Request changing project internals - code that is NOT published label Dec 22, 2016
{
dir: "stylelint",
// files: "lib/**/*.js",
files: "lib/rules/declaration-block-properties-order/index.js",
Copy link
Member Author

Choose a reason for hiding this comment

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

@boopathi I think I found one example where mangler fails. Would be great if you could look into it (and/or check with your latest/local changes to the mangler). You can see it by running node smoke.js after pulling git submodules (git submodule update --init --recursive, IIUC)

@kangax
Copy link
Member Author

kangax commented Dec 22, 2016

@bmaurer cc'ing you in case you have any ideas/suggestions for this smoke test harness (see current todo in the description).

My idea is basically to pull as many projects as possible, using git submodules (this way we can update them easily at any moment). Build those projects, minify them with Babili, then run unit tests, checking that everything still passes. We can eventually plug this into CI, making sure none of our bugfixes/additions introduce regressions.

This is still in early stages but is already looking promising. For example, I confirmed Immutable.js failing few tests. After applying a patch, the failures went away. So this smoke suite would've caught it earlier.

Current challenges are mostly related to figuring out what we need to minify for each project.

Let me know what you think!

@kangax
Copy link
Member Author

kangax commented Dec 22, 2016

This is great, I'm finding cases in "stylelint" where Babili makes it error out w/o "es2015" but not with "es2015" \o/

@kangax
Copy link
Member Author

kangax commented Jan 24, 2017

Hey @yyx990803, I apologize for summoning you out of the blue. I'm trying to run Vue as part of our smoke test harness and can't figure out which dist files are being used for tests. The idea is basically to minify Vue with our minifier and ensure all of Vue's unit tests still pass (essentially checking that minifier doesn't alter behavior).

@yyx990803
Copy link

@kangax the unit tests are actually run directly using source files (bundled on the fly with karma-webpack). Since it's using babel it's technically possible to enable babili in the process (probably should ignore test files for speed). Not sure if that'd be too much of a hassle.

The e2e tests are run against the examples folder which uses dist/vue.min.js - this file is first bundled with rollup + buble and then minified with uglifyjs. To substitute the file you can simply minify dist/vue.js with babili. The downside is dist/vue.js is already ES5 so it doesn't cover any ES201x cases. Alternatively you can use rollup + rollup-plugin-babel + babili to bundle from source. Once you have built dist/vue.min.js you can run the e2e tests with node test/e2e/runner.js.

@boopathi boopathi mentioned this pull request Apr 5, 2017
@boopathi boopathi closed this Apr 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tag: Internal Pull Request changing project internals - code that is NOT published
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants