diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..defe0eb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Node.js: Debug TSDX Jest Tests", + "type": "node", + "request": "launch", + "runtimeArgs": [ + "--inspect-brk", + "${workspaceRoot}/node_modules/tsdx/dist/index.js", + "test", + "--runInBand" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "port": 9229 + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 6b4d890..8725dd1 100644 --- a/package.json +++ b/package.json @@ -84,5 +84,6 @@ "json-schema", "errors", "human" - ] + ], + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/src/index.test.ts b/src/index.test.ts index c945c51..31259c0 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -43,6 +43,26 @@ describe('betterAjvErrors', () => { }; }); + describe('combined schemas', () => { + it('should handle type errors', () => { + data = { + str: 123, + }; + const combinedSchema = {type: 'boolean'}; + const validateCombined = ajv.addSchema(combinedSchema).compile(schema); + validateCombined(data); + const betterErrors = betterAjvErrors({ data, schema, errors: validateCombined.errors }); + expect(betterErrors).toEqual([ + { + context: { + errorType: 'type', + }, + message: "'str' property type must be string", + path: '{base}.str', + }, + ]); + }); + }); describe('additionalProperties', () => { it('should handle additionalProperties=false', () => { data = {