to end with

  • <string> [not] to end with <string>

Asserts that a string ends with a given string.

expect('Hello beautiful world!', 'to end with', 'world!');

In case of a failing expectation you get the following output:

expect('Hello world!', 'to end with', 'foo');
expected 'Hello world!' to end with 'foo'

If there is a partially matching suffix you'll get a diff with the common part highlighted:

expect('Hello world!', 'to end with', 'Hola, world!');
expected 'Hello world!' to end with 'Hola, world!'
 
Hello world!

This assertion can be negated using the not flag:

expect('Hello world!', 'not to end with', 'earth!');

In case of a failing expectation you get the following output:

expect('Hello beautiful world!', 'not to end with', 'world!');
expected 'Hello beautiful world!' not to end with 'world!'
 
Hello beautiful world!