Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing Node.js

Testing Node.js

Introductory presentation for EVRY employees on best practices for testing Node.js projects and various test strategies.

Hans Kristian Flaatten

February 15, 2017
Tweet

More Decks by Hans Kristian Flaatten

Other Decks in Technology

Transcript

  1. ! Agenda OPTIONAL SUBHEADING • Test strategies • Tools and

    frameworks • Application overview • Testing demo
  2. ! 3 Testing basic • Write testable code • Write

    tests as you develop • Add more tests when you find bugs • Test one concern at the time • Test your code
  3. ! 4 Testing basic (cont.) • Few tests are better

    than none • Keep it simple • Don’t get caught up following complex test strategies
  4. ! 5 Test levels • Unit level tests • Higher

    order tests • integration • system • end to end • smoke testing • happy path testing
  5. ! 6 Unit level testing math.sqrt(4) == 2 // root

    of 4 should be 2 User.getAge() == 32 // user age should be 32
  6. ! 8 Tools and frameworks • Test runner • Assertion

    library • Helpers; spies, stubs, and mocks • Syntax linting • Test coverage
  7. ! 9 Test runner: mocha describe('Array', () => { describe('#indexOf()',

    () => { it('returns -1 if not present', () => { [1,2,3].indexOf(4) == -1 }); }); });
  8. ! 10 Assertion library: assert const assert = require('assert'); assert.equal(str,

    'My String'); assert.equal(int, 12345678901); assert.deepEqual(obj1, obj2);
  9. " !

  10. ! Future presentations EVERY THURSDAY AT 12 • 09/02 -

    Node.js introduction • 16/02 - Node.js testing • 23/02 - Jenkins CI/CD • 02/03 - Node.js packages • 09/03 - Docker 101 • 16/03 - Microservices 101 • 23/03 - AWS Lambda (serverless) • 30/03 - TBA