How can I write my test so that it expects my array to contain a specific string? I've tried what I have below and some other methods such as using array.includes
but can't get it to work properly.
let value = "test4";
let dropdownValues = ["test1", "test2", "test3", "test4"];
expect(dropdownValues).toHaveTextContaining(value);
CodePudding user response:
The way to go about this is to set a variable that checks if the array contains a certain string and use that variable in the expect statement:
let value = "test4";
let dropdownValues = ["test1", "test2", "test3", "test4"];
let valueExist = dropdownValues.includes(value);
expect(valueExist).toEqual(true);