vendredi 21 février 2020

expect(...).toHaveAttribute is not a function despite properly extending it

I have my test setup using jest and detox (@e2e)

Issue is, despite seemingly properly importing @testing-lib/jest-dom, I can't seem to use the toHaveAttribute() matcher as I should be able to.


Inside my spec.js file:

import { toHaveAttribute } from '@testing-library/jest-dom/matchers'
import '@testing-library/jest-dom/extend-expect'

expect.extend({
  toHaveAttribute,
})

// ... tests here

However, when running my tests, I get the following error:

TypeError: expect(...).toHaveAttribute is not a function

enter image description here

Aucun commentaire:

Enregistrer un commentaire