Replies: 1 comment
-
While I cannot speak to the difference in configuration here I will ask: you mention setting the style inline so you can test it. Why not set a class name based on Testing the style value is potentially brittle as the actual value can change with the theme while I'd expect CSS classes to remain constant regardless of theme. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Currently implementing tests within a react project using FluentUI , some of our components are not fluent but style using the tokens system for colours etc. I need to test the presence of a colour in a test, using RTL and JestDOM. The style has to be applied via inline style rather than class.
When it comes to testing the toHaveStyle matcher is used as follows inline with FluentUI own tests on repo
expect(Text).toHaveStyle('color: var(--colorNeutralForeground3BrandHover)');
testing for using CSS variables. This test passes but is a false positive asexpect(Text).toHaveStyle('color: var(--NotARealColour)');
also passes, I believe this to be as CSS variable is not being applied properly, therefore the applied style of 'color' is undefined and so is the CSS variable causing it to pass. If you use a normal rgb or hex code colour to the style it picks it up fine, so looks like a problem with how FluentUI applies the CSS variables in test environment.Cloning the FluentUI and running their tests locally the same issue is not present in CSS variables but it is not clear what the difference is. Not sure if a helper function is needed but cannot find anything that stands out within the FluentUI repo, any help is appreciated.
Setup Minimum Reproducible
App.test.ts
App.ts
Beta Was this translation helpful? Give feedback.
All reactions