-
-
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
Add fake chalk in browser builds in order to support IE10 #4367
Conversation
* @flow | ||
*/ | ||
|
||
import ansiStyles from 'ansi-styles'; |
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 about doing a try-catch
around the normal chalk, and just create a fake one if it fails. But I don't think that matters?
@@ -48,6 +48,13 @@ function browserBuild(pkgName, entryPath, destination) { | |||
entry: entryPath, | |||
onwarn: () => {}, | |||
plugins: [ | |||
{ | |||
resolveId(id) { |
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.
inspired by rollup/rollup#661
Codecov Report
@@ Coverage Diff @@
## master #4367 +/- ##
======================================
Coverage 56.2% 56.2%
======================================
Files 191 191
Lines 6411 6411
Branches 6 6
======================================
Hits 3603 3603
Misses 2805 2805
Partials 3 3 Continue to review full report at Codecov.
|
As an alternative to this, could we use the previous version of Chalk? |
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.
Does the project have a browserstack or sauce labs account? Would be very nice to add this.
@@ -0,0 +1,14 @@ | |||
{ | |||
"name": "jest-fake-chalk", |
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.
Would it make sense to have this living outside the packages folder as it really isn't a package, but a stub used only in the browser build?
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.
then it's a bit messy plugging in dependencies, but I have no feelings on the matter
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 don't think browser support should block updates to modules that doesn't even work in the browser anyways.
I don't know... |
packages/jest-fake-chalk/.npmignore
Outdated
**/__mocks__/** | ||
**/__tests__/** | ||
src | ||
yarn.lock |
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.
rm
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.
Done (technically we can remove the whole file since this will not be published)
Nice, thanks for fixing this stuff. I would prefer not to create a separate package for it, and putting |
I can move it to expect, sure. Can we set up browserstack or something similar? |
Could we somehow mock out the environment in Jest? Could that be sufficient for now? |
I can confirm that using the Example of assertion error in the terminal: (Stack trace is different because of #4035) |
Awesome @SimenB!
Agree. |
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
Adds a new module
jest-fake-chalk
which mocks out the entirechalk
API in order forexpect
to work in older browsers.The implementation is a noop (just returns the string it got as input).
Closes #4074
(First commit is from #4366, so you can merge that and I'll rebase, or just merge this).
/cc @skovhus @mjackson
Test plan
./jest
and manually running browser test in IE10We should really look into getting browserstack or something set up!