While tests run in source order, surrounding code does not which can lead to hard to debug issues.
Compare the test file below with the sample output below that and note the order of the log messages.
- Any code not inside of
it
,beforeAll
,afterAll
,beforeEach
orafterEach
runs immediately on initialisation. - This means code at the end of your file runs before even your before hooks.