3.1.1 • Published 3 years ago

cypress-helper v3.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Pré requisitos

Instalação

npm install cypress-helper cypress-audit

ou

yarn add cypress-helper cypress-audit

Configuração no Cypress

No arquivo "cypress/plugins/index" inserir o seguinte código:

const { lighthouse, prepareAudit } = require('cypress-audit')

import AuditPrinter from 'cypress-helper/dist/audit-printer'

module.exports = (on, config) => {
  on('before:browser:launch', (browser, launchOptions) => {
    prepareAudit(launchOptions)
    if (browser.name === 'chrome' && browser.isHeadless) {
      launchOptions.args.push('--disable-gpu')
      return launchOptions
    }
  })

  on('task', {
    lighthouse: lighthouse(item => {
      const audit = new AuditPrinter(item)
      audit.print()
    }),
  })
}

Utilizando o Lighthouse

require('cypress-audit/commands') ou import 'cypress-audit/commands'

Cypress.Commands.add("lighthouseOptions", (opts) => {
    const customThresholds = {
      performance: 1,
      accessibility: 1,
      seo: 1,
      'best-practices': 1,
      pwa: 1,
      'server-response-time': 1500,
    }
    cy.lighthouse(customThresholds, opts)
})
describe('Test', () => {
  it('Lighthouse - test', () => {
      cy.visit('URL do site')
    cy.lighthouseOptions({ blockedUrlPatterns: ['.firestore.'] })
  })
})
npx cypress run ou yarn cypress run

Utilizando o upload de foto

Dentro da pasta integration, crie um teste e insira o código:

describe("test", () => {
    it("upload test", () => {
        cy.get('input file').attachFile('caminho_da_foto', {
            subjectType: 'drag-n-drop', // caso o upload seja drag-n-drop
            force: true,// força o envio
            allowEmpty: true, // não pode ser empty
        })
    })
})
npx cypress run ou yarn cypress run
3.1.1

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago