[英]Loopback 4: Test never end when there is a connection with a MongoDB
启动npm测试,但是它永远不会结束。 当与MongoDB涉及的连接存在时,就会发生这种情况。 很少见,因为测试有效,但永无止境。
before('setupApplication', async () => {
({ app, client } = await setupApplication());
//await prepareTestData()
});
after(async () => {
//await cleanupTestData();
await app.stop();
});
it('login with a test user', async () => {
const res = await client.post('/user-accounts/login').set('urlLogin', TEST_TENANT_URL)
.send({
email: TEST_EMAIL,
password: TEST_PASS
}).expect(200);
token = res.body.token;
expect(res.body).to.ownProperty("token").and.length(EXPECTED_TOKEN_LENGTH);
console.log("Logged in with token ", res.body.token);
});
问题:终端永远不会结束。 就像线程仍在工作。 我不知道环回问题还是什么问题。
任何想法? 我希望有人能帮助我。
谢谢。
在https://github.com/strongloop/loopback-next/issues/3672中交叉讨论我的评论:
请使用Mocha选项exit
,它将在所有测试(以及每个挂钩之后/之后)结束之后结束该过程。 请参阅https://mochajs.org/#configuring-mocha-nodejs了解更多信息。 或者,您可以在mocha
CLI中添加--exit
选项,例如mocha --exit src/__tests__/**/*.js
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.