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

Group common jest config in to a preset #46953

Merged
merged 5 commits into from
Nov 3, 2020
Merged

Conversation

scinos
Copy link
Contributor

@scinos scinos commented Oct 30, 2020

Creates a jest preset to have the config for all packages in a common place.

After reading Jest docs and source code, there are a few points that have influenced this decision:

Testing instructions

  • Verify tests still pass

@scinos scinos requested a review from a team as a code owner October 30, 2020 13:49
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 30, 2020
@scinos scinos changed the base branch from master to try/dont-transpile-packages October 30, 2020 13:49
@scinos scinos requested review from a team as code owners October 30, 2020 13:49
@scinos scinos force-pushed the try/dont-transpile-packages branch from e00b567 to 8787b52 Compare October 30, 2020 13:50
@scinos scinos requested a review from a team October 30, 2020 13:51
@scinos scinos self-assigned this Oct 30, 2020
@matticbot
Copy link
Contributor

matticbot commented Oct 30, 2020

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Member

@sirbrillig sirbrillig left a comment

Choose a reason for hiding this comment

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

I don't fully understand the implications, but I don't have any objection WRT the composite-checkout package. The tests still pass, so I'm happy. Do you also need to convert the jest.config.js in packages/shopping-cart?

@jsnajdr
Copy link
Member

jsnajdr commented Oct 31, 2020

Do you also need to convert the jest.config.js in packages/shopping-cart?

Yes, the shopping-cart package should also use the new preset. I pushed the change in 704d376

Copy link
Member

@jsnajdr jsnajdr left a comment

Choose a reason for hiding this comment

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

The new common config works for me very well! 👍

By default, rootDir is __dirname, no need to specify it again

I tried to get rid of rootDir some time ago, but failed. It was because I was trying to extend a config from another module:

const commonPreset = require( '../common/jest.config.js' );
module.exports = {
  ...commonPreset,
  foo
}

But that didn't work and revealed a Jest bug. Extending the preset is much better!

@scinos
Copy link
Contributor Author

scinos commented Nov 3, 2020

Note: ICFY shows a reduction in bundle size but it is not real. It assumes this branch is targeting master, but it is not.

@jsnajdr
Copy link
Member

jsnajdr commented Nov 3, 2020

It assumes this branch is targeting master, but it is not.

That's true, ICFY always looks for a branching point from master and calculates the diff from there: https://github.com/Automattic/wp-calypso/blob/master/.github/workflows/icfy-stats.yml#L45

Base automatically changed from try/dont-transpile-packages to master November 3, 2020 08:13
@scinos scinos force-pushed the fix/jest-preset-for-packages branch from 704d376 to 84088c3 Compare November 3, 2020 08:17
@scinos scinos merged commit 6fa0fd1 into master Nov 3, 2020
@scinos scinos deleted the fix/jest-preset-for-packages branch November 3, 2020 09:02
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants