问题描述
为什么测试会说表未定义?
这是运行npm run test
时得到的:
knex:query select * from "users" undefined +0ms
GET /api/users 200 28.804 ms - 2
✓ returns 200 and [] (55ms)
1 passing (216ms)
DEBUG=knex:query
在测试文件中,我正在运行它:
context('when the there are no users',() => {
it('returns 200 and []',() => {
console.log(db,"hi")
return supertest(app)
.get('/api/users')
.set({ "Authorization": `Bearer ${process.env.API_TOKEN}` })
.expect(200,[])
})
})
这是服务方法:
getAllUsers(knex) {
return knex.select('*').from('users')
},
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)