Testing Setup
Learn about the different methods of setting up our Jest tests.
We'll cover the following...
What does test setup entail?
Test setup is a series of configurations and hooks that we defined, which create the environment we want to run our tests inside. Most software requires some added context to run. For instance, a server might require a seeded database, and a client might require user authentication. Both a server and a client may need additional packages installed in order to be testable with Jest. Test setup is where we get to do all of this.
Global setup
We can configure a global Jest setup through the Jest config file. In our Jest config, we have access to a globalSetup
field, which points to a string—the path to the file holding our global setup configuration. This file exports a function ...