3 ms·
Are there refs the compliments are holding on to? If so use that and then window.getComputedStyle(refeElement) to test the style. Jest is a testing framework.
by shakes_mcjunkie 3y ago
Are there refs the compliments are holding on to? If so use that and then window.getComputedStyle(refeElement) to test the style.
Jest is a testing framework. You'll need to plug in other libraries to test specific things. For example, use react-testing-library to test react components in various ways.
- akudha 3y agoThank you, I wasn't aware of getComputedStyle, will experiment with it. I haven't yet tried react-testing-library yet, will try it too. It looks like testing JS is straightforward, but not CSS?
- shakes_mcjunkie 3y agoOnce you have the element it should be fairly straightforward to test computed styles. You may have to add some hooks for react-testing-library to grab elements like attributes, unique text, refs, etc. Read up on the tools you should be able to find something in there for your use case.