-
Notifications
You must be signed in to change notification settings - Fork 306
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
Get rid of "Could not find angular material core theme" warning when using with angular-material #83
Comments
Thanks for your input! I'm fine with adding this to readme or better – to FAQ: #79 We could go with the format: FAQHere you'll find answers to frequently asked questions alongside with some common errors and how to fix them ErrorsCould not find Angular Material core themeFull error message:
-- your answer here -- |
Sure I'll add it to the FAQ. It's kind of an ugly solution and it'll break if they change the css selector but so far I haven't found a proper way of loading the angular material theme into jest at runtime. |
Yea, we can point out that this is just a workaround, and better solution is appreciated :D |
Actually better solution is provide See this PR angular/components#4178 But as far as I understand we need to pass this token in every test where we use Material components. For me is too verbose, so I prefer either method described in this issue or solution proposed by me (it also disables hammerjs warning) |
Close in favor of #79 |
For anyone interested, the solution linked by @thekip above, will look something like this (I'm using the Angular testing library): |
When running tests with jest + jest-preset-angular in a non angular-cli app you get a
warning for each of your components that contain an angular material component. Since there is no way of actually loading the theme in a non angular-cli app test you have to disable the warning by injecting some css in the JSDOM page to trick angular material that the page has loaded the css.
This can be done by modifying the
setupJest.ts
file to look like thisMaybe this can be added to the
README.md
? Unless of course I'm mistaken and there is an actual "proper" way of doing it.The text was updated successfully, but these errors were encountered: