Cypress简介

Cypress

gi node >> .gitignore

npm init

npm i --save-dev cypress
vim package.json
{
    "scripts": {
        "e2e:open": "cypress open",
        "e2e:run": "cypress run"
    },
}
npm run e2e:open

Testing

vim cypress/integration/examples/window.spec.js
/// 

context('Window', () => {
    beforeEach(() => {
        cy.visit('https://domain.com')
    })

    it('cy.window() - login test', () => {
        cy.get('#phone').type('123')
        cy.get('#password').type('321')
        cy.get('.ant-btn-primary').click()
    })
})
npm run e2e:open

npm run e2e:run

Reporter

npm i --save-dev mocha mochawesome mochawesome-merge

vim cypress.json
{
    "reporter": "mochawesome",
    "reporterOptions": {
        "reportDir": "cypress/report",
        "html": true,
        "json": false
    }
}
npm run e2e:run

Git保留文件夹且忽略文件夹下所有文件的.gitignore配置

report/*
!report/.gitkeep

References

  • Lovely HTML reports for Cypress.io with Mochawesome

  • Generate a Beautiful Test Report from running Tests on Cypress.io

  • TypeError when using mochawesome reporter

你可能感兴趣的:(Cypress简介)