Skip to content

Instantly share code, notes, and snippets.

@marcelmokos
Last active December 22, 2018 22:00
Show Gist options
  • Save marcelmokos/6aa09a8c73b225c5923633825e10d4d7 to your computer and use it in GitHub Desktop.
Save marcelmokos/6aa09a8c73b225c5923633825e10d4d7 to your computer and use it in GitHub Desktop.
test two elements have same classes
/*-------- Promise.then() syntax ---------*/
// when expect() is in Promise.then() method body
// we have to use callback function done()
it("test two inputs to have labels with same classes using Promise.then() ", (done) => {
getInputsLabelElement(input1).then((label1) => {
getInputsLabelElement(input2).then((label2) => {
label1.getAttribute("class").then((label1Classes) => {
label2.getAttribute("class").then((label2Classes) => {
expect(label1Classes).toBe(label2Classes);
done();
});
});
});
});
});
/*-------- async await syntax ------------*/
// once you use async await we do not have to use callback function
// and we have more controle over test
it("test two inputs to have labels with same classes using async await", async () => {
const label1 = await getInputsLabelElement(input1);
const label2 = await getInputsLabelElement(input1);
expect(await label1.getAttribute("class")).toBe(await label2.getAttribute("class"));
});
@Elte156
Copy link

Elte156 commented Dec 22, 2018

I think L24 should be input2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment