to start with

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

Asserts that a string start with a given string.

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

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

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

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

expect('Hello world!', 'to start with', 'Hell yeah');
expected 'Hello world!' to start with 'Hell yeah'
 
Hello world!

This assertion can be negated using the not flag:

expect('Hello world!', 'not to start with', 'Heaven');

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

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