Repository: chaijs/chai
Pull request #1273 (2019-07-11 22:02:46)

chore: modified the error message
This PR is to address the issue https://github.com/chaijs/chai/issues/1263.
The modified message is as mentioned in the closed PR:
https://github.com/chaijs/chai/pull/1267
```
AssertionError: the given combination of arguments (object and string) is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a string.
```
I didn't add or modify any tests yet, I'll update the tests once modifications are fine.

Thank you.

codecov[bot]: # [Codecov](https://codecov.io/gh/chaijs/chai/pull/1273?src=pr&el=h1) Report
> Merging [#1273](https://codecov.io/gh/chaijs/chai/pull/1273?src=pr&el=desc) into [master](https://codecov.io/gh/chaijs/chai/commit/03913cbaa18c262d46a3b2bf0b21c3991bfe7658?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/chaijs/chai/pull/1273/graphs/tree.svg?width=650&token=J8Fz3KwOQq&height=150&src=pr)](https://codecov.io/gh/chaijs/chai/pull/1273?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1273   +/-   ##
=======================================
  Coverage   94.61%   94.61%           
=======================================
  Files          33       33           
  Lines        1708     1708           
  Branches      416      416           
=======================================
  Hits         1616     1616           
  Misses         92       92
```


| [Impacted Files](https://codecov.io/gh/chaijs/chai/pull/1273?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [lib/chai/core/assertions.js](https://codecov.io/gh/chaijs/chai/pull/1273/diff?src=pr&el=tree#diff-bGliL2NoYWkvY29yZS9hc3NlcnRpb25zLmpz) | `99.39% <ø> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/chaijs/chai/pull/1273?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/chaijs/chai/pull/1273?src=pr&el=footer). Last update [03913cb...ab55d76](https://codecov.io/gh/chaijs/chai/pull/1273?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js
index 4d3fb82..5c071fb 100644
--- a/lib/chai/core/assertions.js
+++ b/lib/chai/core/assertions.js
@@ -533,8 +533,13 @@ module.exports = function (chai, _) {
         // objects with a custom `@@toStringTag`.
         if (val !== Object(val)) {
           throw new AssertionError(
-            flagMsg + 'object tested must be an array, a map, an object,'
-              + ' a set, a string, or a weakset, but ' + objType + ' given',
+            flagMsg + 'the given combination of arguments ('
+            + objType + ' and '
+            + _.type(val).toLowerCase() + ')'
+            + ' is invalid for this assertion. '
+            + 'You can use an array, a map, an object, a set, a string, '
+            + 'or a weakset instead of a '
+            + _.type(val).toLowerCase(),
             undefined,
             ssfi
           );
@@ -3120,12 +3125,12 @@ module.exports = function (chai, _) {
    *
    * It can also be chained with `.contain` or `.include`, which will work with
    * both arrays and strings:
-   * 
+   *
    *     expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
    *     expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
    *     expect([1,2,3]).to.contain.oneOf([3,4,5])
    *     expect([1,2,3]).to.not.contain.oneOf([4,5,6])
-   * 
+   *
    * `.oneOf` accepts an optional `msg` argument which is a custom error message
    * to show when the assertion fails. The message can also be given as the
    * second argument to `expect`.


Test patch:
diff --git a/test/assert.js b/test/assert.js
index fd22d99..1842f36 100644
--- a/test/assert.js
+++ b/test/assert.js
@@ -720,19 +720,31 @@ describe('assert', function () {
 
     err(function(){
       assert.include(true, true, 'blah');
-    }, "blah: object tested must be an array, a map, an object, a set, a string, or a weakset, but boolean given");
+    },
+      "blah: the given combination of arguments (boolean and boolean) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a boolean"
+    );
 
     err(function () {
       assert.include(42, 'bar');
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but number given");
+    },
+      "the given combination of arguments (number and string) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a string"
+    );
 
     err(function(){
       assert.include(null, 42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but null given");
+    },
+      "the given combination of arguments (null and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function () {
       assert.include(undefined, 'bar');
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but undefined given");
+    },
+      "the given combination of arguments (undefined and string) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a string"
+    );
   });
 
   it('notInclude', function () {
@@ -798,19 +810,31 @@ describe('assert', function () {
 
     err(function(){
       assert.notInclude(true, true, 'blah');
-    }, "blah: object tested must be an array, a map, an object, a set, a string, or a weakset, but boolean given");
+    },
+      "blah: the given combination of arguments (boolean and boolean) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a boolean"
+    );
 
     err(function () {
       assert.notInclude(42, 'bar');
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but number given");
+    },
+      "the given combination of arguments (number and string) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a string"
+    );
 
     err(function(){
       assert.notInclude(null, 42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but null given");
+    },
+      "the given combination of arguments (null and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function () {
       assert.notInclude(undefined, 'bar');
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but undefined given");
+    },
+      "the given combination of arguments (undefined and string) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a string"
+    );
 
     err(function () {
       assert.notInclude('foobar', 'bar');
diff --git a/test/expect.js b/test/expect.js
index d7493c3..30c9ba7 100644
--- a/test/expect.js
+++ b/test/expect.js
@@ -2286,39 +2286,66 @@ describe('expect', function () {
 
     err(function(){
       expect(true).to.include(true, 'blah');
-    }, "blah: object tested must be an array, a map, an object, a set, a string, or a weakset, but boolean given");
+    },
+      "blah: the given combination of arguments (boolean and boolean) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a boolean"
+    );
 
     err(function(){
       expect(true, 'blah').to.include(true);
-    }, "blah: object tested must be an array, a map, an object, a set, a string, or a weakset, but boolean given");
+    },
+      "blah: the given combination of arguments (boolean and boolean) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a boolean"
+    );
 
     err(function(){
       expect(42.0).to.include(42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but number given");
+    },
+      "the given combination of arguments (number and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function(){
       expect(null).to.include(42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but null given");
+    },
+      "the given combination of arguments (null and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function(){
       expect(undefined).to.include(42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but undefined given");
+    },
+      "the given combination of arguments (undefined and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function(){
       expect(true).to.not.include(true);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but boolean given");
+    },
+      "the given combination of arguments (boolean and boolean) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a boolean"
+    );
 
     err(function(){
       expect(42.0).to.not.include(42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but number given");
+    },
+      "the given combination of arguments (number and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function(){
       expect(null).to.not.include(42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but null given");
+    },
+      "the given combination of arguments (null and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function(){
       expect(undefined).to.not.include(42);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but undefined given");
+    },
+      "the given combination of arguments (undefined and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
   });
 
   it('deep.include()', function () {
diff --git a/test/should.js b/test/should.js
index b7e1d27..8a44913 100644
--- a/test/should.js
+++ b/test/should.js
@@ -1931,19 +1931,31 @@ describe('should', function() {
 
     err(function(){
       (true).should.include(true, 'blah');
-    }, "blah: object tested must be an array, a map, an object, a set, a string, or a weakset, but boolean given");
+    },
+      "blah: the given combination of arguments (boolean and boolean) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a boolean"
+    );
 
     err(function(){
       (42).should.include(4);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but number given");
+    },
+      "the given combination of arguments (number and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
 
     err(function(){
       (true).should.not.include(true);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but boolean given");
+    },
+      "the given combination of arguments (boolean and boolean) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a boolean"
+    );
 
     err(function(){
       (42).should.not.include(4);
-    }, "object tested must be an array, a map, an object, a set, a string, or a weakset, but number given");
+    },
+      "the given combination of arguments (number and number) is invalid for this assertion. " +
+      "You can use an array, a map, an object, a set, a string, or a weakset instead of a number"
+    );
   });
 
   it('deep.include()', function () {