NODE JS vidly : GET / in genres.test.js does not pass.( picture attached)

I am at Intergration Test ,

            >   >  describe('GET /', () => {
                    it('should return all genres', async () => {
                      const genres = [
                        { name: 'genre1' },
                        { name: 'genre2' },
                      ];
                  await Genre.collection.insertMany(genres);

                  const res = await request(server).get('/api/genres');
                  
                  expect(res.status).toBe(200);
                  expect(res.body.length).toBe(2);
                  expect(res.body.some(g => g.name === 'genre1')).toBeTruthy();
                  expect(res.body.some(g => g.name === 'genre2')).toBeTruthy();
                });
              }); 

in genres.test.js does not pass.Preformatted text

when I check MongoDB compass, there are only 2 genres in collection.

I try to download the sample code from Mosh, It also does not pass ( I attached picture), someone face the same problem? have any idea to solve it?

thank in advance.

Hi, I’m getting a similar error but mine fails at the first expect(res.status).toBe(200) line. Heres a screenshot :

I cant seem to figure it out.

Figured it out, had bufferCommands set to false.