test: abstract some test data
This commit is contained in:
parent
2efb929a0b
commit
5484762579
|
|
@ -8,5 +8,10 @@
|
|||
"username": "plumrx2",
|
||||
"email": "plumrx2@qq.com",
|
||||
"password": "12345678"
|
||||
},
|
||||
"registered":{
|
||||
"username": "plumrx",
|
||||
"email": "plumrx@qq.com",
|
||||
"password": "12345678"
|
||||
}
|
||||
}
|
||||
|
|
@ -10,10 +10,6 @@ describe('test for login', () => {
|
|||
})
|
||||
|
||||
it('login in home page', () => {
|
||||
// const usrname = 'plumrx1'
|
||||
// const email = 'plumrx1@qq.com'
|
||||
// const password = '12345678'
|
||||
|
||||
cy.fixture('users.json').then(users => {
|
||||
cy.login(users.loginPass)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ describe('test for register', () => {
|
|||
|
||||
it('ligin in home page', () => {
|
||||
// click logup button in home page
|
||||
const usrname = 'plumrx'
|
||||
const email = 'plumrx@qq.com'
|
||||
const password = '12345678'
|
||||
cy.register(usrname, email, password)
|
||||
|
||||
cy.get('.navbar')
|
||||
.should('contain', usrname)
|
||||
cy.fixture('users.json').then(users => {
|
||||
cy.register(users.registered)
|
||||
cy.get('.navbar')
|
||||
.should('contain', 'plumrx')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -44,18 +44,18 @@ Cypress.Commands.add('login', (user) => {
|
|||
.should('contain.text', user.username)
|
||||
})
|
||||
|
||||
Cypress.Commands.add('register', (usrname, email, password) => {
|
||||
Cypress.Commands.add('register', (user) => {
|
||||
// click sign up button in home page
|
||||
cy.get('li.nav-item a.nav-link')
|
||||
.contains(' Sign up')
|
||||
.click()
|
||||
// []属性选择器
|
||||
cy.get('[placeholder="Your Name"]')
|
||||
.type(usrname)
|
||||
.type(user.username)
|
||||
cy.get('[placeholder="Email"]')
|
||||
.type(email)
|
||||
.type(user.email)
|
||||
cy.get('[placeholder="Password"]')
|
||||
.type(password)
|
||||
.type(user.password)
|
||||
cy.get('[type="submit"]')
|
||||
.click()
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue