Answer the question
In order to leave comments, you need to log in
How to properly populate the database when testing API?
I am writing tests for my API.
Here is where I test POST /users/:userId/item:
it('should add item to user', async () => {
await myTestsHelper.cleanDb();
// создаю юзера в БД. Мой вопрос про вот эту функцию :)
const user = await myTestsHelper.factories.createSomeUser();
// вызываю тестируемый эндпоинт
await request.post(`/users/$(user.id)/item`)
.expect(200);
// and expect bla bla bla ... Тут все понятно :)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question