chore: migrate Node.js implementation for js-sandbox to isolated-vm (#3973)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
James George
2024-04-19 08:38:46 -07:00
committed by GitHub
parent a079e0f04b
commit 22c6eabd13
52 changed files with 1028 additions and 285 deletions

View File

@@ -0,0 +1,119 @@
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { describe, expect, test } from "vitest"
import { runTestScript } from "~/node"
import { TestResponse } from "~/types"
const fakeResponse: TestResponse = {
status: 200,
body: "hoi",
headers: [],
}
const func = (script: string, res: TestResponse) =>
pipe(
runTestScript(script, { global: [], selected: [] }, res),
TE.map((x) => x.tests)
)
describe("toBe", () => {
describe("general assertion (no negation)", () => {
test("expect equals expected passes assertion", () => {
return expect(
func(
`
pw.expect(2).toBe(2)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "pass", message: "Expected '2' to be '2'" },
],
}),
])
})
test("expect not equals expected fails assertion", () => {
return expect(
func(
`
pw.expect(2).toBe(4)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "fail", message: "Expected '2' to be '4'" },
],
}),
])
})
})
describe("general assertion (with negation)", () => {
test("expect equals expected fails assertion", () => {
return expect(
func(
`
pw.expect(2).not.toBe(2)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: "Expected '2' to not be '2'",
},
],
}),
])
})
test("expect not equals expected passes assertion", () => {
return expect(
func(
`
pw.expect(2).not.toBe(4)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: "Expected '2' to not be '4'",
},
],
}),
])
})
})
})
test("strict checks types", () => {
return expect(
func(
`
pw.expect(2).toBe("2")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: "Expected '2' to be '2'",
},
],
}),
])
})

View File

@@ -0,0 +1,427 @@
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { describe, expect, test } from "vitest"
import { runTestScript } from "~/node"
import { TestResponse } from "~/types"
const fakeResponse: TestResponse = {
status: 200,
body: "hoi",
headers: [],
}
const func = (script: string, res: TestResponse) =>
pipe(
runTestScript(script, { global: [], selected: [] }, res),
TE.map((x) => x.tests)
)
describe("toBeLevel2xx", () => {
test("assertion passes for 200 series with no negation", async () => {
for (let i = 200; i < 300; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel2xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to be 200-level status`,
},
],
}),
])
}
})
test("assertion fails for non 200 series with no negation", async () => {
for (let i = 300; i < 500; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel2xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to be 200-level status`,
},
],
}),
])
}
})
test("give error if the expect value was not a number with no negation", async () => {
await expect(
func(`pw.expect("foo").toBeLevel2xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 200-level status but could not parse value 'foo'",
},
],
}),
])
})
test("assertion fails for 200 series with negation", async () => {
for (let i = 200; i < 300; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel2xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to not be 200-level status`,
},
],
}),
])
}
})
test("assertion passes for non 200 series with negation", async () => {
for (let i = 300; i < 500; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel2xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to not be 200-level status`,
},
],
}),
])
}
})
test("give error if the expect value was not a number with negation", async () => {
await expect(
func(`pw.expect("foo").not.toBeLevel2xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 200-level status but could not parse value 'foo'",
},
],
}),
])
})
})
describe("toBeLevel3xx", () => {
test("assertion passes for 300 series with no negation", async () => {
for (let i = 300; i < 400; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel3xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to be 300-level status`,
},
],
}),
])
}
})
test("assertion fails for non 300 series with no negation", async () => {
for (let i = 400; i < 500; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel3xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to be 300-level status`,
},
],
}),
])
}
})
test("give error if the expect value is not a number without negation", () => {
return expect(
func(`pw.expect("foo").toBeLevel3xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 300-level status but could not parse value 'foo'",
},
],
}),
])
})
test("assertion fails for 400 series with negation", async () => {
for (let i = 300; i < 400; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel3xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to not be 300-level status`,
},
],
}),
])
}
})
test("assertion passes for non 200 series with negation", async () => {
for (let i = 400; i < 500; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel3xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to not be 300-level status`,
},
],
}),
])
}
})
test("give error if the expect value is not a number with negation", () => {
return expect(
func(`pw.expect("foo").not.toBeLevel3xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 300-level status but could not parse value 'foo'",
},
],
}),
])
})
})
describe("toBeLevel4xx", () => {
test("assertion passes for 400 series with no negation", async () => {
for (let i = 400; i < 500; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel4xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to be 400-level status`,
},
],
}),
])
}
})
test("assertion fails for non 400 series with no negation", async () => {
for (let i = 500; i < 600; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel4xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to be 400-level status`,
},
],
}),
])
}
})
test("give error if the expected value is not a number without negation", () => {
return expect(
func(`pw.expect("foo").toBeLevel4xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 400-level status but could not parse value 'foo'",
},
],
}),
])
})
test("assertion fails for 400 series with negation", async () => {
for (let i = 400; i < 500; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel4xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to not be 400-level status`,
},
],
}),
])
}
})
test("assertion passes for non 400 series with negation", async () => {
for (let i = 500; i < 600; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel4xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to not be 400-level status`,
},
],
}),
])
}
})
test("give error if the expected value is not a number with negation", () => {
return expect(
func(`pw.expect("foo").not.toBeLevel4xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 400-level status but could not parse value 'foo'",
},
],
}),
])
})
})
describe("toBeLevel5xx", () => {
test("assertion passes for 500 series with no negation", async () => {
for (let i = 500; i < 600; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel5xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to be 500-level status`,
},
],
}),
])
}
})
test("assertion fails for non 500 series with no negation", async () => {
for (let i = 200; i < 500; i++) {
await expect(
func(`pw.expect(${i}).toBeLevel5xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to be 500-level status`,
},
],
}),
])
}
})
test("give error if the expect value is not a number with no negation", () => {
return expect(
func(`pw.expect("foo").toBeLevel5xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 500-level status but could not parse value 'foo'",
},
],
}),
])
})
test("assertion fails for 500 series with negation", async () => {
for (let i = 500; i < 600; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel5xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: `Expected '${i}' to not be 500-level status`,
},
],
}),
])
}
})
test("assertion passes for non 500 series with negation", async () => {
for (let i = 200; i < 500; i++) {
await expect(
func(`pw.expect(${i}).not.toBeLevel5xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: `Expected '${i}' to not be 500-level status`,
},
],
}),
])
}
})
test("give error if the expect value is not a number with negation", () => {
return expect(
func(`pw.expect("foo").not.toBeLevel5xx()`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected 500-level status but could not parse value 'foo'",
},
],
}),
])
})
})

