Testing Terms, Frameworks, Explained Like a 5th Grader
Published: 2021-03-12 15:54:59



### What are Some Popular(ish) Test Tools for Javascript Development?
*[Mocha](https://mochajs.org/)* - a testing framework (but doesn’t do assertion).

*[Chai](https://www.chaijs.com)* - 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](https://sinonjs.org/)* - 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](https://www.npmjs.com/package/fetch-mock)* - mock up/create fake http requests via `fetch`

*[Node-Fetch](https://www.npmjs.com/package/node-fetch)* - lets you fetch from node.js using similar syntax as `window.fetch` (aka the "normal" fetch used in a browser).

*[Selenium](https://www.selenium.dev/)* - 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](https://martinfowler.com/articles/mocksArentStubs.html)
[TDD vs BDD](https://blog.testlodge.com/tdd-vs-bdd/) 
[Differences Between Unit & Integration Testing](https://www.softwaretestinghelp.com/the-difference-between-unit-integration-and-functional-testing/) 
[Different Types of Testing Explained](https://dev.to/thejessleigh/different-types-of-testing-explained-1ljo)
[The Testing Intro I Wish I Had](https://dev.to/maxwell_dev/the-testing-introduction-i-wish-i-had-2dn)