1

I am getting this error when try to run the test in Cypress. Can someone help me how to resolve this, please?

This is my index.js

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')

Cypress.on('uncaught:exception', (err, runnable) => {
  // returning false here prevents Cypress from
  // failing the test
  return false
})

enter image description here

ChinS
  • 199
  • 2
  • 11

4 Answers4

3

The line where it errors

const env = process.env

is only valid in NodeJS, where process is a global object supplied by the Node runtime.

Cypress has both a Node process to which you can add plugins via the file cypress/plugins/index.js and a Browser process where you can add code to cypress/support/index.js.

The error comes from a package called ci-info, so it looks like you have imported it or something that uses it into cypress/support/index.js or cypress/support/commands.js, or directly into a test.

Please check all your imports.

user16695029
  • 3,365
  • 5
  • 21
  • I just cloned a legacy automation project. It is page object model test automation framework. One of the page class has this `module.exports = { commands: [pageCommands], elements: require('../lib/util.js').getElements( process, require('path').basename(__filename).replace('.js','') ) };` How to fix this? – paul Mar 12 '23 at 10:56
2

I had to remove import "cypress" from my test. That fixed it. 9.7.0

FBB
  • 326
  • 1
  • 12
1

This happened for me when I imported cypress within my test, removing that fixed the issue

Krupal Vaghasiya
  • 536
  • 7
  • 21
-1

This was the issue in my case , I removed it from my test's file. Now, Its working

const cypress = require("cypress");
GHULAM NABI
  • 498
  • 5
  • 15