Commit graph

416 commits

Author SHA1 Message Date
Grant Snodgrass
2f46af85f2 fix: remove Chai frames from .deep.equal stack 2018-01-14 20:47:26 +00:00
Sylvain Leroux
0d1b5862fe feat: Add the .fail([message]) interface
Fix #1116.
The `assert.fail` interface should accept being called with
only 1 arguments to fail with a custom message.
2018-01-12 08:32:57 +01:00
Andrew
0af30b79c9 feat(chai/config): add 'catch' to proxyExcludedKeys (#1101)
closes #1050
2017-12-10 18:25:07 +00:00
Simone Vittori
9a6610eb1e docs: fix typos and remove trailing whitespaces (#1042) 2017-11-22 22:02:05 +00:00
Ankit Singh
3ace4a0bbd property assertion should only accept strings if nested, fixes #1043 (#1044)
* 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
2017-10-02 17:44:05 -03:00
abetomo
d9aa813974 Remove unnecessary line feeds 2017-09-12 18:57:54 +09:00
Aleksey Shvayka
300b994ad3 do not attempt to define properties on primitives 2017-09-06 22:19:26 +03:00
Aleksey Shvayka
d4fde80a3c fix instanceof rethrow test 2017-09-06 22:19:10 +03:00
Aleksey Shvayka
6586e2dcbe add missing vars 2017-09-06 22:18:25 +03:00
Grant Snodgrass
c01cf30de9 fix: .include to work with all objects
Overly strict type-checking was causing `.include` to reject `Error`
objects and objects with a custom `@@toStringTag`.
2017-07-31 17:22:58 -04:00
Grant Snodgrass
c107abb319 fix: .instanceof to allow DOM interfaces in IE11 2017-07-24 18:57:42 -04:00
Grant Snodgrass
11a6f8502f test: skip failing .include tests in IE11
Contrary to spec, IE11 uses SameValue instead of SameValueZero
equality for Sets.
2017-07-09 19:01:00 -04:00
Aleksey Shvayka
2eddd79002 Add ES6 collection support to include() (#994)
* fix error messages tests

* add tests

* add implementation

* performance tweaks

* add tests for SameValueZero

* drop weakmap support

* update docs
2017-06-23 15:35:07 -07:00
Vlad Kolbaya
3c932e21e6 feat: allow dates for isBelow and isAbove assertions (#990)
* Fixed most tests

* Fix date uniformity (UTC)

* Add comment

* Cleanup

* Change extra functions (WIP)

* Finished tests

* Add master chai.js back

* Uncomment failing tests

* Update master and tests

* Actual seconds, duh

* Refactor 'above'

* Update all methods

* More explicit error

* Documentation - articles consistency

* Custom message test in assert

* No parenthesis in should

* Custom message for isAbove
2017-06-23 12:54:23 +01:00
Grant Snodgrass
e6ddf64c8f fix: check target's type in .property assertion
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.
2017-06-10 17:51:50 -04:00
Johannes Loewe
33e4403671 test: added custom message test to negated .nested-, .deep-, .own.include 2017-05-05 00:55:34 +02:00
Johannes Loewe
4180242e83 test: added message argument to negated nested-, deep-, own- and deepOwnInclude 2017-05-05 00:54:11 +02:00
Johannes Loewe
97b6243431 assert interface: add .ownInclude and .notOwnInclude 2017-05-05 00:54:11 +02:00
Johannes Loewe
24d7fa3849 assert interface: add deepNestedInclude and notDeepNestedInclude 2017-05-05 00:54:11 +02:00
Johannes Loewe
875057d8ea test: add assert.deepOwnInclude and assert.notDeepOwnInclude 2017-05-05 00:54:10 +02:00
Johannes Loewe
889b489fe9 test: add assert.deepNestedInclude and assert.notDeepNestedInclude 2017-05-05 00:54:10 +02:00
Johannes Loewe
a5691d32c5 test: add assert.ownInclude and assert.notOwnInclude 2017-05-05 00:54:10 +02:00
Johannes Loewe
479e4c46de test: add assert.nestedInclude and assert.notNestedInclude 2017-05-05 00:54:10 +02:00
Grant Snodgrass
7f8a268e52 fix: always honor custom message 2017-04-04 17:28:19 -04:00
Grant Snodgrass
a253b4c50e docs: remove excessive comments from tests 2017-03-23 18:20:41 -04:00
Grant Snodgrass
8fad9c8000 refactor: rename keep_ssfi to lockSsfi 2017-03-23 18:20:41 -04:00
Grant Snodgrass
b584b94c24 fix: remove frames from assert interface stack
- 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
2017-03-23 18:20:41 -04:00
Grant Snodgrass
4b090100aa fix: remove frames from bdd interface stack
- 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
2017-03-23 18:20:38 -04:00
Grant Snodgrass
cf84f95505 feat: improve keep_ssfi flag
- 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`.
2017-03-23 18:04:15 -04:00
Keith Cirkel
ef2bf66d7c Merge pull request #899 from lucasfcosta/throw-for-non-functions-on-instanceof
Throw error when instanceof is passed something that is not a function as constructor
2017-03-23 09:55:55 +00:00
Keith Cirkel
011612c7b3 Merge pull request #924 from meeber/fix-not-have-keys
fix: make negated `.keys` consider size of sets
2017-03-23 09:54:24 +00:00
lucasfcosta
011815305a Throw error when instanceof is passed something that is not a function as constructor 2017-02-15 21:56:26 -02:00
Grant Snodgrass
a6e172168c test: add .own.include and .nested.include 2017-02-02 18:47:50 -05:00
Grant Snodgrass
f37d2c223b fix: make negated .keys consider size of sets
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.
2017-01-30 18:34:42 -05:00
Aleksey Shvayka
c5ca76c551 Refactor utils.addChainableMethod helper (#900)
* replace __proto__ with Object.setPrototypeOf

* remove hardcoded keys

* cache non-configurable keys
2017-01-12 19:14:29 -02:00
Grant Snodgrass
bf71196c7f test(includeStack): add should interface
Only the `expect` interface was being tested for correct stack traces.
This commit adds identical tests for the `should` interface.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
b88e53639e fix: remove proxy frames from stack traces
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.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
8fa4f78574 test(includeStack): improve tests
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.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
5a1e6764d6 refactor(proxify): move feature detection to util
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.
2017-01-03 16:21:16 -05:00
Grant Snodgrass
ce9a2c283b feat(utils): add length guard to methods
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.
2017-01-02 21:00:51 -05:00
Grant Snodgrass
ae69f27532 refactor(lengthOf): favor it over length
- 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`.
2017-01-02 12:04:12 -05:00
Grant Snodgrass
8a2ef676e3 test: comment out broken tests in Safari 10 (#869)
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.
2016-11-17 09:36:48 -02:00
lucasfcosta
93be4b15d9 Use external get-func-name module 2016-10-16 11:10:36 -02:00
Grant Snodgrass
abbc771aff Update type-detect to v3.0.0 and fix issues
- 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
2016-10-09 09:59:32 -04:00
lucasfcosta
a33ab48186 Use external pathval module instead of internal util modules 2016-10-08 19:16:11 -03:00
Aleksey Shvayka
2ef786d254 Add .empty to assert interface (#828)
* improve jsdoc

* add .empty to assert interface

* add assert.empty tests

* add Map and Set to jsdoc
2016-10-05 12:28:22 -03:00
Aleksey Shvayka
ac0c5f1a16 Do not suppress TypeErrors thrown on integrity checks (#823)
* document behavior for primitives

* simplify integrity checks

* add regression tests

* better tests

* update comment

* add comments to tests
2016-10-04 15:20:42 -03:00
Aleksey Shvayka
fdd0f8cffe Make utils.getName more robust & use it in empty (#813)
* use utils.getName

* remove extra .to in tests

* make getName even more robust

* add basic tests
2016-10-02 15:57:40 -04:00
Aleksey Shvayka
c38bfec30c Make empty assertion work with es6 collections (#814)
* support Map and Set

* throw on weak collections

* called on => passed

* account for partial implementations
2016-10-02 15:33:59 -03:00
Aleksey Shvayka
5b170b2e3b Make 'empty' throw on non-string primitives and functions (#812)
* 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
2016-10-01 15:58:45 -03:00