Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress 12.3.0 usage example #29

Open
teone opened this issue Jan 24, 2023 · 2 comments
Open

Cypress 12.3.0 usage example #29

teone opened this issue Jan 24, 2023 · 2 comments

Comments

@teone
Copy link

teone commented Jan 24, 2023

Hi there,
thanks for creating this plugin!

As per https://docs.cypress.io/guides/tooling/plugins-guide#Using-a-plugin the cypress/plugins/index.js is deprecated after v10, is there an example on how to import this in a later version?

Thanks in advance!

@tomardern
Copy link

tomardern commented Apr 20, 2023

We're using Cypress 12.4.0, here is an example cypress.config.ts file:

import fs from 'fs'
import pactCypressPlugin from '@pactflow/pact-cypress-adapter/dist/plugin'
const { defineConfig } = require('cypress')

export default defineConfig({
  morgan: false,
  chromeWebSecurity: false,
  defaultCommandTimeout: 10000,
  viewportWidth: 1280,
  viewportHeight: 720,
  downloadsFolder: './downloads',
  fixturesFolder: './fixtures',
  screenshotsFolder: './screenshots',
  videosFolder: './videos',
  e2e: {
    specPattern: './e2e/**/*.cy.{js,jsx,ts,tsx}',
    supportFile: './support/e2e.{js,jsx,ts,tsx}',
    screenshotOnRunFailure: false,
    experimentalRunAllSpecs: true,
    video: false,
    setupNodeEvents (on, config) {
      pactCypressPlugin(on, config, fs)

      return config
    },
  },
})

In our /support/index.ts file we have:

import '@pactflow/pact-cypress-adapter'

before(() => {
  cy.setupPact('frontend-e2e', 'api')
  cy.intercept('{BACKEND-API-URL-HERE}**').as('api')
})

after(() => {
  cy.usePactWait(['api'])
})

Seems to work for us. Good luck!

@YOU54F
Copy link
Member

YOU54F commented Apr 20, 2023

nice @tomardern

we have an open pr to add a cypress 10 example here

#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants