DEV Community

Brad Beggs
Brad Beggs

Posted on

Testing Terms, Frameworks, Explained Like a 5th Grader

What are Some Popular(ish) Test Tools for Javascript Development?

Mocha - a testing framework (but doesn’t do assertion).

Chai - an assertion library (used alongside Mocha) to compare output of a unit test to an expected value. To assert: a confident statement of fact.

Sinon.js - allows simulation of real objects, functions, state, networks calls, database queries, etc in an isolated environment (so you can’t break anything and can pinpoint issues). Make spies, stubs, and mocks.

Fetch-Mock - mock up/create fake http requests via fetch

Node-Fetch - lets you fetch from node.js using similar syntax as window.fetch (aka the "normal" fetch used in a browser).

Selenium - automate browser actions/behaviors.

Types of Testing

Behavior-Driven Development (BDD) - code written in an executable style that is understood by the team, the clients, other stakeholders and focuses on ensuring the product (not the code, per se) does what is expected . BDD extends the idea of Test-Driven Development.

Test-Driven Development (TDD) - code written for developers (by developers or test-developers) to test code functionality.

Unit/Component Testing - testing one small element of the software. This is considered the base level of testing since the element in consideration can’t be functionally smaller.

Integration Testing - unlike unit, integration testing takes various elements and tests how they work together.

Regression Testing - check changes or additions to the code don’t break previously working code. If previously working code did break, it moved backward (i.e. regressed) to a less developed state.

Interesting Non-obvious Testing Terms Defined

Mocks/Mocking - making a fake version of a function, database, or some service to stand in place of the real thing. Allows you to add, delete, change, recreate without concern for ruining a real thing. In the Theater world, this is your dress rehearsal.

Stubs - related to mocking, but not quite the same. A stub stands in for a lower-level code module/component/function since the code module isn’t finished. When you call a stub it gives the same output as the code will, once finished. Stubs provide a predetermined response. In carpentry and plumbing, stubbing refers to placing most of the pipe but it isn’t ready for use.

Spies - like their real-world counterpart, a spy records information, such as arguments, the return value, exceptions thrown.

Doubles/Test Doubles - a generic term for any fake/pretend thing used in place of the real. Comes from the idea of a stunt double in movies.

References & Recommended Further Reading

Mocks Aren’t Stubs
TDD vs BDD
Differences Between Unit & Integration Testing
Different Types of Testing Explained
The Testing Intro I Wish I Had

Top comments (0)