我正在尝试使用玩笑来测试我的CRUDS,但似乎我做错了事
问题1:超时-在jest.setTimeout指定的5000ms超时内未调用异步回调。 问题2:预计要调用七个断言,但收到零个断言调用。
testuserfunctions.js文件
const axios = require('axios')
const functions = {
post : async (user) => {
const response = await axios.post("http://localhost:3000/users");
return response.data;
},
module.exports = functions;
Tests.test.js文件
const funcs = require('../controllers/testuserfunctions');
test('post', async() => {
expect.assertions(7);
const user = await funcs.post(user1);
expect(user.data.data._v).resolves.not.toEqual(null);
expect(user.data.data._id).resolves.not.toEqual(null);
expect(user.data.data.conversations).resolves.toEqual([]);
expect(user.data.data.firstName).resolves.toEqual(user1.firstName);
expect(user.data.data.lastName).resolves.toEqual(user1.lastName);
expect(user.data.data.email).resolves.toEqual(user1.email);
expect(user.data.data.password).resolves.not.toEqual(user1.password);
});