bupkis
    Preparing search index...

    These assertions test strings, regular expressions, and pattern matching.

    👉 See to be a string

    Aliases: to be a RegExp, to be a regex, to be a regexp

    Success:

    expect(/hello/, 'to be a RegExp');
    expect(new RegExp('world'), 'to be a regex');
    expect(/[a-z]+/i, 'to be a regexp');

    Failure:

    expect('hello', 'to be a RegExp');
    // AssertionError: Expected 'hello' to be a RegExp

    Negation:

    expect('hello', 'not to be a RegExp');
    

    Aliases: to begin with <string>, to start with <string>

    Success:

    expect('hello world', 'to begin with', 'hello');
    expect('JavaScript', 'to start with', 'Java');

    Failure:

    expect('hello world', 'to begin with', 'world');
    // AssertionError: Expected 'hello world' to begin with 'world'

    Negation:

    expect('hello world', 'not to begin with', 'world');
    

    Success:

    expect('hello world', 'to end with', 'world');
    expect('test.js', 'to end with', '.js');

    Failure:

    expect('hello world', 'to end with', 'hello');
    // AssertionError: Expected 'hello world' to end with 'hello'

    Negation:

    expect('hello world', 'not to end with', 'hello');
    

    Success:

    expect('hello123', 'to match', /\d+/);
    expect('JavaScript', 'to match', /^Java/);
    expect('test@example.com', 'to match', /@/);

    Failure:

    expect('hello', 'to match', /\d+/);
    // AssertionError: Expected 'hello' to match /\d+/

    Negation:

    expect('hello', 'not to match', /\d+/);
    

    Success:

    expect('', 'to be empty');
    

    Failure:

    expect('hello', 'to be empty');
    // AssertionError: Expected 'hello' to be empty

    Negation:

    expect('hello', 'not to be empty');
    

    Success:

    expect('hello', 'to be non-empty');
    expect(' ', 'to be non-empty'); // Whitespace counts as non-empty

    Failure:

    expect('', 'to be non-empty');
    // AssertionError: Expected '' to be non-empty

    Negation:

    PRO TIP: Use "to be empty" instead.

    expect('', 'not to be non-empty');
    

    Aliases: includes <string>, contains <string>, to include <string>, to contain <string>

    Success:

    expect('hello world', 'includes', 'world');
    expect('JavaScript', 'contains', 'Script');
    expect([1, 2, 3], 'to include', 2);
    expect('test string', 'to contain', 'string');

    Failure:

    expect('hello', 'includes', 'world');
    // AssertionError: Expected 'hello' to include 'world'

    Negation:

    expect('hello', 'not to include', 'world');