NestJS Unit Testing - Test Controller (with Guards) and Service | LinkedIn Clone [22]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to the linkedin clone in this video we'll be working on unit testing in sjs in particular if we run our npm run test command we're using jest that's baked into an sjs by default and we're testing the controller for the feed and the service for the feed in isolation and we're ensuring that it's returning the values that we want we are mocking values and we are incorporating guards into our controllers here so this is something you'd probably want to be working on as you make your endpoints similar to the error handling you'd want to be setting this up at the start and adding to it from there but nevertheless we will be uh creating this so let's go ahead and get started so now we're in our project up to date in our api folder one thing i want to do just before we start the testing is i just want to get the right tools for the job so if we look at the package json we can see that by default in sjs it comes with jest and it also comes with something called supertest and that's for the integration or end-to-end testing however we're going to be focusing on the testing the isolation of the controller and the service and from there you can pretty much test any of the files that you want in a for a unit test within a within sjs and if you had any utilities or anything like that it becomes even more simple you just have basic functions and stuff like that you can test for so let's go ahead and let's just get the npm install and we install this as a dev dependency because we don't want to ship it to production and i'm also going to have this node mox-http and this just makes it simple to mock the http request so we can get that npm i slash d node mox-http so we've got that in our project now now usually when you create projects and you use the next cli for building a controller or service or something like that it will automatically create the test file for us i originally was going to do testing but this project's evolved and so i'm just going to go ahead and create the files here and the convention is to have the name of the file dot spec at the end so i've got the feed service spec here and i'm also going to create the feed controller spec file so feed.controller dot spec dot ts and it's actually kind of good that we get to build this from scratch because it's an introduction to testing with jest in the nest js environment so it can't hurt so let's just go ahead and open the controller i'm going to close this just for now but we'll come back to that um so if we're looking at a controller here one thing to note when we're testing is that it's testing uh the compiled code or it's um mocking it but basically when you have these file paths here like you see this source slash auth um when you bring things into this file that you're testing it has a hard time you know determining the where everything is so we basically when we import jwt guard into this controller for example when it's referring to that um it can't find this route or this for this path so what that does mean is all of the file paths in our project that start with source we're going to have to refactor those into relative paths so i'm not going to bore you and make you watch all of that i'll have the code up on github if you want to just you know claim the repo or whatever you want to do pull the repo but i'm basically going to pause the video and do all that magic for us so i've made those changes and i basically just searched for the source slash and you could find that in the api folder and just you know make the changes like that you could also um configure it so you could nest has a better is easier to actually you know determine what these paths are but uh you know it's a lot easier just for testing just to have the relative paths so if we take a look at our feed controller we can see that we've got these guards on things and what i might do just to start off is just comment these guards out because ideally you want to be building this up um like the tests when you build the feature so like you make the crud or a single um operation api endpoint first and you would be testing for that in isolation on the controller side and the server side and then you'll be adding things to it ideally but we've sort of got to go back and do a little bit of ground work and that's okay so let's just go ahead and just comment these guards out just to make things a little easier so we can come to the feed controller and basically what we want to do is firstly we'll need to import a couple of things so we need to import test and a testing module and these aren't rxjs testing these are from at nest js testing oh and i don't want the test scheduler i just want test and i'm also going to want to import the nodemox http library in so we can get the http mox and we can just go ahead and we can require that package we imported and installed and obviously the thing that we're testing is going to need to be imported and that is just the feed controller here so we can go ahead and copy that class name and that's coming from the same location so we can get that and basically when we test things we have a testing category that we're testing for and then we have the individual tests within that suite so overall what we want to do is we use this describe method and then we just describe the thing we're testing so in this case we're just testing the feed controller and it takes this syntax here where it has this callback and this is where all of the [Music] setup work goes so these are things that are going to happen before the test so basically what we want to do here is now before so basically if you've never seen uh never done any testing before basically you just have this it function here and it tells you what the feed controller should be doing for a particular subset problem within the feed controller so the very first thing we want to do is we just want to and this is probably the first thing you do in most cases is you just want to see if the feed controller is defined so this it just tells uh you know it's just a descriptor for what the test should be within this testing suite and it just takes this call back here and we can have an assertion so what we're doing is we're expecting the feed controller which we haven't defined just yet um to be defined and if i go ahead and i just put undefined in here would be expecting a failing test so let's just go ahead and run our test just to see what things look like and we see that we get this this failing test here so the whole test suite failed which is the feed controller test suite and um in particular there should be defined test failed here and there's also some other errors going on here so let's go ahead and um and let me just see if there's any other spec files here um because it looks like there's two test suites failed all right and i think it's just failing because of the um other the feed service spec file i've created um so you can actually specify which file you want to test for if you only want to test for one and this comes in handy if you've got you know lots and lots of test files but you only want to load one of them you just drop the dot spec dot ts and you can test for that and then we're getting our one failed test suite and our one failed test so that's exactly what we'd expect so what we want to do is we want to have a way of putting in the feed controller and checking that it's defined and it's not completely trivial in this case because we've got to do some extra work with these guards and stuff like that but let's just build up onto that basically what we want to do before we call it each of these individual tests so we'll probably have you know three or four of these or something like that but you can actually have this method here before each and this will be running every time before one of these methods so we can have this async function here and what this is going to do is it's going to have uh it's going to create a fake module for us so we've got this testing module here and we want to build up a module that we're testing or a fake module a mock module and we just want to strip things back so we're able to test for the controller in isolation so what we can do is we can just say we can have a constant variable here and we'll call it the module ref and this is going to be of the type testing module and the reason we have an async function here is because we actually want to await for the dot test.create testing module function to occur and only after that's you know retrieved and set up and compiled do we want to run our test so basically this just takes an object and it's very similar to a module like an actual module so if you look at the [Music] feed module we can see that we have this is creator guard and feed service these are dependencies of this module here we have also importing the auth module which has some jwt guard on it and we'll have to be able to deal with that as well but because we're building up a fake module we don't want to import all of these we want to mock some of these things up and just focus on the unit test itself for this particular case the feed controller but we will need to go ahead and tell them tell this module what the controller is and the controllers we can put in the feed controller here and then we have our providers and we're going to have our feed service as a provider so that's going to be one of our providers here now one thing to note is and if you order import something and it comes up source here you will need to just change that i'm going to put this below the third party dependencies and put it with my code here but if i actually go ahead and look at the feed service file here we can see that this feed service it actually has its own dependency and if um this is going to be a quite common pattern because in our services we're using the repository design pattern and that's how we're injecting our entity mapping to our dto so from the database to the object and we need a way to mock this so or what so basically what we want to do here is after this providers here and after this you create the module we can actually so the injection is a provider for the um feed service so if we go and override the provider and we can do the same thing for guard and filter and interceptor and we will show an example of the guards very shortly but if we override the provider the provider that we're overriding is within the feed service and in particular what we want to do here and we can use a class or use a factory but i'm just going to use a value here and i'm going to create a mock feed service and basically what this will be doing is rather than you know because we're not testing the service we're not doing an integrated test between the controller and the service and the data and how it all interacts together we could and we'll probably do that in a subsequent video but we don't necessarily want um to be doing that right now because we're doing the unit test but we still need to because this is being used within our controller we we need to handle how we would use that and we want to mock uh that so basically with all that said in our describe block at the top here we basically want to have a mock feed service so let's create this and it's going to have all of the same methods that are on this service here but right now i'm just going to leave this as an empty object because i want to continue building up our testing module here so now we're using that value there what we can do here is we can just simply run a compile and now we have our module ref built out but we'll still need to actually get the reference to that and we'll need to set the feed controller and the feed service to that so basically let's see here so up the top here we're going to say let feed controller be of the type v controller and then we're going to set the feed controller we're going to say let the feed service be of the type feed service and then in our before each we can see that below our testing module would want to have our feed service that we've created um and we just want to get the module ref and since we've now created this um what's going on oh this needs to be in here so there's a get method here and it takes the type of the service as a generic type and then we can go ahead and actually put in that feed service there so we also want to do the same thing for the feed controller so we'll get the module ref we'll get that of the type feed controller and then you can pass in the feed controller and now if you pass in the feed controller we'll see if this works now there might be some other things at play here but let's just go ahead and run the test to see where we're at okay so it's failed for us and it's failed um all right this isn't the best of uh error messages but it's failing because it doesn't have all of the things it needs on it so let's go ahead and continue to build this out oh and that's because this compile here this should actually be a method here and now i'll get rid of that error so let's do the same thing but with that error amended let's just bring this console terminal up and then we've get this uh one pass should be defined so that's okay but right now we don't have our guards on at all so what i want to do is i want to i'll get the jwt guard in so let's just go ahead and undo a few things here so comment back in all these guards and now we need to deal with the jwt guard and his creator guard here now one thing to note is this is creator guard is within this module but this jwt guard is coming from this auth module here so if you actually take a look at the auth module um you know it has its own dependencies in there so we need to be able to circumvent that and basically what we need to do is we need to have a reference to the user service so we can say let user service type user service we can bring this in now see how it's bringing in from source here um i'm sure there's a way to you know change that default or you know have nests look at that but for our simple purposes i'm just going to go amend that manually so we've got this user service here now now we've added that user service we need to allow for it as a provider so [Music] basically we've done this feed service you've you've got this provider for feed service and you've overwritten its dependencies here if we have a look at user service and i'm going to do this in a different way but it's the same thing essentially just to demonstrate the different ways one could do something is if we have this user service here we've also got you know its own dependencies in here again um so i'm just going to have a mock user service just like i've had a mock um feed service and here rather than doing this object chaining syntax here we're doing this object syntax so i can use the property use value here and i can refer that to the mock user service variable and then we'll just have to go ahead and create that so i'm just going to go ahead and copy this down here and change this to mock user service and we'll go ahead and we'll just set a few more things up so as you can see most of the works in you know the configuration getting everything set up and when we get to the testing it's relatively quite easy so basically what i want to do here is i want to i also want to mock uh some of the results but i'll get into that in just a moment um i want to [Music] go ahead and get the guards uh mocked so i'm going to go ahead and copy this down here twice and for the jwt guard and we're importing that from the auth module and i also want to get the is creator guard and this one imported it nicely for us but what we want to do for the used value basically if we look at the guard itself like if we look at this is create a guard or the jwt guard if we look into that we can see it has this can activate method that's been implemented and basically that's the life cycle method that's been called to return either true or false and that allows you to either get past the guard or the guard just stops and you won't be able to continue the end point um so essentially what we want to do is just simulate this can activate and just allow them to get through it so you could have more testing for different circumstances um you know allow them to not go through and all that um but they'll be quite trivial once we've set up all of this work here so basically yes it comes with this uh function here so you can run a js dot fn and then you can make your own implementation um function so you can go ahead and you can mock the implementation and this allows you to just you know return true because we just want to override the guard here and obviously if you're testing for different users and all that sort of stuff um you know in a different spec file you would want to consider both the cases and the user type and all that stuff but this is just a simple unit test for the feed controller and it's important that you don't get too carried away and you just focus on the task at hand here because there will be a time where you need to integrate it or to do your integrated tests um but we want to sort of abstract uh that coupling away as much as possible and we do the same thing for the creator guard in an analogous way to the jwt guard and that should let's just see what that gives us here oh and we've got the user service 2 now so let's just go ahead and get that as well so [Music] user service is of the type user service so let's just run a test just to see where things are up to now that we've added back our guards see if there's any errors perhaps with file paths or anything like that so it appears everything's still working and then we can see the feed controller is defined so that was a lot of boilerplate to get our controller to be defined and now we can get into some of the more interesting stuff not that that wasn't interesting but more specific to the goal of this video of actually doing the unit testing so more tests and getting the test coverage but basically another test we might be having here is we could say it um so we're in the feed controller and one of the methods here is to create so one well probably the most obvious thing to test for is it should be able to create a feed post and what this will be doing what we're expecting here is um we're expecting that our feed controller that we've got going if we call the create method i want to if if we look at the feed module sorry not the feed module the feed controller we can see that it takes the request user and also the feed post so we're going to go and mock those values so up the top here we're going to need to have a mock request and this is why i've installed the http mox dependency so i can call that http mox and i can have a create request because it's taking a request as an argument in this particular case so i can say for the mock request there's going to be a user which is of the type new user now i'm not actually going to list out all of the properties of the user because the user will be you know we only need to test that one of them are accurate because then there will be the right user but if i just get this file path uh let's see here user it should be in here so i'm just going to say on the mock request on the user just give it a first name and i'll set that equal to john and if you wanted to set all your other properties and check all those uh that's fine but this is just a mock anyway um so what i'm going to expect back from that is just the first name just to save lines of code so and then of course we're going to need the mock feed post of the type feed post so we know our feed post is going to have a body it's going to have a created app and i'm just going to set that to a new date doesn't really matter what it is and it's going to have an author and that's why i've got this mock request here as well another reason i can just go ahead and i can just put in the user that we've created here and then now we've got our mock feed posts now we might also want to test um you know finding multiple posts and stuff like that so while i'm here i may as well oh and i guess i need to import this and i'm going to have mock feed post which is just the array of feed posts and this is just going to be the mock feed post for the first one and as the second mock fee post i'm just going to take everything in the first one uh but i'm just going to amend the body and i'm just going to say that it's the second feed post and then i'm going to duplicate this down one more and just change this to third feed post here so let me just i want to see that for a second coming back in my feed pose body i want this to be an array rather than an object so let's get the array records going so we have an array of mock posts the first one is this defined one and the second one is the same thing but with the body as the second feed post and third feed post okay so we've got the mock feed post there now we need to what's going to happen is when we call create so let's go ahead and put in our arguments we're going to have our mock feed post oh actually the singular mock feed post because let's just have a look at this method again it's going to take the feed post so that's the first argument mock feed post and as a second argument it's going to take the request and we know that that is just nothing more than the mock request here so let's go ahead and get that and it's just the request and this is going to equal what we want to happen is we want this to be equal and basically we want it to be exactly the feed post that we gave it so we can say dot dot slash mock feed post but in addition to that it's going to create a unique id for us with the save method so what we can do here and it doesn't really matter what it is so for the id we can expect and we can type in any number here and this should be this is what we're expecting here now what happens when you call this create method though if you call this create method it actually refers to the feed service and it refers to this create post method here so currently this controller isn't i mean this test module it isn't aware of that um this service because we're just we're redirecting it and overriding the provider service inside this file and that's exactly what you would want to do for a unit test to decouple the logic um but it just means that we need to come to our mock feed service here and go ahead and just add some of these methods here so in particular it's calling the create post method here so let's go ahead and add that to our spec file so we've got this create post now this is going to take we're going to overwrite that and we're going to do that with the jest function and we're going to mock the implementation of that function and basically what we want to have here is we know that the first argument is going to be user although we don't specifically need it here we'll just put it in as a placeholder and actually we can just go ahead and copy this signature entirely and then what this is going to give back for us for our test is it's going to return an object and we can just set the id to one it doesn't really matter what the number is put that at random or something and then we use the spread operator and we can say okay feed post so with that if we run our test now we should be able to get something useful back and test that our controller that particular method works in isolation and it indeed does should create a feed post so that's good now we want to mock the case of finding the post so we've already created what we want the um you know or like three posts if we take a look at our service we have this final post but i think it would be more interesting to have write a test for the fine post where we can take a number and skip the number so what i want to do is skip the first one and return the second two now this function this logic is handled by um typeform where you're building up the um you're creating the query uh using the create query builder function or method and um so we're just going to need to uh have another way of having that done and we'll just have a fine post in here so you can have multiple things here and this is going to be equal to the jest function we're going to mock the implementation and as the signature we can go ahead and we can put this in here but we will go ahead and remove the default values here because we're going to pass in the specific values and i might actually even change this to number two take i know it's implied by the type here but just the naming of it when we're testing it makes it's easier to for readability purposes so you can see the number to take or number to skip so i know that's built into typeform in that sort of way like take and skip and i was trying to keep it consistent with that but yeah again for the readability and the testing of it i'm just going to override the variable name to number to take a number to skip ah of course that's totally up to you and then what this is going to do for us now as said before this is using type orm and the repository method to build up the query but we just want something um you know something that works so we basically we want to skip a certain number so we want to skip the first um we'll skip whatever the number to skip is and then we want to take the number of elements starting from the remaining of the array so what we can do here to simulate that is we can have the feed posts after skipping and this is just going to take the mock feed post here and we're just going to slice the number to skip so all a slice does is if you have an array of three elements and you pass one in you'll remove the first element for you if you pass two and it removes the first two elements for you so then we'll be expecting just these two to come back if this number was one or just this one to be coming back if this was two um so that handles the skipping um but let's say we also want to take the number as well so it could be that we only wanted to take this middle element here so if the number to take was 1 we wouldn't want to return both of these so what we can do is we can use the slice method again and there's probably a way to refactor this make it more elegant but the purpose of testing isn't necessary to write the cleanest code in testing is to test whether your you know implementation code is working and functioning correctly and that should be written clean um so so you want to have that trade off there depending on you know getting work done and testing the works done uh correctly um but obviously when you're testing uh it helps you to write clean code but you want to be testing from the beginning sort of thing and building up the tests it's easier that way because as you've seen we've done a lot of plumbing here but nevertheless if i have this constant filtered feed posts variable here i can just take the feed post after the skipping and then what we can do here is we can use the slife method slice method now we don't want to cut anything off from the start so and since we've already sliced it we know that the start of the array is where we want to start our take from but the end the second parameter slice can take is the n number and that can be the number to take so if we passed in one for the number to take we'll just take in this one because this is already been sliced off if it was two we'll get these two back and so on so what we can do here is we can just simply return the filtered feed post and this is our fine post mock from our feed service mock so basically what we can do is we can have another test now and let's just copy this one down here actually i'll copy this one down so it should get two feed post skipping the first so what we're doing is so rather than this here we're going to have this feed controller and the feed controller is going to call the [Music] fine selected method and the fine selected method it takes the number to take and number to skip so we can explicitly say we want to you know get 2 and skip the first one and this should equal the um the mock feed post excluding the first one so we can just say slice one here so let's go ahead and run our test here and now we get three test pass so that's awesome now i may as well finish off the crud operations uh for you know updating and deleting um is to be noted that these two are taking the update result and delete result um back so let's just go ahead and mock those just for completion see so basically where we have these mock feed posts we can also have a constant variable to mock the delete result and i've done this one first on purpose even though update comes higher up in the code in the controller [Music] and you'll see why in just a moment but basically well firstly if we import that from typeorm and we can go ahead and bring this up the top here uh actually nest third party our stuff so basically we can say raw is an empty array affected now when we delete something this is going to affect one row so we'll expect one to be coming back here and i'm just going to go ahead and copy this down and just remove this here for the update result because update result it returns also the raw and affected and we're also expecting that to be one as well so what we can do is we can just say we can take everything that the delete results going to give us and it also has this thing called generated maps and that's just set to an empty array by default oh and of course this needs to be called mock update result so if i come to the service here and i look at the service it's going to have this update post and delete post method so let me get those and i'll do both these at the same time because they're pretty simple these ones but basically what we want to do for the first case is for the mock implementation function for this update post or what it represents we don't really need any parameters here at all because all we want to do is we just want to return the mock delete result oh mock update result and i'm just going to go ahead and copy these lines down which allows me to just cut this variable ahead and i'm just going to change this to mock delete result so it's pretty simple so now all we really need to do here is write the test so basically let's just go ahead and copy this line down here and we're expecting this test for update case it should um should update a feed post and when we call the feed controller when we call the update method uh let's say we're updating um something with the id of one and then we just pass in [Music] our mock feed post it doesn't really matter and then we just change the body to anything just updated body we expect that to equal the mock update result and in a very similar way we'll finish off testing our controller by having it should delete a feed post so when we delete a feed post we don't need to pass in a second argument we just need the id and we expect this to be equal to the mock delete result we just created so let's run the test specifically for the feed controller here we see that all of our tests pass so the control is defined that means we've set everything up including all the guards and services and the mocks um we're able to create a feed post we're able to select two skipping the first and then the update and delete methods so that's all i really want to do for the controller now i want to do a test for this service and now i know how things working i won't um i'll just do one example because uh you know after i do these two you can pretty much unit test anything within the whole nest application here so let's go to the [Music] feed service spec and let's start to write some things so i'm just going to copy and paste this whole thing here and i'm just going to coming out a few things firstly um let's see here we do want to have a lot of the same sort of boilerplate and again some of the boilerplate is generated for you when you use the cli so um oh just move this down though because i don't like that there how that's been input oh no no that's okay third party because i group things yeah so that's okay um but basically what we're describing here is the feed service this time so that's going to be independent of the guards because the guards are at the controller level and we also don't need the user service in this case we might need a user object and we're not going to need these here so we've got test testing module um so we've got the user feed post we might need the feed post entity but we'll bring that in as needed um so i might actually bring this user stuff here and then put this feed stuff here together like that um but we won't need to be testing the feed controller so that means we only really need the feed service here this mock request will keep and we'll keep uh in the same way because we're still in the service we're still expecting uh so let's say we create a post we'd still want to get that created post so it turns out that this is actually okay here now i don't need this one though or these three i'm just going to test for creating the post if i have this uh i want to delete these methods i want to keep this here just for now but i'm probably going to rename it so i'll just comment it out uh this mock user service you don't need that now i'm going to remove these overrides here and i'm going to have the feed service i'm just going to remove these things here so once again the feed service it has its own um dependency here and it's the actual repository so i'm just going to show you how you can do this in a different way here and actually we don't even need the controllers here alls we're going to be testing is the providers but on this feed service here what we can say is we can say for the provider get repository token and what this does is it um refers to the actual entity that we're injecting so for the feed post entity because you need that to inject the repository so if you get the repository token you'll need that there and i'm just going to import that and we don't need this one here but i'm going to move this import up here to the top here and then we have our feed stuff all together and our user stuff here third party and our nest stuff here and basically after we have this feed service we can use this provide to get the repository token which will handle the feed services dependencies for the entity that's been injected to it so we can have here as a second thing we can have a mock feed post repository and this is going to be this here so you can go ahead and just mock that here now we don't need to have these two things going here and we just want to test that the feed service is defined in the first instance so let's just run an npm test on the feed so let's just to see where things are up to see if we missed any steps or anything like that okay so that's passing so the service is defined we've you know overwritten the dependencies for the repository method now what we want to do is we just want to have a test here to say that it should create a feed post so in the controller we checked if it's creating an um basically if it's using um so on the controller we're calling the controller method and then we mock the service in here um so that was just giving back data but now we actually want to test the service itself and call that service method um so there's the separation between the control and service logic and then probably in the next video we'll talk about integration or end-to-end tests and stuff like that but if you have a look at the so it's going to need to take something here but if we have our feed service now what we want to do is create a post here and we've got our mock request user because if we look at the feed service create post it takes a user and a feed post so we can get the user and the mop feed post that we've defined before however one difference here is this is actually returning an observable so to be able to handle this what we need to do is we need to subscribe to the observable and then we need to do the um actually that needs to be together so for the feed posts that we're getting back what we can do is we can say we can expect the feed post that we're getting back to equal our feed post that we've set up so that's going to have an id so we can do the id expect any number because i'll just generate that on the five for us and then we can just go ahead and pass in our mock feed post here and one thing to note is because we're doing a call back if you're dealing with asynchronous operations or callbacks you need to say as an additional argument done and this is of the type just done clawback and after you've done the asynchronous operation so you've subscribed and then you've done the expectation assertion you can just pour done and that that just allows things to work smoothly so one thing to note is i probably just need to work on the mock feed post repository if we look at the method here it's calling create post and create post is actually also calling save so it's referring to the repository itself here where we have this save method so we're going to need to create both so we've got our mock implementation for our user and our feed posts and this is going to give back the feed post and it's also going to give back the author which is just the user so this should be returning for us this time so this should be generated uh asynchronously id and the author is nothing more than the user which will also be set but of course we're going to need to call have a method here for save which is just a jess function here oops and then we can once again mock the implementation and what we're going to get here is if we take a look at the save method here this in itself if we look at this save method here it's actually returning a promise and then we're converting it to an observable but on the repository layer itself it's actually returning a promise here so what we can do is we can say for that feed post of the feed post type what we want to do is well it's going to return a promise but we want to resolve that promise because we want to set the uh you know what it what the asynchronous operation resolves to in the form of an object and we'll just set this to id of one and set this to feed post here like this so now we've got our create post method our save method before each uh everything looks like it's set up nicely and we've got our asynchronous test here so let's just go ahead and run the test to see if everything's working smoothly and it is and let's just confirm um by making a test that fails for example let's set this to that the string of that and then we'll run this so now we see we've got this error here see the timeout and if we go ahead and just run test so i'll save this again and i run an npm run test it should run both our test suites so for the feed controller and also for the feed service and we can see that both the test suites passed it tells you which files got run and it shows you that all of the tests got successfully passed so we've covered how to do unit testing in an sjs environment with jest and that's pretty much all you need to know about unit testing because ingest because we've done it at the controller level and we've done it at the service level and anything else you'll be testing is probably going to be relating to like helper functions or things of that nature so it's just even simpler and it's just testing functions rather than integrated with an sjs environment so thanks so much for watching the video in the next video we're going to expand on our testing knowledge on unit testing and we're going to look at integration and end-to-end testing so we're tested in isolation the control and service but how do those things work together and can we do an integrated test of that or an intent test of the entire application perhaps so yeah thanks so much for watching and if you're interested uh in that sort of content please subscribe to my youtube channel and i'll see you in the next video cheers
Info
Channel: Jon Peppinck
Views: 493
Rating: 5 out of 5
Keywords: nestjs, unit testing, nestjs tutorial, unit tests, nestjs testing, unit test, nestjs swagger, nestjs microservices, js unit tests, javascript unit testing, test driven development, nestjs testes, js unit test, nestjs typeorm, nestjs graphql, nestjs test async, test, unit test là gì, nestjs e2e testing, nestjs training, nestjs with postgres, nestjs test coverage, nestjs testing module, nestjs js, nestjs postgresql, nestjs with eslint, javascript unit test
Id: 43iQzPJvZDw
Channel Id: undefined
Length: 65min 59sec (3959 seconds)
Published: Thu Aug 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.