This course has been updated! We now recommend you take the Advanced GraphQL, v2 course.
Transcript from the "Unit & Integration Test Solution" Lesson
>> Scott Moss: We're gonna check out the solution branch, and see how we can get those projects tested just like we did you tasks.
>> Scott Moss: Cool, so if we go look, let me pull this back up, there we go. If we go look at the project.spec for what I have, it's more or less the same thing that the task spec was.
[00:00:28] The only difference is, probably I did some different assertions here, what they expect. For instance, I'm checking that, because we're doing the project query that gets back one project, I wanna make sure that I'm getting back the correct project. So I'm checking the IDs against each other, which basically is what is happening here.
[00:00:46] So this is the unit test, as you can see. I create a project in the database. I then run the resolver without a query. I pass in the expected input. I mark out the models, or I inject the models. And then I just expect that the result of that resolver's id is equal to the project that I created above's id.
[00:01:11] So that's that test there. And then as far as the integration test, it's the same resolver but we're actually testing against the whole query. So here I just make a query with some inputs, and then I just go ahead and test it, I run the query. I expect no errors to be there, which I know should be that now.
[00:01:36] And, I also expect the data.project which is this, so to be this so it will be data.project. This is project, to have an id field who's equal to the project's id that I created in the database. So that's what that check is there, and that's how I get these tests.
[00:01:57] Any questions on these tests here?
>> Scott Moss: Pretty simple, so again, like I talked about before, there's a third way to test, which is basically testing the strings against each other. Like if you wanted to important in that GraphQL file, and you wanted to test that it stays the same, then you're basically just testing out a string that never changes, so you can totally do that if you want.
[00:02:38] But, I feel like these type of queries kinda cover a lot of it. It's really up to you, how you wanna do it.