Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Upgrades Jest to v24 #594

Merged
merged 7 commits into from
Apr 25, 2019
Merged

Upgrades Jest to v24 #594

merged 7 commits into from
Apr 25, 2019

Conversation

tinkertrain
Copy link
Collaborator

@tinkertrain tinkertrain commented Apr 24, 2019

Upgrades Jest to v24

Jest 24 is the latest version of the testing framework, we'd like to keep this dependency up-to-date.

More info here and changelog here

This version includes some support for typescript, but it is only traspilation through babel, so we will continue to use ts-jest, which gets upgraded in this PR too. Here's some context from that repo regarding Jest 24

Some minor changes to the jest config were necessary and for the most part things just worked.

I did find some issues with async/await tests, where I found a couple of problems, among them "regenerator runtime" not found. After searching for solutions I found a few issues that touched on this problem:

And some others.

The solution I came up with that fixed the issue was to add the babel plugin: @babel/plugin-transform-runtime but only to the 'test' environment to avoid including the runtime on our builds.

Other solutions that I read about was to update the babel configuration file, specifically the preset-env.target.node option to 'current', at the moment we have '8' and I assume we want to leave it like that, so I didn't try that (my node v is 8 anyways)

More info on babel and the runtime:

Watcher:

npm run test:

@coveralls
Copy link

coveralls commented Apr 24, 2019

Pull Request Test Coverage Report for Build 2056

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2054: 0.0%
Covered Lines: 7698
Relevant Lines: 7698

💛 - Coveralls

@@ -124,6 +124,7 @@
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.4.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm! I am suspicious about this one! I've had issues with this in the past. Checking out the compiled files now.. 🤞

Copy link
Contributor

@ItsJonQ ItsJonQ Apr 24, 2019

Choose a reason for hiding this comment

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

@tinkertrain Ugh... yea. It's what I feared.

Check out the babel compiled code:

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));

Prior to @babel/runtime, these functions were not dependencies.
With this set up.. that means that consuming integrations HAVE to also use @babel/runtime to compile things.

I remember running into these issues during the Brigade v1.x work.

Is there a way we can get Jest 24 set up, without @babel/runtime in .babelrc?

😊

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was afraid of something like that!

I have pushed a solution... feels a little bit like cheating...

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not cheating if it works! Haha

@plbabin plbabin mentioned this pull request Apr 24, 2019
@ItsJonQ
Copy link
Contributor

ItsJonQ commented Apr 24, 2019

Dang it Netlify! What's going on

@ItsJonQ
Copy link
Contributor

ItsJonQ commented Apr 24, 2019

@tinkertrain Thanks for making that babel update! Will check again in a sec :)

'emotion',
],
}
module.exports = api => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Much better 😎 . Take advantage of dat JS

Juan Pablo Lomeli Diaz added 2 commits April 24, 2019 17:14
@tinkertrain
Copy link
Collaborator Author

@netlify
Copy link

netlify bot commented Apr 24, 2019

Deploy preview for hsds-react ready!

Built with commit 5829b79

https://deploy-preview-594--hsds-react.netlify.com

Copy link
Contributor

@ItsJonQ ItsJonQ left a comment

Choose a reason for hiding this comment

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

🚀 Merged in latest master (the one with Storybook 5!). Resolved merge conflicts.

Tested Storybook dev + build. Tested Jest. Tested babel/TS build.

Things look like they're working as expected 😎

@ItsJonQ
Copy link
Contributor

ItsJonQ commented Apr 24, 2019

Oh darn. Netlify is struggling a bit again. Trying the build again (deleting cache + rebuild)

Copy link
Collaborator

@plbabin plbabin left a comment

Choose a reason for hiding this comment

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

🚀

@ItsJonQ
Copy link
Contributor

ItsJonQ commented Apr 25, 2019

Awesome! Thanks for the review all! And of course, big thanks to @tinkertrain 🚂 for making this upgrade 😍

@ItsJonQ ItsJonQ merged commit cb97577 into master Apr 25, 2019
@plbabin plbabin deleted the enhancement/upgrade-jest-24 branch April 27, 2020 14:07
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.

5 participants