GithubHelp home page GithubHelp logo

test-node-api-with-mocha-chai's Introduction

test-node-api-with-mocha-chai

Mocha: Testing Environment

Mocha is a javascript framework for node.js which allows async testing. let's say it provides the Environment in which we can use our favorite assertion libraries to test the code.

Mocha comes with tons of great features, the website shows a long list but here are the ones I like the most:

simple async support, including promises. async test timeout support. before, after, before each, after each hooks (very useful to clean the environment where each test!). use any assertion library you want, Chai in our tutorial.

Chai: Assertion library

So with mocha we actually have the environment for making our tests but how do we test HTTP calls for example ? Moreover, How do we test whether a GET request is actually returning the JSON file we are expecting, given a defined input ? we need an assertion library, that's why mocha is not enought.

Chai shines on the freedom of choosing the interface we prefer: "should", "expect", "assert" they are all available. I personally use should but you are free to check it out the API and switch to the others two. Lastly Chai HTTP addon allows Chai library to easily use assertions on HTTP requests which suits our needs.

test-node-api-with-mocha-chai's People

Contributors

shailesh74250 avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.