Skip to content

Commit be25dd7

Browse files
committed
suppress warnings
1 parent 20c9e02 commit be25dd7

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"lint-fix": "run-p lint-fix:*",
2525
"lint-fix:format": "yarn --silent prettier --write",
2626
"lint-fix:tslint": "yarn --silent tslint --fix",
27-
"lint:format": "yarn --silent prettier -l",
27+
"lint:format": "yarn --silent prettier --check",
2828
"lint:tslint": "yarn --silent tslint",
2929
"prepare": "run-s build",
3030
"test": "run-s lint test:*",

src/ajvLogger.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Ajv from "ajv";
2+
3+
export const errorLogger: Ajv.CustomLogger = {
4+
// tslint:disable-next-line:no-console
5+
error: (...args) => console.log(...args),
6+
log: () => null,
7+
warn: () => null,
8+
};

src/toMatchApiResponse.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MatcherState } from "expect";
33
import { matcherHint } from "jest-matcher-utils";
44
import get from "lodash/get";
55
import { ajvCompile } from "./ajvCompile";
6+
import { errorLogger } from "./ajvLogger";
67
import { getErrorMessage } from "./getErrorMessage";
78

89
export type Method =
@@ -137,7 +138,7 @@ export async function toMatchApiResponse(
137138
};
138139
}
139140

140-
const validate = ajvCompile(schema);
141+
const validate = ajvCompile(schema, { logger: errorLogger });
141142
const body = received.body;
142143
const pass = await validate(body);
143144
if (!pass) {

src/toMatchRef.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import RefParser from "@apidevtools/json-schema-ref-parser";
22
import { MatcherState } from "expect";
33
import { matcherHint } from "jest-matcher-utils";
44
import { ajvCompile } from "./ajvCompile";
5+
import { errorLogger } from "./ajvLogger";
56
import { getErrorMessage } from "./getErrorMessage";
67

78
declare global {
@@ -45,7 +46,7 @@ export async function toMatchRef$(
4546
};
4647
}
4748

48-
const validate = ajvCompile(desiredSpec);
49+
const validate = ajvCompile(desiredSpec, { logger: errorLogger });
4950
const pass = await validate(received);
5051
if (!pass) {
5152
return {

0 commit comments

Comments
 (0)