Jest defaults to an outdated version of jsdom
.jsdom added support for
HTMLElement.dataset in a recent version. However, due to minimum node version support differences, Jest by default uses an older version of jsdom. Switching to the latest version though turned out to be fairly easy. I installed jest-environment-jsdom-latest and changed my
package.json to run jest with
"testEnvironment": "jsdom-latest". Alternatively I could have used
Steal Configs From elsewhere
It's really easy to run down the rabbit hole of learning everything about how to set up a tool before learning if you want to actually use it. To get started, I stole some of the config from an ejected
create-react-app application and looked at the docs for using jest with webpack. That was all I needed.
.resolves() for your promises
Unwrapping a promise and using
.resolves() allows me to easily unwrap promises and keep my expectation in a single chain. It feels as much like magic to me as promises did the first time I used them.
Overall, I'm excited to continue playing with Jest.