How to run it:
- Install Jest
npm i -g jest - Save
runOrder.test.jsin a folder (ensure it is named with.test.jsas a suffix) - Run
jestin that folder
- Any code not inside of
it,beforeAll,afterAll,beforeEachorafterEachruns immediately on initialisation.- This means code at the end of your file runs before even your before hooks.
- Code inside a
describeblock runs even if the block or file has no active tests.
*Allhooks wrap*Eachhooks, i.e.- For a given test all
beforeAllhooks will have run before the firstbeforeEachhook runs, regardless of the order in which they are defined and nested. - Similarly
afterAllhooks run after allafterEachhooks.
- For a given test all
async version of above, fwiw: https://gist.github.com/chuckplantain/8359063a1c025b5ccfce52b4f5707368