DEV Community

Discussion on: What do you use to test JavaScript code (if)?

Collapse
 
evanplaice profile image
Evan Plaice • Edited

Keep in mind, these choices are opinionated. IMO, the best testing framework is the one you notice the least.

Wherever possible, I stay away from FWs that are overloaded with a ton of convenience features or support trendy-but-not-useful approaches (ex BDD).

For example Mocha/Chai is usually the most popular for unit tests. I'm not a fan.

Protractor (Angular) and Enzyme (React) work perfectly well for framework-specific testing. But, I like that testing-library works directly on the DOM.

I like Tape b/c it doesn't use a plugin model for formatting the output. Instead, it outputs TAP (Test Again Protocol).

TAP is really basic and not too readable but since it's a standard there are plenty of tools built to consume it. For example piping tap into tap-spec will give you nice looking colorized test results.

Where TAP really makes a difference is CI/CD testing. On CI/CD speed trumps readability.

IMO, every testing lib should support TAP. If not as the default, then as an option.

Why the strong dislike of Selenium? I've used it before. Work that should've taken a week took almost a month b/c tests would randomly fail. To compensate, the tests became riddled with wait statements and other hacks.

Non-deterministic testing is a nightmare scenario for a Dev. It's really aggravating, time consuming, and makes you look bad even if you're doubled-down on effort trying to make it work.

Selenium is the anti-thesis of "the best testing FW is the one you notice least" in every way.

Collapse
 
maxdevjs profile image
maxdevjs

Here you addressed a good amount of my doubts and curiosities. Greatly appreciated :)