View File

@@ -0,0 +1,231 @@
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { describe, expect, test } from "vitest"
import { runTestScript } from "~/node"
import { TestResponse } from "~/types"
const fakeResponse: TestResponse = {
status: 200,
body: "hoi",
headers: [],
}
const func = (script: string, res: TestResponse) =>
pipe(
runTestScript(script, { global: [], selected: [] }, res),
TE.map((x) => x.tests)
)
describe("toBeType", () => {
test("asserts true for valid type expectations with no negation", () => {
return expect(
func(
`
pw.expect(2).toBeType("number")
pw.expect("2").toBeType("string")
pw.expect(true).toBeType("boolean")
pw.expect({}).toBeType("object")
pw.expect(undefined).toBeType("undefined")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "pass", message: `Expected '2' to be type 'number'` },
{ status: "pass", message: `Expected '2' to be type 'string'` },
{ status: "pass", message: `Expected 'true' to be type 'boolean'` },
{
status: "pass",
message: `Expected '[object Object]' to be type 'object'`,
},
{
status: "pass",
message: `Expected 'undefined' to be type 'undefined'`,
},
],
}),
])
})
test("asserts false for invalid type expectations with no negation", () => {
return expect(
func(
`
pw.expect(2).toBeType("string")
pw.expect("2").toBeType("number")
pw.expect(true).toBeType("string")
pw.expect({}).toBeType("number")
pw.expect(undefined).toBeType("number")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "fail", message: `Expected '2' to be type 'string'` },
{ status: "fail", message: `Expected '2' to be type 'number'` },
{ status: "fail", message: `Expected 'true' to be type 'string'` },
{
status: "fail",
message: `Expected '[object Object]' to be type 'number'`,
},
{
status: "fail",
message: `Expected 'undefined' to be type 'number'`,
},
],
}),
])
})
test("asserts false for valid type expectations with negation", () => {
return expect(
func(
`
pw.expect(2).not.toBeType("number")
pw.expect("2").not.toBeType("string")
pw.expect(true).not.toBeType("boolean")
pw.expect({}).not.toBeType("object")
pw.expect(undefined).not.toBeType("undefined")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "fail", message: `Expected '2' to not be type 'number'` },
{ status: "fail", message: `Expected '2' to not be type 'string'` },
{
status: "fail",
message: `Expected 'true' to not be type 'boolean'`,
},
{
status: "fail",
message: `Expected '[object Object]' to not be type 'object'`,
},
{
status: "fail",
message: `Expected 'undefined' to not be type 'undefined'`,
},
],
}),
])
})
test("asserts true for invalid type expectations with negation", () => {
return expect(
func(
`
pw.expect(2).not.toBeType("string")
pw.expect("2").not.toBeType("number")
pw.expect(true).not.toBeType("string")
pw.expect({}).not.toBeType("number")
pw.expect(undefined).not.toBeType("number")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "pass", message: `Expected '2' to not be type 'string'` },
{ status: "pass", message: `Expected '2' to not be type 'number'` },
{
status: "pass",
message: `Expected 'true' to not be type 'string'`,
},
{
status: "pass",
message: `Expected '[object Object]' to not be type 'number'`,
},
{
status: "pass",
message: `Expected 'undefined' to not be type 'number'`,
},
],
}),
])
})
test("gives error for invalid type names without negation", () => {
return expect(
func(
`
pw.expect(2).toBeType("foo")
pw.expect("2").toBeType("bar")
pw.expect(true).toBeType("baz")
pw.expect({}).toBeType("qux")
pw.expect(undefined).toBeType("quux")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
],
}),
])
})
test("gives error for invalid type names with negation", () => {
return expect(
func(
`
pw.expect(2).not.toBeType("foo")
pw.expect("2").not.toBeType("bar")
pw.expect(true).not.toBeType("baz")
pw.expect({}).not.toBeType("qux")
pw.expect(undefined).not.toBeType("quux")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
{
status: "error",
message: `Argument for toBeType should be "string", "boolean", "number", "object", "undefined", "bigint", "symbol" or "function"`,
},
],
}),
])
})
})

