Skip to content

Commit a2b3541

Browse files
committed
ci: fix test scripts and disable logging
1 parent 67aca43 commit a2b3541

File tree

7 files changed

+39
-34
lines changed

7 files changed

+39
-34
lines changed

.mocharc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
process.env.TS_NODE_PROJECT = "./tsconfig.test.json";
2+
3+
module.exports = {
4+
require: "ts-node/register"
5+
};

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
"lint": "eslint src",
1515
"prepublishOnly": "yarn dist",
1616
"tdd": "watch \"npm run test:unit\" src/ tests/",
17-
"test": "TS_NODE_PROJECT=./tsconfig.test.json mocha -r ts-node/register -R spec 'src/**/*.{test,spec}.ts'",
18-
"test:2019": "TS_NODE_PROJECT=./tsconfig.test.json mocha -r ts-node/register -R spec 'src/tests/spec/draft2019-09.spec.ts'",
19-
"test:4": "TS_NODE_PROJECT=./tsconfig.test.json mocha -r ts-node/register -R spec 'src/tests/spec/draft04.spec.ts'",
20-
"test:6": "TS_NODE_PROJECT=./tsconfig.test.json mocha -r ts-node/register -R spec 'src/tests/spec/draft06.spec.ts'",
21-
"test:7": "TS_NODE_PROJECT=./tsconfig.test.json mocha -r ts-node/register -R spec 'src/tests/spec/draft07.spec.ts'",
22-
"test::2019:ci": "yarn test:2019 > test-result-spec2019-09.json; exit 0",
17+
"test": "mocha 'src/**/*.{test,spec}.ts'",
18+
"test:2019": "mocha 'src/tests/spec/draft2019-09.spec.ts'",
19+
"test:2019:ci": "DISABLE_LOG=true mocha -R json 'src/tests/spec/draft2019-09.spec.ts' > test-result-spec2019-09.json; exit 0",
20+
"test:4": "mocha 'src/tests/spec/draft04.spec.ts'",
21+
"test:4:ci": "DISABLE_LOG=true mocha -R json 'src/tests/spec/draft04.spec.ts' > test-result-spec4.json; exit 0",
22+
"test:6": "mocha 'src/tests/spec/draft06.spec.ts'",
23+
"test:6:ci": "DISABLE_LOG=true mocha -R json 'src/tests/spec/draft06.spec.ts' > test-result-spec6.json; exit 0",
24+
"test:7": "mocha 'src/tests/spec/draft07.spec.ts'",
25+
"test:7:ci": "DISABLE_LOG=true mocha -R json 'src/tests/spec/draft07.spec.ts' > test-result-spec7.json; exit 0",
2326
"test:inspect": "yarn test:2019 --inspect-brk",
24-
"test::4:ci": "yarn test:4 > test-result-spec4.json; exit 0",
25-
"test::6:ci": "yarn test:6 > test-result-spec6.json; exit 0",
26-
"test::7:ci": "yarn test:7 > test-result-spec7.json; exit 0",
27-
"test:spec": "TS_NODE_PROJECT=./tsconfig.test.json mocha -r ts-node/register -R spec 'src/tests/spec/*.spec.ts'",
28-
"test:unit": "TS_NODE_PROJECT=./tsconfig.test.json mocha -r ts-node/register -R spec 'src/**/*.test.ts'",
29-
"test:unit:ci": "yarn test:unit > test-result-unit.json; exit 0"
27+
"test:spec": "mocha 'src/tests/spec/*.spec.ts'",
28+
"test:unit": "mocha 'src/**/*.test.ts'",
29+
"test:unit:ci": "DISABLE_LOG=true mocha -R json 'src/**/*.test.ts' -R json > test-result-unit.json; exit 0"
3030
},
3131
"repository": {
3232
"type": "git",

src/errors/errors.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint no-invalid-this: 0 */
22
import { createCustomError, CreateError } from "./createCustomError";
33

4-
export const errors: Record<string, CreateError> = {
4+
export const defaultErrors = {
55
additionalItemsError: createCustomError("AdditionalItemsError"),
66
additionalPropertiesError: createCustomError("AdditionalPropertiesError"),
77
allOfError: createCustomError("AllOfError"),
@@ -69,3 +69,5 @@ export const errors: Record<string, CreateError> = {
6969
unknownPropertyError: createCustomError("UnknownPropertyError"),
7070
valueNotEmptyError: createCustomError("ValueNotEmptyError")
7171
};
72+
73+
export const errors: typeof defaultErrors & Record<string, CreateError> = defaultErrors;

src/features/draft04/ref.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function getRef(node: SchemaNode, $ref = node?.ref): SchemaNode | undefined {
101101
// check for remote-host + pointer pair to switch rootSchema
102102
const fragments = splitRef($ref);
103103
if (fragments.length === 0) {
104-
console.error("REF: INVALID", $ref);
104+
// console.error("REF: INVALID", $ref);
105105
return undefined;
106106
}
107107

@@ -112,7 +112,7 @@ function getRef(node: SchemaNode, $ref = node?.ref): SchemaNode | undefined {
112112
if (node.context.remotes[$ref]) {
113113
return compileNext(node.context.remotes[$ref], node.spointer);
114114
}
115-
console.error("REF: UNFOUND 1", $ref, Object.keys(node.context.remotes));
115+
// console.error("REF: UNFOUND 1", $ref, Object.keys(node.context.remotes));
116116
return undefined;
117117
}
118118

@@ -141,9 +141,8 @@ function getRef(node: SchemaNode, $ref = node?.ref): SchemaNode | undefined {
141141
return getRef(nextNode?.$defs?.[property]);
142142
}
143143

144-
console.error("REF: UNFOUND 2", $ref);
144+
// console.error("REF: UNFOUND 2", $ref);
145145
return undefined;
146146
}
147-
148147
console.error("REF: UNHANDLED", $ref);
149148
}

src/features/ref.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default function getRef(node: SchemaNode, $ref = node?.ref): SchemaNode |
136136
// check for remote-host + pointer pair to switch rootSchema
137137
const fragments = splitRef($ref);
138138
if (fragments.length === 0) {
139-
console.error("REF: INVALID", $ref);
139+
// console.error("REF: INVALID", $ref);
140140
return undefined;
141141
}
142142

@@ -147,7 +147,7 @@ export default function getRef(node: SchemaNode, $ref = node?.ref): SchemaNode |
147147
if (node.context.remotes[$ref]) {
148148
return compileNext(node.context.remotes[$ref], node.spointer);
149149
}
150-
console.error("REF: UNFOUND 1", $ref);
150+
// console.error("REF: UNFOUND 1", $ref);
151151
return undefined;
152152
}
153153

@@ -167,7 +167,7 @@ export default function getRef(node: SchemaNode, $ref = node?.ref): SchemaNode |
167167
return nextNode;
168168
}
169169
}
170-
console.error("REF: UNFOUND 2", $ref);
170+
// console.error("REF: UNFOUND 2", $ref);
171171
return undefined;
172172
}
173173

src/tests/utils/runTestCases.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,18 @@ export default function runAllTestCases(setup: Setup) {
100100

101101
after(() => {
102102
measurements.end = Date.now();
103-
console.log(
104-
"\n",
105-
"time overall:",
106-
measurements.end - measurements.start,
107-
"ms",
108-
"time validations:",
109-
measurements.validationDuration,
110-
"ms",
111-
"average validation time:",
112-
measurements.validationDuration / measurements.testCount
113-
);
103+
process.env.DISABLE_LOG !== "true" &&
104+
console.log(
105+
"\n",
106+
"time overall:",
107+
measurements.end - measurements.start,
108+
"ms",
109+
"time validations:",
110+
measurements.validationDuration,
111+
"ms",
112+
"average validation time:",
113+
measurements.validationDuration / measurements.testCount
114+
);
114115
// console.log("max time:", measurements.max);
115116
});
116117
});

src/validationPath.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ describe("validate - path", () => {
2424
"#",
2525
path
2626
);
27-
28-
console.log(path.map((v) => ({ ptr: v.pointer, sptr: v.node.spointer })));
29-
27+
// console.log(path.map((v) => ({ ptr: v.pointer, sptr: v.node.spointer })));
3028
assert(path.length > 0);
3129
});
3230
});

0 commit comments

Comments
 (0)