diff --git a/package.json b/package.json index f5af959..e85cbda 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "barky", - "version": "1.1.13", + "version": "1.1.14", "description": "A simple cloud services watchdog with digest notification support & no external dependencies", "homepage": "https://github.com/Rohland/barky#readme", "main": "dist/cli.js", diff --git a/src/evaluators/web.spec.ts b/src/evaluators/web.spec.ts index 9470ae5..62f782a 100644 --- a/src/evaluators/web.spec.ts +++ b/src/evaluators/web.spec.ts @@ -46,6 +46,22 @@ describe("web evaluator", () => { expect(result).toEqual(expected); }); }); + describe("when data is an object", () => { + it("should serialise to json then inspect", async () => { + // arrange + const web = { data: { test: 123 } } as AxiosResponse; + + // act + const result = isFailureWebResult( + web, + { + text: "123" + }); + + // assert + expect(result).toEqual(false); + }); + }); }); }); }); diff --git a/src/evaluators/web.ts b/src/evaluators/web.ts index 1079cc2..9f9791b 100644 --- a/src/evaluators/web.ts +++ b/src/evaluators/web.ts @@ -255,7 +255,10 @@ export function isFailureWebResult( webResult: AxiosResponse, validator: IWebValidator) { if (validator?.text) { - if (!webResult.data.toLowerCase().includes(validator.text.toString().toLowerCase())) { + const text = typeof(webResult.data) === "object" + ? JSON.stringify(webResult.data) + : webResult.data; + if (!text.toLowerCase().includes(validator.text.toString().toLowerCase())) { return true; } }