View File

@@ -0,0 +1,203 @@
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { describe, expect, test } from "vitest"
import { runTestScript } from "~/node"
import { TestResponse } from "~/types"
const fakeResponse: TestResponse = {
status: 200,
body: "hoi",
headers: [],
}
const func = (script: string, res: TestResponse) =>
pipe(
runTestScript(script, { global: [], selected: [] }, res),
TE.map((x) => x.tests)
)
describe("toHaveLength", () => {
test("asserts true for valid lengths with no negation", () => {
return expect(
func(
`
pw.expect([1, 2, 3, 4]).toHaveLength(4)
pw.expect([]).toHaveLength(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "pass", message: "Expected the array to be of length '4'" },
{ status: "pass", message: "Expected the array to be of length '0'" },
],
}),
])
})
test("asserts false for invalid lengths with no negation", () => {
return expect(
func(
`
pw.expect([]).toHaveLength(4)
pw.expect([1, 2, 3, 4]).toHaveLength(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "fail", message: "Expected the array to be of length '4'" },
{ status: "fail", message: "Expected the array to be of length '0'" },
],
}),
])
})
test("asserts false for valid lengths with negation", () => {
return expect(
func(
`
pw.expect([1, 2, 3, 4]).not.toHaveLength(4)
pw.expect([]).not.toHaveLength(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "fail",
message: "Expected the array to not be of length '4'",
},
{
status: "fail",
message: "Expected the array to not be of length '0'",
},
],
}),
])
})
test("asserts true for invalid lengths with negation", () => {
return expect(
func(
`
pw.expect([]).not.toHaveLength(4)
pw.expect([1, 2, 3, 4]).not.toHaveLength(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: "Expected the array to not be of length '4'",
},
{
status: "pass",
message: "Expected the array to not be of length '0'",
},
],
}),
])
})
test("gives error if not called on an array or a string with no negation", () => {
return expect(
func(
`
pw.expect(5).toHaveLength(0)
pw.expect(true).toHaveLength(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected toHaveLength to be called for an array or string",
},
{
status: "error",
message:
"Expected toHaveLength to be called for an array or string",
},
],
}),
])
})
test("gives error if not called on an array or a string with negation", () => {
return expect(
func(
`
pw.expect(5).not.toHaveLength(0)
pw.expect(true).not.toHaveLength(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message:
"Expected toHaveLength to be called for an array or string",
},
{
status: "error",
message:
"Expected toHaveLength to be called for an array or string",
},
],
}),
])
})
test("gives an error if toHaveLength parameter is not a number without negation", () => {
return expect(
func(
`
pw.expect([1, 2, 3, 4]).toHaveLength("a")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message: "Argument for toHaveLength should be a number",
},
],
}),
])
})
test("gives an error if toHaveLength parameter is not a number with negation", () => {
return expect(
func(
`
pw.expect([1, 2, 3, 4]).not.toHaveLength("a")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message: "Argument for toHaveLength should be a number",
},
],
}),
])
})
})

