-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Better browser support #3421
Better browser support #3421
Conversation
1ba9ab4
to
32788e4
Compare
Generated by 🚫 dangerJS |
eda7e3e
to
6657d8e
Compare
6657d8e
to
6176556
Compare
Codecov Report
@@ Coverage Diff @@
## master #3421 +/- ##
=======================================
Coverage 64.04% 64.04%
=======================================
Files 177 177
Lines 6570 6570
Branches 4 4
=======================================
Hits 4208 4208
Misses 2361 2361
Partials 1 1 Continue to review full report at Codecov.
|
Suggestion: might make sense to release this as a patch (shouldn't break anything), so we can try it out on projects wanting to use |
I'm holding off on this one right before Jest 20 but it'll be one of the first PRs after that release I'm gonna look at :) |
Will it go into a 20.x release, or do we have to wait a couple of months for it? Browser compat for stub and assertion should be high, imo. It can replace chai and sinon and really take off for browser-side testing frameworks 😄 |
Let's do it! #yolo @skovhus what are the next steps? How close are we to renaming Jest matchers to expect? |
@cpojer Making a beta release (or patch) of this would help in order to test it out in older browsers. I can do that. Not sure about the Jest Matchers tasks, but the codemod is ready whenever the test repos can build. : ) |
@skovhus I published jest@19.2.0-alpha.993e64af which is the latest version of master. |
Cool. Let me try that out. : ) |
@cpojer It doesn't work yet due to
|
); | ||
const {browser} = require(pkgJsonPath); | ||
if (browser) { | ||
if (browser.indexOf(BUILD_ES5_DIR) !== 0) { |
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.
Can use String.prototype.startsWith
Need to add https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime as a dep for es5 builds? |
It should be auto loaded by Jest |
Jest isn't the runner though |
I guess we should embed it to the build-es5 builds. Don't have much time to look at this right now though. : ) |
Oh, right. In this case you need to add regenerator runtime to global scope as @SimenB said. |
So nothing should be done from Jest side? Without embedding it into the jest es5 bundles the package.json "browser" field seems a bit misleading. But it might be the right solution. |
Could you explicitly add regeneratorRuntime to the deps of the project you are testing and see if that unblocks you? |
It's already in deps, as that project uses npm 4. He needs to require/import it. |
@thymikee really? Is it part of installing |
Looks like this. Apparently we use |
Adding it globally will probably work. But this isn't that friendly an interface if we want Jest-matchers to be used for testing in browsers. |
Is async used a lot of places? Could consider not using it. |
Totally agree, we should find a way. |
* Add support for building es2015 versions of packages * Build ES2015 versions of relevant packages * Ensure no untranspiled code by linting build-es5 folders
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This should solve #3360 by adding support for building ES2015 version of Jest packages.
I've done this in an opt in fashion. So by adding
browser: "build-es5/..."
to thepackage.json
file for a package, the build step will run a babel ES2015 compilation of that package. I've started by doing this for all packages, but it slows down the build (and is not needed for half of the packages).Test plan
build-es5
for some of the packages. I've verified that these folder does not contain any non ES2015 code (likeconst
declarations).build-es5
folders (https://twitter.com/kenneth_skovhus/status/851913077104799748)I would like someone to review if more packages should be able to run in browsers.