Matchers
toBeOk
Expects the actual value to be ok.
Basic Usage
await I.expect("mySelector").toBeOk();
toExist
Expects actual element to exist.
Basic Usage
await I.expect("mySelector").toExist();
toEqual
Expects the actual value to be equal to the expected value, using deep equality comparison.
Parameter | Type | Description |
---|---|---|
expected | any | Expected value. |
Basic Usage
const inputValue = `hello world`;
await I.expect(inputValue).toEqual(`hello world`);
toBeSameAs
Expects the actual value to be same as the expected.
Parameter | Type | Description |
---|---|---|
expected | any | Expected value. |
Basic Usage
await I.expect("mySelector").toBeSameAs("mySelectorToCompare");
toBeSameJSONAs
Expects the actual value to have the same JSON as the expected.
Parameter | Type | Description |
---|---|---|
expected | any | Expected value. |
Basic Usage
let scrollPosition = await I.getScrollPosition();
await I.expect(scrollPosition).toBeSameJSONAs({ left: 0, top: 0 });
toBeAtLeast
Expect the actual value to be greater than or equal to the expected value. For an array, it compares if the actual array contains at least all the values of array. For an object, it compares if actual object contains at least the keys values of the expected object.
Parameter | Type | Description |
---|---|---|
expected | number / [] / {} | Expected value. |
Basic Usage
await I.expect(["a","b","c"]).toBeAtLeast(["b","c"]); //array length is 3
toBeAtMost
Expect the actual value to be lower than or equal to the expected value. For an array, it asserts whether an actual array contains some or all the expected values of expected array and nothing else. For an array, it asserts whether an actual object contains some or all the expected keys values of expected object and nothing else.
Parameter | Type | Description |
---|---|---|
expected | number / [] / {} | Expected value. |
Basic Usage
await I.expect(["c"]).toBeAtMost(["b","c"]);
toBeGreaterThan
Expect the actual value to be greater than or equal to the expected value. For an array, it . For an object, it compares the value of the object keys.
Parameter | Type | Description |
---|---|---|
expected | number / [] / {} | Expected value. |
Basic Usage
await I.expect(3).toBeGreaterThan(2);
toBeLessThan
Expect the actual value to be lower than or equal to the expected value. For an array, it compares the array length. For an object, it compares the value of the object keys.
Parameter | Type | Description |
---|---|---|
expected | number / [] / {} | Expected value. |
Basic Usage
await I.expect(1).toBeLessThan(2);
toBeBetween
Parameter | Type | Description |
---|---|---|
expectedLower | number / [] / {} | |
expectedUpper | number / [] / {} |
Basic Usage
await I.expect(1).toBeBetween(0,2);
toContainAllOf
Expects the actual value to contains all of the expected values.
Parameter | Type | Description |
---|---|---|
expected | any[] | Expected value. |
Basic Usage
await I.expect(["a","b","c"]).toContainAllOf(["c","b","a"]);
toContainAnyOf
Expects the actual value to contains any of the expected values.
Parameter | Type | Description |
---|---|---|
expected | any[] | Expected value. |
Basic Usage
await I.expect(["a","b"]).toContainAnyOf(["a","b","c"]);
toContain
Expects the actual value to contains some of the expected values.
Parameter | Type | Description |
---|---|---|
expected | string / any[] | Expected value. |
Basic Usage
await I.expect("text example").toContain("exam");
toStartWith
Expects the actual value to start with the expected value.
Parameter | Type | Description |
---|---|---|
expected | string | Expected value. |
Basic Usage
await I.expect("mySelector").toStartWith("my");
toEndWith
Expects the actual value to end with the expected value.
Parameter | Type | Description |
---|---|---|
expected | string | Expected value. |
Basic Usage
await I.expect("mySelector").toEndWith("lector");
toMatch
Expects the actual value to match a regEx.
Parameter | Type | Description |
---|---|---|
expected | RegExp | Expected regEx. |
Basic Usage
await I.expect("a").toMatch(/[ab]/g);
toBeInstanceOf
Expects the actual value to be of a specific instance.
Parameter | Type | Description |
---|---|---|
expected | any | Expected instance. |
Basic Usage
class Foo { }
class Bar { }
let bar = new Bar();
await I.expect(bar).toBeInstanceOf(Bar).and.not.toBeInstanceOf(Foo);
toBeOfType
Expects the actual value to be of a specific type.
Parameter | Type | Description |
---|---|---|
expected | string | Expected type. |
Basic Usage
await I.expect(targetElement.innerText).toBeOfType('string');
toBeBoolean
Expects the actual value to be of boolean type.
Basic Usage
await I.expect(true).toBeBoolean();
toBeTrue
Expects the actual value to be true.
Basic Usage
await I.expect(1===1).toBeBoolean();
toBeFalse
Expects the actual value to be false.
Basic Usage
await I.expect(1===2).toBeFalse();
toBeFalsy
Expects the actual value to be falsy.
Basic Usage
await I.expect(1==2).toBeFalsy();
toBeUndefined
Expects the actual value to be undefined.
Basic Usage
let a;
await I.expect(a).toBeUndefined();
toBeNull
Expects the actual value to be null.
Basic Usage
await I.expect(null).toBeNull();
toBeNan
Expects the actual value not to be a number.
Basic Usage
await I.expect("mySelector").toBeNan();
toThrow
Expect expression to throw something.
Parameter | Type | Description |
---|---|---|
expected | string / RegExp / ((ex: Error) => boolean) |
Basic Usage
await I.expect(Error).toThrow("Expected error message");
toHavePDFField
Expects the parsed PDF to have a field with the specified name or id and value equal to the expected value.
Parameter | Type | Description |
---|---|---|
fieldBy | name or id | Field identification type (name or id). |
expected | string | Expected field value. |
Basic Usage
const pdfParsed = await I.parsePDF(`./src/assets/files/test-pdf.pdf`);
await I.expect(pdfParsed).toHavePDFField('name', 'link');
toHavePDFFieldValue
Expects the parsed PDF to have a field with the specified name or id and value equal to the expected value (field V).
Parameter | Type | Description |
---|---|---|
fieldBy | name or id | Field identification type (name or id). |
fieldIdOrNameValue | string | Field id or name value. |
expected | string or undefined | Expected field value. |
Basic Usage
const pdfParsed = await I.parsePDF(`./src/assets/files/test-pdf.pdf`);
await I.expect(pdfParsed).toHavePDFFieldValue('id', 'BXA', '1 item');
not
Keyword to negate an assertion.Invert the matcher following this expect.
Basic Usage
await I.expect(12).not.toBeUndefined();
or
Keyword to have an or condition between several assertions.
Basic Usage
await I.expect(Selector("#idElement")).toExist().or.toBeUndefined();
and
Keyword to chain assertions.
Basic Usage
await I.expect(Selector("#idElement")).toExist().and.toBeVisible();