View File

@@ -0,0 +1,187 @@
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { describe, expect, test } from "vitest"
import { runTestScript } from "~/node"
import { TestResponse } from "~/types"
const fakeResponse: TestResponse = {
status: 200,
body: "hoi",
headers: [],
}
const func = (script: string, res: TestResponse) =>
pipe(
runTestScript(script, { global: [], selected: [] }, res),
TE.map((x) => x.tests)
)
describe("toInclude", () => {
test("asserts true for collections with matching values", () => {
return expect(
func(
`
pw.expect([1, 2, 3]).toInclude(1)
pw.expect("123").toInclude(1)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "pass", message: "Expected [1,2,3] to include 1" },
{ status: "pass", message: 'Expected "123" to include 1' },
],
}),
])
})
test("asserts false for collections without matching values", () => {
return expect(
func(
`
pw.expect([1, 2, 3]).toInclude(4)
pw.expect("123").toInclude(4)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{ status: "fail", message: "Expected [1,2,3] to include 4" },
{ status: "fail", message: 'Expected "123" to include 4' },
],
}),
])
})
test("asserts false for empty collections", () => {
return expect(
func(
`
pw.expect([]).not.toInclude(0)
pw.expect("").not.toInclude(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: "Expected [] to not include 0",
},
{
status: "pass",
message: 'Expected "" to not include 0',
},
],
}),
])
})
test("asserts false for [number array].includes(string)", () => {
return expect(
func(
`
pw.expect([1]).not.toInclude("1")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: 'Expected [1] to not include "1"',
},
],
}),
])
})
test("asserts true for [string].includes(number)", () => {
// This is a Node.js quirk.
// (`"123".includes(123)` returns `True` in Node.js v14.19.1)
// See https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.includes
return expect(
func(`pw.expect("123").toInclude(123)`, fakeResponse)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "pass",
message: 'Expected "123" to include 123',
},
],
}),
])
})
test("gives error if not called on an array or string", () => {
return expect(
func(
`
pw.expect(5).not.toInclude(0)
pw.expect(true).not.toInclude(0)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message: "Expected toInclude to be called for an array or string",
},
{
status: "error",
message: "Expected toInclude to be called for an array or string",
},
],
}),
])
})
test("gives an error if toInclude parameter is null", () => {
return expect(
func(
`
pw.expect([1, 2, 3, 4]).not.toInclude(null)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message: "Argument for toInclude should not be null",
},
],
}),
])
})
test("gives an error if toInclude parameter is undefined", () => {
return expect(
func(
`
pw.expect([1, 2, 3, 4]).not.toInclude(undefined)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [
{
status: "error",
message: "Argument for toInclude should not be undefined",
},
],
}),
])
})
})