to contain

  • <Set> [not] to contain <any>

Asserts that a Set instance contains a given element.

expect(new Set([1, 2, 3]), 'to contain', 3);

You get a diff when the assertion fails:

expect(new Set([1, 2, 3]), 'to contain', 4);
expected Set([ 123 ]) to contain 4
 
Set([
  
1,
  
2,
  
3
  
//
 
missing 4
])

The assertion can be negated using the not flag:

expect(new Set([1, 2, 3]), 'not to contain', 4);
expect(new Set([1, 2, 3]), 'not to contain', 3);
expected Set([ 123 ]) not to contain 3
 
Set([
  
1,
  
2,
  
3 
//
 
should be removed
])