Node.js TypeError:无法读取属性';应用';使用JEST单元测试在NodeJS中定义未定义的

Node.js TypeError:无法读取属性';应用';使用JEST单元测试在NodeJS中定义未定义的,node.js,api,unit-testing,jestjs,Node.js,Api,Unit Testing,Jestjs,我不熟悉jest单元测试和NodeJS,我正在尝试使用以下代码测试我的API const request = require('supertest'); const quick_registration = require('../../../routes/register/quick_registration_of_user') describe('Quick Registration of users', () => { beforeAll(() => {

我不熟悉jest单元测试和NodeJS,我正在尝试使用以下代码测试我的API

const request = require('supertest');
const quick_registration = require('../../../routes/register/quick_registration_of_user')

describe('Quick Registration of users', () => {
    beforeAll(() => {
        con.connect();
    });

    describe("GET / ", () => {
        test("It should respond with an array of students", async () => {
          const response = await request(quick_registration).get("/api/quickregistration");
          expect(response.status).toBe(200);
        });
      });
})
但是考试一直不及格,给了我一个错误

 FAIL  tests/routes/register/quick_registration_of_user.test.js
  Quick Registration of users
    GET /
      × It should respond with an array of students (20ms)

  ● Quick Registration of users › GET /  › It should respond with an array of students

    TypeError: Cannot read property 'apply' of undefined

      at node_modules/express/lib/router/index.js:635:15
      at next (node_modules/express/lib/router/index.js:260:14)
      at Function.handle (node_modules/express/lib/router/index.js:174:3)
      at Server.router (node_modules/express/lib/router/index.js:47:12)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        1.649s, estimated 2s
Ran all test suites.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
我在排队

const quick_registration = require('../../../routes/register/quick_registration_of_user')

需要定义路由器的文件。您需要的是定义应用程序的文件。

我认为您应该模拟get-requestWhat's
con.connect()。请提供测试中的最小可复制代码。