1 of 14

Integration testing

git.io/fp3TM

Webdev JS Evenings

2 of 14

Outline

  • Testing “pyramid”
  • Unit tests recap
  • Integration tests motivation
  • Best practices
  • Demo 1 (cli app, testing frameworks, mocks, coverage*)
  • Demo 2 (web app, chai, enzyme)
  • Best practices
  • Recap + teaser for next week

git.io/fp3TM

3 of 14

Testing pyramid

git.io/fp3TM

4 of 14

Unit tests recap

  • Important! tests are equal to code
  • Fast, reliable, readable
  • KISS, DRY, compose, separate
  • Pure functions, immutable structures
  • Automate in CI
  • TDD, BDD and common sense

git.io/fp3TM

5 of 14

git.io/fp3TM

6 of 14

Integration tests

“test integration of your own

and third-party modules”

git.io/fp3TM

7 of 14

Integration tests motivation

  • Business logic is encapsuled in modules
    • How to connect the modules together
    • How to test this “connection”
  • Dependencies are also “integrated” components
  • Examples
    • API calls
    • File system calls
    • DOM children components

git.io/fp3TM

8 of 14

Definitions

  • 90’s SW books
    • Big bang approach
    • Top-down
    • Bottom-up
    • Sandwich
  • Fowler’s definitions
    • Narrow
    • Broad (more E2E)

git.io/fp3TM

9 of 14

Best practices

  • Integration / unit test difference (common sense)
  • Integrate in CI
  • Integration “depth”
    • 2 internal components (mock others)
    • 1 ext dependency (mock it’s api / use the real one)
    • API (apiary / dockerized backend / real backend)
    • All internal components (mock externals / e2e tests)

git.io/fp3TM

10 of 14

Demo (snaps)

11 of 14

12 of 14

Demo (cypress)

13 of 14

Teaser

  • E2E testing from past to the future
  • Cypress.io in depth + CI
  • User testing sessions

git.io/fp3TM

14 of 14

Discussion

Thanks,

@jakubzitny