使用jest和axiom编写一个API集成测试。我发誓当我将bearer令牌硬编码到put请求的头部时,我有一个简单的版本可以工作。但是经过一些futzing,我甚至不能ctr + z到达它“工作”的地方-我无法摆脱这个错误:
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● TLSWRAP
13 |
14 | it('user can create a cart', async () => {
> 15 | const response = await axios.put(
我已经尝试修复这些修复,但没有骰子。
- https://jestjs.io/docs/asynchronous
- Jest has detected the following 1 open handle potentially keeping Jest from exiting
我怎样才能让它成功运行(200响应),而不是因为打开句柄而退出?
import axios from 'axios';
describe('Cart Manipulation', () => {
let oc_token: string;
beforeAll(() => {
oc_token = "eyJblahblahblah"
});
it('user can create a cart', async () => {
const response = await axios.put(
'https://api.urltogoto',
{
'Accept': 'application/json',
// 'Authorization': 'Bearer eyJblahblahblah'
'Authorization': oc_token
}
);
console.log(response);
expect(response.status).toBe(200);
});
});
1条答案
按热度按时间0tdrvxhp1#
找到了解决方案,我不知道是什么具体的变化造成了差异,但大量的futzing周围产生了这个: