Giter Site home page Giter Site logo

ws-test-harness's Introduction

ws-test-harness

Rationale

This is a simple skeleton using of the shelf components to allow for easy declarative integration testing. I specially like the declarative nature how tests are setup and the whole environment is bootstrapped.

To acomplish this it implements an integration test harness in order to test a service that depends itself on an external service.

The external service is declared as express application with stubbed or faked responses.

The service under test is also implemented as express application but in theory can be any HTTP service implementation.

The driver of the integration test is mocha a node.js testing framework.

Let’s assume a client application needs to contact an intermediate broker web service to request a widget from a third party web service.

The following sequence diagram should clarify the flow:

The client is simulated by mocha using superagent. The ws is the web service that is going to be tested, in this case for ease of use it’s also an express application. And finally the third party endpoint other_ws is faked through express with stubbed responses.

Dependencies

  • node.js
  • npm
  • mocha
  • express
  • supertest
  • optional: strace

Getting started

Run integration test

Depends: apt-get install nodejs mocha

mocha [debug] -R spec spec.js

Using strace to debug legacy node.js versions with incomplete stack traces

strace was used to debug conditions that crashed node.js 1.0.29 on Debian Jessie without useful stack traces.

strace -f -o mocha.strace.dump mocha --reporter spec --check-leaks  --globals i spec.js | grep bind --color

ws-test-harness's People

Contributors

i-0 avatar

Watchers

 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.