jeudi 16 mai 2019

Export beforeAll and afterAll in JEST

There are some files I am repeating this pattern:

beforeAll(() => {
    MockDate.set(1487076708000)
  })

  afterAll(() => {
    MockDate.reset()
  })


The only thing I am doing here, is to mock the date. I am wondering if there's a way to export into a helper these methods and then invoke it in the needed files.

Global beforeAll wouldn't work for me since I just need it for 4 or 5 files.

Thanks!

Aucun commentaire:

Enregistrer un commentaire