I am curious if there is a best practice (if any at all) with trying to unit test a feature test. For example, if I have a function called isStyleSupported
that detects if a CSS property is supported in the current browser, how can I reliably unit test this function knowing the results would be different in different browsers.
The only thing I can think of is sniffing out the specific browser and then comparing the function's return value with what is expected for that browser. However, it seems like a bad approach given the fact that browser detection is bad practice.
I've briefly looked at Modernizr to see what they do without any definitive answer as it's a lot to look through.
Any ideas? Thanks.