Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jest expect string to contain substring

try {
    throw new Error("Username already in use. Sorry 282378292"); 
} catch (error) {
    expect(error.message).toEqual(expect.stringContaining("Username already in use"));
}
 
PREVIOUS NEXT
Tagged: #jest #expect #string #substring
ADD COMMENT
Topic
Name
6+9 =