期望libarary TypeError:expect(...).toInclude不是函数

2 javascript unit-testing supertest

我猜这是一个导入错误,但我似乎无法弄清楚如何,期望是最新的,如果没有它说我不能得到太多的运行

libarary TypeError:expect(...).toInclude不是函数

var request = require("supertest");
var {app} = require("./../server.js");
var {Show} = require("./../models/show");
var expect = require('expect');

    describe("GET /show/:id", () => {
        it("Should include the show name 'Arrow' in the body", (done) => {
            request(app)
            .get(`/show/${showName}`)
            .expect(200)
            .expect((res) => {
                expect('hello world').toInclude('world')

            })
            .end(done);
        });
    })

});
Run Code Online (Sandbox Code Playgroud)

MaX*_*Xon 9

对于过去常常.toMatchObject检查对象是否包含某些字段的人来说,新版本是.toHaveProperty.

这是文档参考


Mat*_*and 2

expect库最近成为Jest项目的一部分 - Jest 团队对 API 做了一些更改,正如这个答案所解释的那样。

expect现在可以在这里找到完整的文档:https: //facebook.github.io/jest/docs/en/expect.html