13
How we do test apps

How do we test nodejs apps?

Embed Size (px)

Citation preview

Page 1: How do we test nodejs apps?

How we do test apps

Page 2: How do we test nodejs apps?

HotelQuickly Approach●Git flow

●Pull Request

●Code Quality Tool

●Unit tests

● Integration tests

●Continuous integration

Page 3: How do we test nodejs apps?

Git flow

The main branches (infinite lifetime):

● master (production-ready state)

● develop (the latest delivered development changes for the next release)

Supporting branches:

● feature branches

● release branches

● hotfix branches

Page 4: How do we test nodejs apps?

Sample App ModelActions:

● find offers

● book hotel

Page 5: How do we test nodejs apps?

Initialize ApplicationWeb framework expressjs

●npm init

●npm install express … --save-dev

https://github.com/HotelQuickly/nodejs-meetup

git checkout step1

Page 6: How do we test nodejs apps?

Find offersModules

●mysql2 mysql driver (fast)

●knex query buildergit checkout step2

Page 7: How do we test nodejs apps?

Time to DockerDocker allows you to package an application with all of its dependencies into a standardized unit for software development ©

Page 8: How do we test nodejs apps?

Docker●Dockerfile

●Build image

●Publish image

●Start containergit checkout step3

Page 9: How do we test nodejs apps?

Modules

●mochajs test runner

●shouldjs assertion library

●supertest

●sql-fixtures

●chancejs minimalist generator of random

Integration tests

git checkout step4

Note: don’t install mocha globally

Page 10: How do we test nodejs apps?

Code Quality●eslint

●HotelQuickly config

git checkout step5

Page 11: How do we test nodejs apps?

Book hotelNOTE: custom errors in node.js

git checkout step6

Modules●sinonjs Spies, Stubs and Mocks

●proxyquire

Unit tests

git checkout step7

git checkout step8

Integration tests

Page 12: How do we test nodejs apps?

Continuous integration●Docker compose

●Travis

git checkout step9

Page 13: How do we test nodejs apps?

QuestionsThanks for coming!