Jest run async function ONCE before all tests

后端 未结 4 1141
名媛妹妹
名媛妹妹 2021-02-05 02:45

I want to use jest for my server unit testing (instead of mocha+chai). Is there a way I can run async function before all tests start (init purposes) only once and not for every

4条回答
  •  日久生厌
    2021-02-05 03:18

    If you execute jest tests with npm you can run any node command or any executable before executing other command

    "scripts": {
        "test": "node setup.js && jest"
      }
    

    so now you can run this with command

    $ npm t
    

提交回复
热议问题