Polyglot, autodidact. OSS author and contributor. Addicted to writing code, seeking my next 'fix'. Love communicating with an audience whose eyes don't glaze over when I get to the 'good parts'.
Yes, yes and 1000 times yes. By far the most sensible option 90% of the time for unit testing some JS. Small surface area (barely any dependencies), runs quickly, sensible set of default assertions built in. Very much in the style of the Go testing library - you can extend it yourself by writing your own functions.
If you're looking for clean, easy to read tests that don't install half of npm to your computer, this is my go to lib.
Polyglot, autodidact. OSS author and contributor. Addicted to writing code, seeking my next 'fix'. Love communicating with an audience whose eyes don't glaze over when I get to the 'good parts'.
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.
Tape.js for util libs
It's super easy to setup and use. Doesn't require plugins so it can be run w/o install via npx.
Jest for DOM interactions
Same reasons I use Tape except whrn I need to test some fake DOM interactions.
testing-library for framework code
Lightweight, doesn't depend on framework-specific implementation details. Just add a test-id and use it to check on an element's state.
Cypress.io for E2E/Integration*
B/C Selenium is a non-deterministic piece of trash. Puppeteer would probably work as well.
Wow, these are helpful suggestions. I am reading a few comparison/opinionated articles, but takes me a
while
to wrap my mind around this topic :)Yes, yes and 1000 times yes. By far the most sensible option 90% of the time for unit testing some JS. Small surface area (barely any dependencies), runs quickly, sensible set of default assertions built in. Very much in the style of the Go testing library - you can extend it yourself by writing your own functions.
If you're looking for clean, easy to read tests that don't install half of npm to your computer, this is my go to lib.
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.
Here you addressed a good amount of my doubts and curiosities. Greatly appreciated :)