* property assertion should only accept strings if nested, fixes#1043
* similar logic seperated out
* test cases for fix#1043
* type check if not isNested with tests
* Tests for assert and should inteface
* Error message change
* changes in should and assert tests as per review
* assert tests modified
* Review comments changes
* review comments fixes
Previously, the `.property` assertion failed ungracefully if the target was `null` or `undefined`. This commit causes an `AssertionError` to be thrown instead so that the ssfi flag and custom error messages are respected.
- 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`.
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.
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.
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`.
Three tests on the `should` interface are failing in Safari 10 due to a
bug related to proxies. These tests should be re-enabled once the bug is
fixed. See https://github.com/chaijs/chai/issues/855.
- Use typeof instead of type-detect whenever possible for performance
- Fix casing whenever type-detect is used per v3.0.0 breaking change
- Remove duplicate type-detect calls by storing results in variables
* Make 'empty' throw on non-string primitives and functions
* Update jsdoc
* improve error messages
* fix symbol to string coercion for Node 0.12
* use utils.inspect