Giter Site home page Giter Site logo

containerized-mocha-testing's Introduction

Containerized Moch Testing

There are several options you can choose regarding database for integration test in Node.js

Firstly, you can use in memory databases such as SQLite.

It's fast and doesn't require long running teardown, however, there are subtle differences in syntax with other SQL databases.

For example, you can't query by time, hour and second in SQLite like we can do with MySQL.

Thus you'll find certain disparity between test and production environment.

Secondly, you can use a local SQL database of your choice.

It ensures there's no disparity between test and production environment.

But it can be difficult to setup local test environment especially when you're in a big team.

Docker container comes to the rescue! It reduces the time and effort to setup an identical environment among many machines.

Another advantage of using it is you can also run tests in parallel easily.

You can do something like this.

npm run test:docker -- -e MYSQL_DATABASE=test app
npm run test:docker -- -e MYSQL_DATABASE=test2 app

As two commands use seperate database, tests will pass.

Run locally

npm test # needs local mysql
npm run test:docker app # needs nothing! :)
OR
npm run test:docker -e ENV_VAR_TO_OVERRIDE=value app

containerized-mocha-testing's People

Contributors

leejh3224 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.