Additional Globals
Explore the tools that Jest provides to help write and run our tests as efficiently as possible.
We'll cover the following...
Looking deeper into Jest globals
To help with writing and running our tests efficiently, Jest provides several additional globals that we can use. These globals allow us to do things like iterate over test cases and run only the test we are working on.
Additional functionality of describe
-
describe.each(table)(name, fn, timeout)
helps to abstract repetitive testing logic that just needs to be run with multiple data sets. The
tableargument is an array of arrays representing the data to pass to the anonymous function (
fn`) and ultimately for us to use in our individual tests. The name is still the descriptor for the test suite, i.e., function or component name, and we have an optional timeout again. -
describe.only(name, fn)
tells Jest ...