Slide 1

Slide 1 text

Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Unit tests in deno A std journey

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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 ?

Slide 5

Slide 5 text

Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 You have the job but... 5

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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...

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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())

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Assertions 3 / 3 15 Powerful Error assertions

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 Doesn’t know Fibonacci at all !!! 17

Slide 18

Slide 18 text

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)

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

Paul SOUCHE Repository => https://github.com/paulsouche/unit-tests-in-deno Meetup Paris Deno 4/14/2020 26 Thank you Questions ?

Slide 27

Slide 27 text

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