The last video we did a little bit of tricky debugging and we realized that our air handler that we
had defined inside of our common module wasn't really giving us enough information back if there's ever
some kind of error that we weren't really expecting to see.
We should really console log it or do something with it so that you and I can review our logs at some
point the future and say oh look something's going wrong that we weren't really expecting.
So I'm inside my coming module I'm in the middle where's directory air handler to us if we get past
this if statement right here.
Let's log this error.
So I going to do a console dot air and log out the air that just occurred I'll then save this file.
So we just made a change to our common module to get that update over to our tickets project.
We have to rebuild and republish the common module.
We then have to do an update to the module version inside of our tickets project.
So it is a little bit of a laborious process.
But remember we set up that little script to help us out.
I'm going to close the error handler.
I'm gonna go back over to my terminal.
I'm going to stop my tests with a control C and then go back up change into my common directory and
I'll run that NPM run up so remember that's going to increment our version number clean up the bill
directory rebuild do the get commit all that kind of stuff and then eventually publish it off to NPM
OK there we go.
About Version 1.0 1 2.
Now at this point you might be only at like 1.0 for something.
Again every now and then I make a mistake after we record a video.
And so I just happen to be at this version now that I'm going to go now back over to my tickets directory
and instead of tickets we now need to update that package.
Remember the package we can find cyber packages out Jason File inside of tickets for me I need to update
SMG tickets.
Common you're gonna find whatever your organization name was instead will do inside of tickets NPM update
your organization name flash common it's all run that and I should see the updated version printed out
once it does the install.
There we go.
Very good.
Now we can start artist suite back up and hopefully we're going to end up seeing a better error message
or some error message for that matter around getting that invalid I.D. so I'm going to do an MP and
run test
and after a brief warm up period there we go.
So it's way more information we probably want but at least it is an area that we are seeing now if anything
goes wrong.
We will see it even if we do not have some custom air built to deal with it.
So now it would be a lot easier for us if we had this originally to take a look at this and say Oh okay
yeah we put in some invalid I.D. we've got some it looks like that we need a normal real I.D. That's
how we can fix this.
Well let's go back over to our test file but here is show test done to yes.
I've still got a console log right here of response body.
I'm going to clean that up.
I don't need to get access to the response anymore.
I'm gonna clean that up and I'm going to restore at the very end of that chain.
The expect or.
Oh for and then going to find this get right here and we're going to put a real I.D. inside there.
We can either try to write out a real I.D. manually or alternatively we could try to generate one for
ourselves.
I think I'd be a lot better to use some built in function to generate this idea for us because to be
honest with you kind of easy for us to not get the like twelve or twenty four character whatever it
was.
I.D. correct.
So I'm going to turn this string into a template string by putting in the tactics I can remove that
hardcoded one right there and replace it with some interpolation to generate this I.D. We're going to
import Mongoose
then inside of the function body I'm going to create a new variable called I.D..
So we're going to use a function that is built into muggers to generate a normal or a realistic valid
ID looking out for us to say new Mongoose types dot object I.D. We're going to invoke that and they're
going to call to hex string
like so and then we'll pass them the I.D. right there.
So as you guessed this is a function to generate a valid object I.D. We're then going to toss it into
that string and no longer shall we get some air coming out of mongoose.
When we tried to make that query and fetch the ticket by I.D. So let's say this and see if our tests
are now passing a flip back over and there we go.
I'll set.
Well I think you can agree with me that generating the idea with this long and right here is not super
ideal if you want to you could certainly make some kind of helper function and tuck it away inside of
some utilize or helper file inside that test directory.
But I will leave that up to you.
All right.
Well I think that our show stuff is now pretty much working.
This is looking pretty reasonable to me at this point.
So let's take a pause right here.
Continue in just a moment.