okay next up we’re going to add a little
bit of multiplication multiplication
it’s multiplied this adds so that it
becomes BDD naming let’s do let’s get
I’m gonna copy this from the last test
and then I’m gonna change this to say
five times nine okay so now we get an
error here type error cannot read
property one of no now I know like just
watching this code coverage here that
the error is here like you can very
easily identify where where things go
wrong using these code coverage
indicators but uh let’s say that this
was a big file and it was bit more
tricky to you know like I couldn’t maybe
I had didn’t have this file open or
something if we just if I’m on this line
here where it’s failing I can just do
come on shift P and to bring up the
Mishra studio code
come on thingamabob and then I just do
wallaby jump to error source and then it
will actually just boom jump me to the
line where the error happens which is
pretty cool was unfortunately not clever
enough to actually do it in the file
that was open so I’m gonna move this
over here still super useful anyway we
have this problem here we see that type
error cannot read probably one of no
that is because well this is not
matching
because we have like we have this we are
doing multiplication and this just
expects there to be plus that’s the only
thing that we support so we’re gonna add
support for that I’m gonna hide a star
here does that work what happens no it
still love matching oh hang on in red X
I need to when I want to match either or
I need to add these low brackets and now
it matches here at five star nine look
here by the way like this is so cool
you see here that it says star comma
plus and it does come by here as well so
it shows me the values of of these
things on both runs so like this is from
the multiplication test and this is from
the addition test so like that if it’s
like super super cool so in loops it
will actually show all the values but
but while it’s cool it’s not what we
want at the moment so I’m going to focus
on only the multiplies test for the
moment to keep us from distracting by
adding it only and now you see that that
disappeared I’m we used just see little
star here
however our test is still failing
because it takes here it expects the
value to be 45 but they received empty
string which makes sense because we’re
not doing anything here because we we
only support plus so I’m going to add
else if operate or equals
star then I’m going to do the result
equals left x right I know this code is
super silly and this is absolutely not
how you would write a real calculator
why I don’t know I don’t have never
written a real calculator but it’s
probably not how you do it this is just
for illustrative purposes we’re just
demonstrating we’ll be here but that
distracted me from the fact
the test is now green I want to talk a
little bit about coverage here I’m not
big on test coverage in general I don’t
think it’s necessarily a useful metric
but when you use it like this it’s
really cool if you see here like this
one is white means that this line of
code here it’s it’s not being executed
and you just wait what we have a test
for yes oh no wait we’re using we have
only enabled here so if I remove the
only we’ll see that up now everything
here is covered really really cool when
it comes to coverage wallaby actually
includes a pretty nifty thing if you go
to wallaby j/s dot-com
slash app you actually get this thing
that shows you your local test run so
they are hosting this app so you don’t
have to run a web server yourself but
this actually runs against your local
wallaby je s so you see here that these
are my tests and also show some really I
chose this the inline evaluation thing
is pretty cool if I click here it
actually jumps to that point in the
editor which is just pretty critical
[Music]
integration with Visual Studio code but
what I actually wanted to draw your
attention to is this test coverage here
so you can see here that you have a one
up sent test coverage of app J s nice
but we have these registers service
worker and index J s here that have
syrups and coverage and it’s dragging
our average down so I’m going to go jump
to the config file and get rid of those
from the from the coverage and way we do
files with no coverage coverage
calculated
Boop and it’s SRC slash what’s it called
I go register serviceworker and we also
don’t want to include the source index J
s either because that is just like just
setup and stuff and I need cover there
and I think that should be it might have
to restart wallaby not sure see if I
just refresh here yeah I think I need to
restart well we lobby this is the one
I’m washing by the way if you wondering
where my I saw and we now have one home
visit coverage now we haven’t actually
looked at the app for like a million
years so let’s make sure that our apps
actually work probably won’t let me
start it where is it come on BAM
okay see what happens here did okay Lisa
starts let’s try to write for Oh BAM
cannot read property 1 am NOT okay makes
sense because when I started typing it
just didn’t we haven’t considered the
case of partial input where you just
start typing so hmm alright so I think
the problem is here like parts is when
if we have a partial expression here
this is not going to match so parts is
going to be no so I think that we could
just if parts or not parts then we just
return all right now works and then I go
1 plus 1 and yeah to what five five four
nice
but what is this the coverage has
dropped from 100% let’s let’s check this
out let’s jump into up Jay s here notice
here that this is now brown like poop
brown that means that this line is
partially covered so it in in some cases
it will test have covered it but this
return statement here
mmm we’ve added this people without
adding a test for it nasty nasty so
let’s see here it doesn’t crash on
partial input all right let’s actually
undo our change here as well because
otherwise we have no way of knowing if
our test is actually actually testing
what we expect to do like it’s it’s
important to actually have your code
breaking before writing a test Const
it’s actually just copy this I know that
we’re seeing a lot of duplication in
these tests but I want to focus on
demonstrating like the live feedback
cycle of wallaby here not necessarily
every aspect of good testing practices
anyway
the partial input should looks like that
and now we reintroduce the change Larry
handmade see there and we’re green and
we are now back at 100%
notice that this just Oh live updated
pretty cool and that’s wallaby J as it’s
really nice if you’re into test-driven
development wallaby has a free trial so
you can just install it immediate
in in Visual Studio code but if you buy
it make sure that you enter the coupon
code fun fun function when you order
because that gives you a rebate that is
limited until January 31st no so this
coupon code will stop working on this
date so make sure that you if you if you
think about buying it by now
that coupon code is also in the episode
description and that is it you have just
watched an episode of function I am mpj until next time stay curious