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

Unit test in deno

Unit test in deno

In this presentation we will see how to use the cli to run unit tests in deno, write assertions and have an overview of the benchmark API.

paul souche

April 14, 2020
Tweet

More Decks by paul souche

Other Decks in Technology

Transcript

  1. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Disclaimer

    Deno is in v0.40.0 at the time I made this presentation. Some presented patterns may evolve in further releases. Purpose is to present the opinionated choices deno made in its architecture. 3
  2. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 My

    first IT job interview 4 For the algorithm test we should begin with Fibonacci. Do you know it ? Yes, I studied it in highschool Ok great ! Could you begin with a unit test ? I never did a unit test of my life sorry ! but maybe can you help me ?
  3. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Me

    at the time 6 Fibonacci master First IT job Need to learn everything about tests
  4. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Seven

    years later 8 deno test Hey Lilian ! Deno looks so great but how do you test ? Try yourself and make a presentation ! Ok but what are the patterns ? What do you write ? Ok then...
  5. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Useful

    options 10 • -A --allow-all to manage permissions • --filter to filter spec files • --inspect-brk to debug • --log-level to debug
  6. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Limitations

    11 • No watch mode out of the box • Specs are executed sequentially (no parallelism) • Coverage is missing • Files must respect pattern (can be tricked with Deno.runTests())
  7. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Now

    I can do job interviews myself 16 And have access to all job interviews reports
  8. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 18

    Fibonacci 1 / 1 / 2 / 3 / 5 / 8 / 13 f(0) = 1 f(1) = 1 f(n) = f(n-1) + f(n-2)
  9. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Conclusion

    25 • deno dev experience is great (thanks to axetroy extension for vs code) • testing std & cli are not production ready at all • I hope the bench API will be kept
  10. Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 27

    Ressources • repository (https://github.com/paulsouche/unit-tests-in-deno) • testing std (https://github.com/denoland/deno/tree/master/std/testing) • fibonacci & golden number (https://youtu.be/J6tcnc7LukM?t=971) (french) • fibonacci & JavaScript (https://medium.com/developers-writing/fibonacci-sequence-algorithm-in-javascript-b253dc7e320e) • demo meme (https://youtu.be/y_lYoENIffI) (check it out it's hilarious) Thanks to Paris Deno, axetroy, Aurélien & Mathieu