Package Exports
- assertion
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (assertion) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Assertion Library for Browsers and NodeJS
Based on NodeJS Assert module.
API
NodeJS API
Additional API
has / hasNotSubset matching// Substring search assert.has(String, String | RegExp, ?message); // Simple property existance check assert.has(Object, String); // Sub-object match assert.has(Object, Object); // Check if item exists in set assert.has(Array, Primitive); // Subset match assert.has(Array, Array);
When checking arrays or objects deep matching is performed. See tests
assert.has({ foo: 'foo', bar: { qux: { qux: 'qux' quux: 'quux' }, baz: [1, 2, 3] } }, { foo: null, bar: { baz: [1], qux: { qux: 'qux' } } });
is/isNotType check// Check by Typename assert.is(Any, String, ?message) // Check by Contructor (instanceof) assert.is(Any, Function);
Typename are extracted from
Object.prototype.toString.call, so these are:'String' 'Number' 'Null' 'Undefined' 'Function' 'RegExp' 'Date' 'Object' // any `object` will pass here 'HTML**' // DOM Node, e.g. HTMLBodyElement 'CustomEvent' ... all other buit-in typesawaitWait for a callback Create a wrapper function to ensure that the function is called.assert.await( Function/*optional - wrap function */, Context/*optional - use binded context */, Number/*optional - expectation count, default is `1`*/ ); // Example var fn = assert.await(); assert.callbacks === 1; try { throw new Error() } catch { fn(); } assert.callbacks === 0;