Share
Embed
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
Transcript
27 slides
-
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Unit
tests in deno A std journey -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Me
myself and I @paul.souche paulsouche @paulsouche 2 -
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 -
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 ? -
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 -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Resolution
#1 Always learn a language / framework / library / … through tests 7 -
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... -
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 -
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()) -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Assertions
3 / 3 15 Powerful Error assertions -
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 -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Doesn’t
know Fibonacci at all !!! 17 -
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) -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 What
I did at the time 1/3 : fibonacci 19 -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 What
I did at the time 2/3 : fibonacci Rec 20 -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 What
I did at the time 3/3 : famous unit test 21 -
Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 What
I missed at the time : fibonacci memo 22 -
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 -
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