Skip to content

Commit 9dba9b1

Browse files
committed
added helper functions in commands.js
1 parent d3eb5db commit 9dba9b1

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

cypress/support/commands.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,30 @@
2525
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
2626

2727
import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/command'
28+
import { size } from 'cypress/types/lodash'
2829

29-
addMatchImageSnapshotPlugin()
30+
addMatchImageSnapshotPlugin()
31+
32+
Cypress.Commands.add('isVisible', selector => {
33+
cy.get(selector).should('be.visible')
34+
})
35+
36+
Cypress.Commands.add('isHidden', selector => {
37+
cy.get(selector).should('not.exist')
38+
})
39+
40+
Cypress.Commands.add('setResolution', size => {
41+
if (Cypress._.isArray(size)) {
42+
cy.viewport(size[0], size[1])
43+
} else {
44+
cy.viewport(size)
45+
}
46+
})
47+
48+
Cypress.Commands.add('login', (username, password) => {
49+
cy.get('#login_form').should('be.visible')
50+
cy.get('#user_login').type(username)
51+
cy.get('#user_password').type(password)
52+
cy.get('#user_remember_me').click()
53+
cy.contains('Sign in').click()
54+
})

0 commit comments

Comments
 (0)