vendredi 22 novembre 2019

My test wont pass in JEST, i got some error

I`v following some tutorial with a code that i will show you. When i try implementing it and run JEST i get error and test wont pass

const mongoose = require('mongoose')
const supertest = require('supertest')
const app = require('../app')

const api = supertest(app)

test('notes are returned as json', async () => {
  await api
    .get('/api/notes')
    .expect(200)
    .expect('Content-Type', /application\/json/)
})

test('there are four notes', async () => {
  const response = await api.get('/api/notes')

  expect(response.body.length).toBe(4)
})

test('the first note is about HTTP methods', async () => {
  const response = await api.get('/api/notes')

  expect(response.body[0].content).toBe('HTML is easy')
})

afterAll(async () => {
  await mongoose.connection.close()
})

I got this kind of error https://prnt.sc/q0imi3

Also that line were it says "Jest did not exit one second after the test run has completed." I`v done making jest.config.js file in the root of the app to prevent this with this code but it still shows up as some kind of error.

module.exports = {
    testEnvironment: 'node',
  }

Help me guys

Aucun commentaire:

Enregistrer un commentaire