为什么Jest async()会导致语法错误?

时间:2018-12-05 19:24:24

标签: node.js syntax-error jestjs

我在学校项目中使用Jest,但是每当我使用async()进行测试时,它都会返回语法错误。 这是 Syntax error和这个

test('POST /userGroups; should return 201 + userGroup obj', async () => {
    expect.assertions(2);
    let response = await request(app).post('/userGroups').set('Authorization', 'Bearer ' + validId).send({user:dummyTeacher, userGroup:dummyUserGroup});
    expect(response.statusCode).toBe(201);
    expect(response.body).toBeDefined();
    dummyUserGroup.id = response.body.id;
    dummyUserGroup.creator = response.body.creator;
    validUGId = dummyUserGroup.id;
});

这是package.json文件的一部分(部分)

"dependencies": {
    "body-parser": "^1.18.3",
    "db": "^1.1.1",
    "dotenv": "^6.1.0",
    "express": "^4.16.4",
    "google-auth-library": "^2.0.1",
    "mysql": "^2.16.0",
    "node-fetch": "^2.3.0",
    "passport": "^0.4.0",
    "passport-google-oauth": "^1.0.0",
    "passport-http-bearer": "^1.0.1",
    "supertest": "^3.3.0"
  },
  "devDependencies": {
    "jest": "^23.6.0"
  },
  "scripts": {
    "start": "node -r dotenv/config ./server.js",
    "test": "jest"
  },
  "jest": {
    "verbose": true,
    "collectCoverage": true
  }

我正在使用节点6.15.1 我究竟做错了什么? T_T

0 个答案:

没有答案