Launch npm test, but it never end. It happens when there is a connection with a MongoDB involve. It is rare because the test works, but it never ends.
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);
});
The problem: The terminal never end. Is like a thread still working. I don´t know if it is a problem with loopback or what.
Any idea? I hope somebody could help me.
Thanks.
Cross-posting my comment from the discussion in https://github.com/strongloop/loopback-next/issues/3672:
Please use Mocha option exit
, it will end the process after all tests (and after/afterEach hooks) have finished. See https://mochajs.org/#configuring-mocha-nodejs to learn more. Alternatively, you can add --exit
option to mocha
CLI, e.g. mocha --exit src/__tests__/**/*.js
.