【问题标题】:Nodemailer potentially keeping Jest from exitingNodemailer 可能会阻止 Jest 退出
【发布时间】:2021-08-20 11:06:47
【问题描述】:

我正在运行一个集成测试,它不需要 nodemailer 就可以正常工作。在我添加它的那一刻,我开始得到它

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  DNSCHANNEL

      1 | require('dotenv').config()
    > 2 | const nodemailer = require("nodemailer");

测试脚本在这里

require('dotenv').config()

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

// const server = supertest.agent("http://localhost:" + process.env.ACCESS_TEST_PORT)

beforeAll(() => {
    process.env.NODE_ENV = 'test'
})

describe('Testing', () => {
    it('Testing if my sample test works!', () => {
        expect(true).toBe(true)
    })
})

describe('Testing the Index Page', () => {
    it('It should return statusCode 200', (done) => {
        supertest(app)
            .get('/v1/')
            .expect(200)
            .end((err, res) => {
                if (err) return done(err);
                expect(res.body).toEqual(
                    expect.objectContaining({
                        statusCode: 200,
                        message: 'This serves as a repository of API calls for INPAY application'
                        // token: expect.any(String),
                        // user: expect.any(Object),
                    }),
                );
                done();
            });
    });
});

任何帮助将不胜感激

【问题讨论】:

    标签: node.js jestjs nodemailer supertest


    【解决方案1】:

    这已经解决了。我意识到我添加了一个检测打开句柄的标志(--detectOpenHandles),因此是消息的原因

    【讨论】:

      猜你喜欢
      • 2019-03-13
      • 2020-08-24
      • 2020-09-20
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 2019-06-30
      • 2020-11-13
      相关资源
      最近更新 更多