Saturday 29 August 2020

How do you guys deal with testing you API endpoints and seeding?

Hey guys,​Im working on a typescript/graphql backend currently and am writing some tests for my services/endpoints as i go. Im primarily a front end developer who is migrating to full stack. I've come across some issues when trying to "seed" inside my test files...From resources i can find online, most recommend to NOT run general fixtures before running your tests, and instead seed the database for each individual test to avoid mutating the same data/guaranteeing the use case is covered no matter what was done to the database prior.However, my database schema is getting pretty complex, with relationships being a few levels deep.For example, my database consists of relationships such as:`organization` has a `session` which has a `course`, and users can be added to these courses.It is seeming to be a bit too much boilerplate and repeating my code by manually creating an organization, then a session, then a course, and THEN my user that i want to use for the test. Do you guys create some kind of helper functions or test service for seeding or how do you guys go about with seeding your API integration tests?

Submitted August 29, 2020 at 07:25AM by cinco_cinco_cinco

No comments:

Post a Comment