-
Notifications
You must be signed in to change notification settings - Fork 44
Property 'toHaveStyle' does not exist on type 'JestMatchers<any>' #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It seems like referencing this library directly from within the jest config causes the types not to be loaded. I guess this is how jest & TypeScript together works, not sure if there is a way to automatically fix it. But a simple workaround is to point the script to a TypeScript file that just imports the library: Change from this: // jest.config.js
module.exports = {
// [...]
setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
}; To this: // jest.setupFilesAfterEnv.ts
import '@testing-library/jest-native/extend-expect' // jest.config.js
module.exports = {
// [...]
setupFilesAfterEnv: ['<rootDir>/jest.setupFilesAfterEnv.ts'],
}; |
Related: #7 One more thing worth mentioning (in case it wasn't obvious): Make sure the test setup file ends in |
it works, but it will cause |
That's correct. If your project is published and you want to only ship compiled source files (not tests or setup.ts), then you would need two separate |
This problem also happened with me when I added |
Closing as stale. @jorgeruvalcaba If the issue persists with the latest release v5.0.0. Please submit a new issue with minimal repro repository. For our convenience please use |
Have the same problem. Using |
@alexamy Please submit a new issue with minimal repro repository. For convenience please use examples/basic from React Native Testing Library as a base for the PR. |
New issue: #136 |
Try adding |
In my case, I just converted the // jest.config.js
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
...
} // jest.setup.ts
import '@testing-library/jest-dom' |
Uh oh!
There was an error while loading. Please reload this page.
I've just installed
jest-native
and when I try to usetoHaveStyle()
I got this error:This is the complete example:
How can I get rid off this error?
The text was updated successfully, but these errors were encountered: