mirror of
https://github.com/zerotier/zerotier-one-api-spec.git
synced 2026-05-22 16:29:58 -07:00
chore: improve test harness
`borp` lets node --test use typescript with actual source-mapped stacktraces and stuff
This commit is contained in:
committed by
Travis LaDuke
parent
99e78f3a64
commit
c1863fd950
@@ -4,4 +4,5 @@ module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint'],
|
||||
root: true,
|
||||
ignorePatterns: ["dist/*"]
|
||||
};
|
||||
|
||||
Generated
+790
-524
File diff suppressed because it is too large
Load Diff
+4
-3
@@ -3,7 +3,7 @@
|
||||
"repository": "https://github.com/zerotier/zerotier-one-api-spec",
|
||||
"scripts": {
|
||||
"start": "run-s build watch",
|
||||
"test": "tsx test/*test.ts",
|
||||
"test": "borp",
|
||||
"build": "run-s pre-compile compile lint build:*",
|
||||
"lint": "run-p lint:*",
|
||||
"pre-compile": "run-p depcheck format-spec format-code variables",
|
||||
@@ -39,7 +39,6 @@
|
||||
"ajv": "^8.12.0",
|
||||
"ajv-formats": "^2.1.1",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"better-ajv-errors": "^1.2.0",
|
||||
"depcheck": "^1.4.7",
|
||||
"eslint": "^8.56.0",
|
||||
"gh-release": "^7.0.2",
|
||||
@@ -48,7 +47,9 @@
|
||||
"openapi-typescript": "^7.0.0-next.7",
|
||||
"openapi-typescript-helpers": "^0.0.6",
|
||||
"prettier": "^3.2.5",
|
||||
"tsx": "^4.7.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"borp": "^0.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ import createClient from "openapi-fetch";
|
||||
import { PathsWithMethod } from "openapi-typescript-helpers";
|
||||
import type { paths } from "/tmp/schema.ts"; // generated by openapi-typescript
|
||||
|
||||
import Ajv, { DefinedError } from "ajv/dist/2020";
|
||||
import addFormats from "ajv-formats";
|
||||
import betterAjvErrors from "better-ajv-errors";
|
||||
import _Ajv from "ajv/dist/2020.js";
|
||||
import _addFormats from "ajv-formats";
|
||||
import { AnyValidateFunction } from "ajv/dist/core.js";
|
||||
|
||||
const Ajv = _Ajv.default;
|
||||
const addFormats = _addFormats.default;
|
||||
|
||||
if (!process.env.AUTH_TOKEN) {
|
||||
console.error("No AUTH_TOKEN env var set. Exiting.");
|
||||
@@ -45,17 +48,14 @@ function createValidator(schemaId: string) {
|
||||
return { validate, schema };
|
||||
}
|
||||
|
||||
function assertValid({ validate, schema }, data: object | undefined) {
|
||||
function assertValid(
|
||||
{ validate }: { validate: AnyValidateFunction },
|
||||
data: object | undefined,
|
||||
) {
|
||||
const valid = validate(data);
|
||||
if (!valid) {
|
||||
const output = betterAjvErrors(
|
||||
schema,
|
||||
data,
|
||||
validate.errors as DefinedError[],
|
||||
);
|
||||
console.error(JSON.stringify(validate.errors, null, 4));
|
||||
console.error(JSON.stringify(data, null, 4));
|
||||
assert.fail(output);
|
||||
assert.fail(JSON.stringify(validate.errors, null, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"sourceMap": true,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"types": ["node"],
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"resolveJsonModule": true,
|
||||
"removeComments": true,
|
||||
"newLine": "lf",
|
||||
"noUnusedLocals": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"isolatedModules": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true,
|
||||
"lib": [
|
||||
"ESNext"
|
||||
],
|
||||
"incremental": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user