zack37 / fluent-assert Goto Github PK
View Code? Open in Web Editor NEWAn npm package for fluent contract assertions.
An npm package for fluent contract assertions.
Need to:
it
messages to all be in the should language style..npmignore
to exclude tests and coverage reporting.More could come up as the prior issues are being completed. Will add more as they come up
For example:
someFunc(thing){
assert.optional().array('thing.arr', thing.arr).of('object');
}
will throw an exception when it gets to .of('object')
if thing.arr
is undefined
or null
I would assume/prefer if the tag on assertions just passed if the optional parent was omitted.
I have not tested the other assertions for this (such as assert.optional().string(...).notWhitespace()
), but would assume the behavior is the same currently.
assert.array('obj.arr', null);
or
assert.array('obj.arr', undefined);
throws Cannot read property 'toString' of null
Cause: common-assert.js #arrayCheck actual: value.toString(),
assert.date()
Need to add date assertions
The message passed in assert.ok is returning undefined for the context.
assert.ok('something', object);
Reports undefined instead of something
in the error message
AssertionError: expected [Function] to throw error matching /object/ but got 'AssertionError: undefined + \'should not be undefined or null'
Need to add NODE_NDEBUG flag for making sure assertions don't affect performance and can be turned off for production. Decided to use NODE_ENV instead and turn off typeof
checks for NODE_ENV=production
For simplicity, the production flag is only going to wrap typeof checks and return true
when in production mode to still get validation on type properties.
Ran into a use case where null is allowed but I don't want undefined.
In this use case null
was going to be used as a SQL value.
var isUndefined = metadata.value === undefined ? undefined : 1;
assert.ok('value', isUndefined);
The docs say that it is .boolean
and not .bool
for the assertion on booleans. This is with the latest version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.