Specify code to run before any Jest setup happens

前端 未结 3 1011
春和景丽
春和景丽 2021-02-11 23:24

The tl;dr is:

1) How can I have Jest use the native require function to load all modules in my tests anywhere.

2) Where / how would I go about modif

3条回答
  •  醉酒成梦
    2021-02-12 00:04

    setupFiles worked for me. Add this in package.json:

    "jest": {
        "setupFiles": ["./my_file.js"]
      },
    

    https://jestjs.io/docs/en/configuration.html#setupfiles-array

提交回复
热议问题