typescript-runtime-type-benchmarks
typescript-runtime-type-benchmarks copied to clipboard
How do I add a testcase (Request: Documentation on that)
addCase('vality', 'parseSafe', data => {
const res = validate(dataType, data, { strict: true, bail: true });
if(res.valid) return res.data;
throw new Error("Invalid");
});
throws an exception on invalid which crashes the process.
Executing "vality"
Loading "vality"
/home/coder/data/typescript-runtime-type-benchmarks/cases/vality.ts:24
throw new Error('Invalid!');
^
Error: Invalid!
at ParseSafe.fn (/home/coder/data/typescript-runtime-type-benchmarks/cases/vality.ts:24:9)
at ParseSafe.run (/home/coder/data/typescript-runtime-type-benchmarks/benchmarks/parseSafe.ts:29:10)
@hoeck Do you have any input on this?
@jeengbe have you tried running the tests with npm run test
- what do they say?
If a benchmarked library does not implement the benchmark correctly (e.g. raises an exception if the data is valid) the benchmark will crash. The tests are meant to ensure that the benchmarked libraries do indeed conform to the benchmark spec.
Ah yes, I could debug it with jest. That is something that should somewhat be documented 🙈
Along the lines of
parseSafe:
- Allows unknown properties
- Throws if invalid
- Returns data if valid
assertStrict
- Doesn't unknown properties
- Throws if invalid
- Returns true if valid
:+1: also at the bottom of the benchmark graph there is a short description what every benchmark is supposed to test: https://moltar.github.io/typescript-runtime-type-benchmarks/
That is something that should somewhat be documented see_no_evil
I didn't expect so much feedback and new libraries so you're right, documentation is missing a bit.
If you could add a few hints / bullets to the readme on how to add a new library, that would be great.
Feel free to ask when something is not working or if you need some help.