Skip to content

Commit 5c8a3d2

Browse files
committed
Replace callback-based assertion with native Cypress `.should('contain')
1 parent 2c789f0 commit 5c8a3d2

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

ui-tests/cypress/support/commands.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,24 @@ Cypress.Commands.add("shouldNotBeHasDisabledClass", (element) => {
220220

221221
Cypress.Commands.add("shouldContainText", (element, text) => {
222222

223-
cy.getElement(element).then(($el) => {
223+
setDebugContext({
224+
assertion: 'contain text',
225+
expected: text
226+
});
224227

225-
const actual = $el.text().trim();
228+
cy.getElement(element)
229+
.should('contain', text)
230+
.then($el => {
226231

227-
setDebugContext({
228-
assertion: 'contain text',
229-
expected: text,
230-
actual
231-
});
232+
const actual = $el.text().trim();
232233

233-
expect(actual).to.contain(text);
234+
setDebugContext({
235+
assertion: 'contain text',
236+
expected: text,
237+
actual
238+
});
234239

235-
});
240+
});
236241

237242
});
238243

0 commit comments

Comments
 (0)