Unit Tests

in proton-mail

Theory

Jest

  • Done by Facebook engineering
  • It's the best modern test runner
  • It includes mocking and assetions features
  • Runs tests inside JSDom a Node based browser emulator
  • Not linked to React so don't includes features for testing React components
  • Beware, Jest skip the Webpack packaging!

Enzyme

Testing Library

Testing phylosophies

  • Isolation
    • From third parties services
    • From third parties libraries
    • From the inside of the project
  • Mocking
    • All the things
    • In last resort
  • Shallow rendering
    • Not rendering the inner components
    • Good or bad?

Testing Library
=
no mocking

My only doubt

Is it still unit tests or integration tests?

React Hooks Testing Library

On proton-mail

Custom render

Minimal mocking

Complete test environment

(Built progressively)

Includes helpers for:

  • API
  • Cache management
  • Event manager
  • Recently: cryptography

Some real unit tests

Some, a lot more high level

Thanks

deck

By Matthieu Lux

deck

  • 234