Most assertions use the term "target" to refer to the object under
test, but a few assertions also had a `target` argument, resulting in
an overloaded term that was difficult to document. This commit
renames every `target` argument to `subject`.
- Make it so that only `AssertionError` is thrown from inside of an
assert interface wrapper function
- Always set `ssfi` to the current function when creating a new
`AssertionError` inside of an assert interface wrapper function
- Always set `ssfi` to the current function when creating a new
`Assertion` inside of an assert interface wrapper function,
and set the `keep_ssfi` flag
- Improve the `globalErr` test helper function to also validate that the
thrown error's stack trace doesn't contain frames from the assert
interface
- Make it so that only `AssertionError` is thrown from inside of an
assertion
- Always pass the current `ssfi` to a `new AssertionError` inside of an
assertion
- Always pass the current `ssfi` to a new `Assertion` inside of an
assertion, and set the `keep_ssfi` flag
- Improve the `globalErr` test helper function to also validate that
the thrown error's stack trace doesn't contain implementation frames
- Allows the `keep_ssfi` flag to be set when creating new Assertion
objects by providing its value as the fourth argument.
- Updates the `transferFlags` util to only transfer `keep_ssfi` when the
`includeAll` argument is set to `true`.
- Updates assertion creation and proxify utils to only set `ssfi` if
`keep_ssfi` isn't set.
- Updates inline docs to reflect expanded usage of `keep_ssfi`.
BREAKING CHANGE: `.change`, `.increase`, and `.decrease` changed from
Chainable Method Assertions to Method Assertions. They don't have any
chaining behavior, and there's no generic semantic benefit to chaining
them.
When neither the `contains` nor `any` flags are set, the `.keys`
assertion implicitly means `.all.keys` and thus requires the target
and given sets to be the same size. Therefore, `not.keys` implicitly
means `.not.all.keys`, and should thus pass when the target and given
sets aren't the same size, even if the target set is a superset of the
given set. This commit enables this behavior.
- Rename third parameter of Assertion constructor from `stack` to
`ssfi` for consistency's sake.
- Add documentation to Assertion constructor explaining what the `object`,
`message`, and `ssfi` flags are for.
There was some dead code leftover from before `includeStack` was made
into a config value (as opposed to existing as a property on the
Assertion object). This commit removes that dead code, and adds inline
documentation for the remaining stack-related code.
Proxy-related implementation frames were showing up in the stack
traces for failed property assertions. This commit removes them by
setting the proxy getter (instead of the property getter) as the
starting point to remove all implementation frames.
Only a couple of types of assertions were being tested for correct
stack traces. This commit cleans up the existing tests and adds tests
for the missing assertion types.
Many of the utility functions had slightly misleading names or no
names at all. This commit renames the functions with misleading names
and adds names to functions that were missing one.
Currently, only one module needs to detect if Chai's proxy protection
is enabled. However, upcoming changes will involve performing this
detection in other modules as well. This commit moves the detection
logic to its own utility module for easy reuse.
When the `length` assertion is chained directly off of an uninvoked
method, it references `function`'s built-in `length` property instead
of Chai's `length` assertion. This commit adds a guard to Chai methods
to detect this problem and throw a helpful error message that advises
the user on how to correct it.
- The method part of the `length` assertion was slated for deprecation
due to a compatibility issue in legacy environments. The decision to
deprecate `length` was reversed per #684. This commit replaces the
deprecation notice with a recommendation to favor `lengthOf` over
`length` due to the compatibility issue.
- The `lengthOf` assertion wasn't a true alias of `length` because it
was a method assertion instead of a chainable method assertion. This
commit changes `lengthOf` into a chainable method assertion that's
identical to `length`, and updates tests and docs accordingly.
- Updates docs to classify `length` as an alias of `lengthOf`.
- Updates docs of related assertions to use `lengthOf` instead of
`length`.
* Update chai/{testing-style} to chai/register-{testing-style}
* Update documentation on registering side effects and remove module.exports
* Update README.md usage for minor consistency issues