Skip to content

Use named import from pretty-format, not default#11360

Merged
SimenB merged 2 commits intojestjs:masterfrom
IanVS:pretty-format-named
Apr 30, 2021
Merged

Use named import from pretty-format, not default#11360
SimenB merged 2 commits intojestjs:masterfrom
IanVS:pretty-format-named

Conversation

@IanVS
Copy link
Copy Markdown
Contributor

@IanVS IanVS commented Apr 29, 2021

Summary

Similarly to #11359, I was trying to run expect in snowpack / webtestrunner, and got errors about

TypeError: (0 , _prettyFormat.default) is not a function

This is because pretty-format exports both a default export and named exports. This confuses babel+rollup, but it sounded like it was an intentional decision in #10515 to keep both. So, this PR does not remove the default export, but it changes all of the existing default imports throughout jest into named imports instead. This seems to compile to cjs in such a way that rollup can successfully turn it back into esm.

Test plan

Same as in #11359, I built jest and used it in my app, and the errors were resolved.

Comment thread packages/jest-diff/src/index.ts Outdated
import chalk = require('chalk');
import getType = require('jest-get-type');
import prettyFormat, {plugins as prettyFormatPlugins} from 'pretty-format';
import getType from 'jest-get-type';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rebasing on master should fix this

@IanVS IanVS force-pushed the pretty-format-named branch from 4f53048 to e5f10f7 Compare April 30, 2021 12:57
@IanVS
Copy link
Copy Markdown
Contributor Author

IanVS commented Apr 30, 2021

Hmmm, I rebased and I don't understand why one of the tests failed. Maybe it's a flakey test? I also don't think I can restart it.

@SimenB
Copy link
Copy Markdown
Member

SimenB commented Apr 30, 2021

Yep, looks like flake to me 👍

Copy link
Copy Markdown
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

👍

@SimenB SimenB merged commit 7c6cea2 into jestjs:master Apr 30, 2021
@IanVS IanVS deleted the pretty-format-named branch April 30, 2021 14:11
@IanVS
Copy link
Copy Markdown
Contributor Author

IanVS commented Apr 30, 2021

Thanks for the speedy reviews and merges! 🎉

@github-actions
Copy link
Copy Markdown

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants