2022-11-28
|~1 min read
|148 words
Another entry for my Jest Tips collection! Today, we debug the mode. I frequently use Jest as a a test runner. Recently, however, I came…
2022-11-28
|~2 min read
|249 words
I like to write most of my code in Typescript these days, so when I had an opportunity to start a new project recently, I wanted to make…
2022-11-28
|~2 min read
|336 words
I recently added a feature to an app that scrolls the user to the top of page on navigation. Unfortunately, this started spewing errors in…
2022-11-28
|~1 min read
|53 words
A collection of tips on how to use Jest. A good follow up to the collection of configuration tips. Debugging ‘Not Implemented’ Errors…
2022-11-28
|~2 min read
|351 words
When testing code that you expect to fail with Jest, you need to wrap the function. This is called out explicitly in the docs. Note: You…
2022-11-28
|~1 min read
|84 words
From time to time, Jest’s test runner seems to be stuck on old code. In debugging it, I tried a number of different strategies, but…
2022-11-28
|~4 min read
|607 words
When it comes to testing your application, it’s often useful to know how much of your code is covered in one way or another by tests…
2022-11-28
|~2 min read
|397 words
To run Jest in watch mode, pass the option: By default, Jest will run tests against all changed files since the last commit, but watch mode…
2022-11-28
|~2 min read
|256 words
If you’re getting an unresolved module error like the one above from ESLint, it means that ESLint (and ESLint alone) is unable to resolve…
2022-11-28
|~3 min read
|457 words
While testing specific CSS styles within a unit test is rare, it’s not uncommon to want to know if the right class was applied to a…
2022-11-28
|~2 min read
|345 words
By default, Jest runs tests in a “browser-like” environment using jsdom. This, however, is configurable. For example, if you’re building a…
2022-11-28
|~2 min read
|311 words
If you are taking advantage of ES Modules, whether through a extension or babel transpilation, it’s likely that you’re using the / syntax…
2022-11-28
|~3 min read
|564 words
Jest is best known as a test runner, however, it can be used to run all sorts of things, including custom runners, Go, Python, etc. As part…
2022-11-28
|~2 min read
|268 words
Similar to other Jest plugins (e.g., typeahead), is meant to help make testing faster and easier. In the case of , the ideas is that a code…
2022-11-28
|~6 min read
|1041 words
In many React applications, there’s an component that is wrapped by a number of providers - themes, redux, routing, etc. When it comes to…
2022-11-28
|~9 min read
|1710 words
When it comes to testing UIs, there’s a lot to keep track of. Sometimes it can be helpful to just make sure that if a component changes, you…
2022-11-28
|~2 min read
|388 words
Update: A previous version of this post tried to resolve an absolute path for the mocks. This doesn’t work out of the box, so I’ve updated…
2022-11-28
|~2 min read
|394 words
A common pattern within Javascript applications is to use Webpack or Typescript to treat internal directories as modules so that they can be…
2022-11-28
|~1 min read
|195 words
In Debugging Node, I discussed how to use Node’s flag to debug a Node process. This is also really helpful for when we want to step through…
2022-11-28
|~3 min read
|418 words
One of those slightly annoying features of Jest’s watch mode is the regex pattern matching. It’s wonderful in how powerful it is, but it…
2022-11-28
|~2 min read
|365 words
CI/CD pipelines are designed to ensure that no broken code reaches the main branch.However, running all of the tests and compiling a project…
2022-11-28
|~5 min read
|815 words
Jest has a robust assertion library, but it’s also a general purpose tool. This can lead to some awkward tests, or imperative at least…
2022-11-28
|~2 min read
|259 words
A collection of posts on how to configure Jest to add various capabilities. Many of these posts are inspired by Kent C. Dodds’ Testing…
2022-11-28
|~5 min read
|885 words
Continuing my foray into becoming a better tester, today, I’m exploring the Test Object Factory. This pattern shares some similarities with…
2022-11-28
|~10 min read
|1834 words
When it comes to testing our code, it may be desireable to avoid following the normal code path all the way. Some examples of calls that we…
2022-11-28
|~5 min read
|974 words
How can you gain greater confidence that what you’re testing is what you intend? One solution is to automate away a lot of the noise with a…
2022-11-28
|~6 min read
|1034 words
What is a test? How do testing frameworks work? This post explores how different of a framework fit together and why they’re relevant. In…
2022-11-28
|~5 min read
|993 words
I hit some road blocks with recently which are motivating a refactoring with an eye toward reliability through testing.1 Since ’s primary…
2022-11-28
|~3 min read
|466 words
I was working recently on a project where a function would print to the console when it was executed. I was practicing writing more tests…
2022-11-28
|~2 min read
|388 words
Trying to run tests with Jest, I got the following error: Looking at the stack trace (in full at the end of this post), however, there were…