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

Migrate select Jest options #100

Merged
merged 2 commits into from
Jun 23, 2020
Merged

Migrate select Jest options #100

merged 2 commits into from
Jun 23, 2020

Conversation

72636c
Copy link
Member

@72636c 72636c commented Jun 23, 2020

After many half-hearted attempts, I've finally mustered the will to get TypeScript ASTing. This extracts a blessed list of Jest options from the input jest.config.js and merges that with our base config. We also naively set the --coverage flag in package.json#/scripts/test when we see the collectCoverage option.


And yes, Jest configuration is JavaScript, but this may be a better investment if we end up doing something smart with .ts sources in future.

After many half-hearted attempts, I've finally mustered the will to get
TypeScript ASTing. This extracts a blessed list of Jest options from the
input `jest.config.js` and merges that with our base config. We also
naively set the `--coverage` flag in `package.json#/scripts/test` when
we see the `collectCoverage` option.
@72636c 72636c requested a review from a team as a code owner June 23, 2020 14:25
@changeset-bot
Copy link

changeset-bot bot commented Jun 23, 2020

🦋 Changeset is good to go

Latest commit: 80ef7d5

We got this.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

* ```
*/
const createModuleExportsExpression = (props: Props): ts.ExpressionStatement =>
ts.createExpressionStatement(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is kind of cute

rootNode,
(node) => {
if (
!ts.isExpressionStatement(node) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

This might read better if the whole thing was wrapped in a ! so the conditions were describing what a module export looks like instead of what it doesn’t

@72636c 72636c merged commit fe86bdf into master Jun 23, 2020
@72636c 72636c deleted the jest-migration branch June 23, 2020 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants