1.

Define test pyramid with an example?

Answer»

Test pyramid is the pictorial representation of the RATIO of unit tests, integration tests and end-to-end tests required for developing a good quality node.js project.

  • Usually, a large number of low-level unit tests are written.
  • Comparatively less number of integration tests are written that tests how MODULES interact with each other.
  • Fewer end-to-end tests are written that tests the system as a whole.

Unit tests help to check the working of a single component or module. All dependencies are stubbed providing tests for exposed METHODS. Modules used for Node.js Unit Testing are:

  • Test runners like Mocha
  • Assertion library like Chai
  • Test spies, stubs and mocks like Sinon

Some of the above tools could also be used for integration tests for eg: SuperTest, Mocha and Chai that detects the defects in the early stage itself. Integration tests run FASTER than end-to-end tests.

Testing your application through its user interface is the most popular end-to-end way of testing for any application. End-to-end tests provide us with confidence that our system works all well together. The main disadvantage of end to end testing is that it requires a lot of MAINTENANCE and run pretty slowly.



Discussion

No Comment Found