Slide 1

Slide 1 text

Testing JavaScript applications @ivanjov96 - Workshop -

Slide 2

Slide 2 text

Ivan Jovanovic Senior software engineer @ nearForm https://ivanjov.com @ivanjov96 Founder @ JS Remotely

Slide 3

Slide 3 text

Are you writing tests?

Slide 4

Slide 4 text

What are your excuses for not writing tests?

Slide 5

Slide 5 text

Excuses • My code is the best! • I don’t know how to test, it’s difficult • I don’t know what to test • It increases development time

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Just write tests…

Slide 8

Slide 8 text

And test everything!

Slide 9

Slide 9 text

Types of tests • Unit tests • Integration tests • Functional tests

Slide 10

Slide 10 text

Tools

Slide 11

Slide 11 text

What do you need from the testing library? • Provide a testing structure (Mocha, Jasmine, Jest, Cucumber) • Provide assertions functions (Chai, Jasmine, Jest, Unexpected) • Generate, display, and watch test results (Mocha, Jasmine, Jest, Karma) • Generate and compare snapshots of component and data structures to make sure changes from previous runs are intended (Jest, Ava) • Provide mocks, spies, and stubs (Sinon, Jasmine, enzyme, Jest, testdouble) • Generate code coverage reports (Istanbul, Jest, Blanket) • Provide a browser or browser-like environment with a control on their scenarios execution (Cypress, Protractor, Nightwatch, Phantom, Casper)

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Coverage • Function coverage – Has each function (or subroutine) in the program been called? • Statement coverage – Has each statement in the program been executed? • Branch coverage – Has each branch (also called DD-path) of each control structure (such as in if and case statements) been executed? • Line coverage - Has each line been called?

Slide 15

Slide 15 text

Demo time