diff --git a/tests/bundles/auto-negative-schema.zzb b/tests/bundles/auto-negative-schema.zzb new file mode 100644 index 0000000..00f98ee --- /dev/null +++ b/tests/bundles/auto-negative-schema.zzb @@ -0,0 +1,23 @@ +common: + baseUrl: https://postman-echo.com + headers: + Content-type: application/json + +requests: + # This request tests should all fail due to bad tests schema + # Ensure we don't crash on these. + tests-negative-schema: + method: POST + url: /post + body: + address: 1, example street + numbers: [444, 222] + object: { foo: bar } + tests: + status: { $ne: 200 } + headers: + content-type: { $exists: false } + $.data.operator: { badop: any } # invalid operator badop. If you want to match an entire object/array, use it as the value of the $eq operator. + $.data.numbers: [444, 222] + $.data.address: { $type: invalid } + $.data.object: { $exists: 4 } diff --git a/tests/bundles/auto-tests.zzb b/tests/bundles/auto-tests.zzb index e01e990..5a108c4 100644 --- a/tests/bundles/auto-tests.zzb +++ b/tests/bundles/auto-tests.zzb @@ -298,24 +298,6 @@ requests: $.data.age.something: 55 # jsonpath should take care of this. $.data.numbers[5]: 0 # jsonpath should take care of this - # This request tests should all fail due to bad tests schema - # Ensure we don't crash on these. - tests-negative-schema: - method: POST - url: /post - body: - address: 1, example street - numbers: [444, 222] - object: { foo: bar } - tests: - status: { $ne: 200 } - headers: - content-type: { $exists: false } - $.data.operator: { badop: any } # invalid operator badop. If you want to match an entire object/array, use it as the value of the $eq operator. - $.data.numbers: [444, 222] - $.data.address: { $type: invalid } - $.data.object: { $exists: 4 } - capture-response-positive: method: POST url: /post diff --git a/tests/integration.test.ts b/tests/integration.test.ts index 9fcd142..037230a 100644 --- a/tests/integration.test.ts +++ b/tests/integration.test.ts @@ -6,3 +6,8 @@ test("execute auto-tests.zzb in default env", async () => { const rawReq = new RawRequest("./tests/bundles/auto-tests.zzb", "default"); expect(await callRequests(rawReq)).toBe(0); }); + +test("execute auto-negative-schema.zzb in default env", async () => { + const rawReq = new RawRequest("./tests/bundles/auto-negative-schema.zzb", "default"); + expect(await callRequests(rawReq)).toBe(0); +});