should.js is an expressive, BDD-style assertion library for JavaScript, designed to be framework-agnostic and provide helpful error messages. It is currently at version 13.2.3 and maintains an active release schedule with frequent patch and minor updates. A key differentiator is its default behavior of extending `Object.prototype` with a non-enumerable `should` getter, enabling `(value).should.be.something` syntax. For environments where `Object.prototype` extension is undesirable, it offers an alternative function-style API, `should(value).be.something`. The library ships with TypeScript type definitions, though specific import patterns have seen minor adjustments across versions. It aims for readability and clear test code.
npm install shouldVerified import paths — ran on the pinned version, not inferred.
Demonstrates both the default `Object.prototype` extended assertion style and the explicit function-style `should()` API for various data types and asynchronous operations.
Review existing tests involving `Map` or `Set` comparisons where object keys were used. Ensure keys are referentially identical if strict key equality is desired, or adjust tests to compare elements individually.
Remove any usage of `.enumerable` or `.enumerables` from your assertion chains. Use standard JavaScript iteration or other assertion methods to check for enumerability if necessary.
Ensure no arguments are passed to zero-argument assertions. For assertions that require arguments (e.g., `.equal()`, `.property()`), use the correct assertion method.
For cleaner code or when `Object.prototype` extension is undesirable, use `require('should/as-function')` or `import should from 'should/as-function'` to use the function-style API, e.g., `should(value).be.something()`.Update TypeScript import statements to `import * as should from 'should';` to ensure compatibility and access to all assertion methods, especially if you encountered issues after upgrading from v13.1.0.
Use the function-style assertion API: `should(null).not.be.ok();` or `should(undefined).not.exist();`. Alternatively, ensure the value is not `null` or `undefined` before calling `.should`.
If object key identity is not strictly necessary, restructure your tests to compare the `Map` or `Set` contents differently, perhaps by iterating and comparing values. If strict identity is intended, ensure the same key object instance is used.
Remove any arguments passed to zero-argument assertions. For example, change `value.should.be.Number(someArg)` to `value.should.be.Number()`.
No dependency data recorded yet.