jest-dom icon indicating copy to clipboard operation
jest-dom copied to clipboard

Fixes a bug where css.parse returns {} instead of a function

Open uzikilon opened this issue 5 years ago • 3 comments

What:

Replaces the way the CSS parse utility is imported

Why:

Fixes a bug where css.parse returns {} instead of a function in ts-jest

TypeError: (0 , _css.parse) is not a function

node : v13.2.0 "ts-jest: "^24.1.0", "@testing-library/jest-dom": "^4.2.4",

How:

Checklist:

  • [ ] Documentation "N/A"
  • [ ] Tests "N/A"
  • [ ] Updated Type Definitions "N/A"
  • [x] Ready to be merged

uzikilon avatar Dec 01 '19 08:12 uzikilon

@uzikilon can you expand a little bit more on how/when/where this bug happens? I'm checking the css lib documentation and I see that the recommended way to import it is from the module's default import and and not from a subpath. Maybe what we should do is import it like this instead:

import css from 'css'

// Then use it like this:
css.parse(...)

gnapse avatar Dec 02 '19 13:12 gnapse

The bug is a specific typescript issue, accrues any time we run toHaveStyle on a typescript test loaded with ts-jest.

This is more of a workaround than a solution. I suppose the real bug is in the CSS library and not jest-dom.

uzikilon avatar Dec 02 '19 14:12 uzikilon

Oh thanks, that clarifies it.

Could you raise the issue in that library without closing this one, and you can reference this issue over there? I'd rather not introduce these kind of ad-hoc workarounds here, at least not until we check if there's a fix at the source.

gnapse avatar Dec 02 '19 16:12 gnapse