我的测试无法通过JEST,我遇到了一些错误

编程入门 行业动态 更新时间:2024-10-10 12:18:42

我的测试无法通过JEST,我遇到了一些<a href=https://www.elefans.com/category/jswz/34/1771449.html style=错误"/>

我的测试无法通过JEST,我遇到了一些错误

我将按照一些教程向我展示代码。当我尝试实现它并运行JEST时出现错误,并且测试无法通过]

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()
})

我遇到这种错误

也就是那行说“测试运行完成后,Jest没有退出一秒钟。”我已经用该代码在应用程序的根目录中制作了jest.config.js文件,以防止出现这种情况,但是它仍然显示为某种错误。

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

帮帮我

回答如下:

在屏幕上,有关于Jest失败的非常具体的信息。

更多推荐

我的测试无法通过JEST,我遇到了一些错误

本文发布于:2024-05-06 21:44:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1753873.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   测试   JEST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!