Cypress error: Unable to access 'uid' property as it is undefined

Recently in my Cypress project with TypeScript support utilizing the Cucumber Preprocessor, an unexpected exception has started appearing:

 TypeError: Cannot read properties of undefined (reading 'uid')

There are instances where changing to a different workspace resolves the issue temporarily. However, the error persists when opening the Cypress runner or executing tests in Jenkins.

Cypress Runner: (v8.4.0)

https://i.stack.imgur.com/D0GuT.png

Jenkins Console: (v8.7.0)

An error was encountered when invoking the function exported by the plugins file at `C:\Jenkins\workspace\ABC\cypress\plugins\index.js`.

 TypeError: Cannot read properties of undefined (reading 'uid')
   <error trace here>
error Command failed with exit code 1.

plugins/index.js

const resolve = require('resolve');
const cucumber = require("cypress-cucumber-preprocessor").default;
const cypressBrowserify = require("@cypress/browserify-preprocessor");
...

support/index.ts

import './commands';
import '@shelex/cypress-allure-plugin/reporter';
import 'cypress-xpath';
import 'cypress-plugin-tab';   

Cypress.on('uncaught:exception', (err, runnable) => {
  cy.log(`Uncaught Exception: ${JSON.stringify(err)}`);

  return false;
});

Answer №1

I encountered a similar problem when trying to initiate the test on my local machine. Interestingly, no errors occurred when running tests through a Git actions workflow. I found the solution in a comment by "aidanhyland," which can be viewed here: https://github.com/cypress-io/cypress/issues/19674#issuecomment-1012212527
It's important to note that the issue is not related to the presence of "uid" in your code, but rather with the cucumber dependency and how it is resolved.

Answer №2

After attempting various solutions such as cleaning the cache and analyzing the index.js file, I finally found the fix for the problem.

I resolved the issue by first uninstalling Cypress from my machine and then installing version 8.5.0 of Cypress. After doing so, everything started working smoothly.

npm install <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="02617b7270677171423a2c372c32">[email protected]</a>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to set up VS Code's code completion feature to automatically accept punctuation suggestions?

For all the C# devs transitioning to TypeScript in VS Code, this question is directed at you. I was captivated by the code completion feature in VS C#. To paint a clearer picture, let's say I'm trying to write: console.log('hello') W ...

Sign up for a feature that provides an observable exclusively within an if statement

There is an if clause in my code that checks for the presence of the cordova object in the window global object. If cordova is present, it will make a http request and return the default angular 2 http observable. If the application is in a web context wh ...

What is the best way to run tests on this method using Jest?

import { format, getDaysInMonth, getMonth, getYear, isValid, parse } from "date-fns"; export class DateService { public getDaysInMonth(month?: Date) { return getDaysInMonth(month || new Date()); } What is the best way to test this func ...

Struggling to refine the result set using jsonpath-plus

Utilizing the jsonpath-plus module (typescript), I am currently working on navigating to a specific object within a json document. The target object is nested several levels deep, requiring passage through 2 levels of arrays. When using the following jsonp ...

Exploring with Cucumber and Selenium: is there a way to view the browser's perspective?

While working on a scenario in Rails with Cucumber, I encountered an issue where it couldn't locate the edit link to click on. When I manually checked the page, the link was there. I know I must be missing something, but I can't pinpoint what it ...

Converting a string[] to an EventEmitter string[] in Angular 4 with TypeScript: Step-by-step guide

Programming Language: Typescript – written as .ts files Development Framework: Angular 4 I'm currently working on an application that is supposed to add chips (similar to tags in Angular 1) whenever a user types something into the input box and hi ...

In the latest version of Angular, accessing document.getelementbyid consistently returns null

I am struggling with a component that looks like this export class NotificationPostComponent extends PostComponent implements OnInit, AfterViewInit { commentsDto: IComment[] = []; commentId = ''; ngOnInit(): void { this.route.data ...

I'm attempting to retrieve mlab data in the console using node.js, but unfortunately encountering an error

I came across this helpful YouTube tutorial:https://www.youtube.com/watch?v=PFP0oXNNveg&t=460s. I followed the steps outlined in the video and made necessary code adjustments based on current updates found through a Google search (to resolve errors enc ...

A guide on cycling through keys in an object with changing values using Typescript

Struggling with a beginner question here - I'm having trouble iterating through an object with dynamic keys in Typescript //This is how I've typed my object let obj: { [key: string]: string } = {}; Using forEach or map isn't working and thr ...

The data type 'string' cannot be assigned to the data type 'Position'

Currently, I am in the process of converting React js to typescript. The component being used is a Class Component. I would like to obtain CSS settings through props and apply them to an element. How can I resolve this issue? render(){return( <span st ...

Typescript - A guide on updating the value of a key in a Map object

My Map is designed to store Lectures as keys and Arrays of Todos as values. lecturesWithTodos: Map<Lecture, Todos[]> = new Map<Lecture, Todos[]>(); Initially, I set the key in the Map without any value since I will add the Todos later. student ...

Limit input to numbers only in Semantic UI React Form Field

I've developed a custom CurrencyInput React component for users to input numeric values. I set the input type to "number", but unfortunately, this only seems to function properly in Chrome (as Firefox still allows non-numeric entries). Here is the co ...

Display a separate component within a primary component upon clicking a button

Looking to display data from a placeholder module upon component click. As a beginner with React, my attempts have been unsuccessful so far. I have a component that lists some information for each element in the module as a list, and I would like to be ab ...

Is it possible for an object's property specified in a TypeScript interface to also incorporate the interface within its own declaration?

While it may seem like an unusual request, in my specific scenario, it would be a perfect fit. I am working with an object named layer that looks something like this: const layer = { Title: 'parent title', Name: 'parent name', ...

Determine the data type of an object's key

I have a XInterface defined as: export interface XInterface { foo: (() => Foo[]) | Foo[], bar: string, baz: number } When declaring an object using this interface, I want the type of foo to be Foo[], like so: const myObj: XInterface = { ...

Attempting to transfer files to and from Firebase storage

Having trouble with my React Native app. I am trying to upload files, whether they are pictures or PDFs, but once uploaded, I can't seem to open them. However, "The files are getting uploaded to the storage." export const uploadToStorage = async (docu ...

Using an asynchronous pipe filter with the ngFor loop in Angular 2 for efficient data

I have a JSON array that I need to iterate through in order to display data using an NGfor Loop. My goal is to apply filters after the data has been loaded to refine the results. The issue I am facing is that my pipe filter is returning 'cannot read p ...

Error: Trying to modify an immutable property 'title' of object '#<Object>' - React JS and Typescript

Whenever I press the Add button, all input values are stored in a reducer. However, if I append any character to the existing value in the input fields, it triggers the following error: Cannot assign to read only property 'title' of object &apos ...

What could be causing a blank page to appear after being redirected? (Using NextJS 13 API Route)

After struggling with this issue for 2 days, I'm throwing in the towel and reaching out to the community for assistance. I've been tasked with setting up a basic login system for a new project using NextJS v13. However, it seems like a lot has c ...

Expanding the typings for an established component in DefinitelyTyped

Is there a way to define new typings for additional props in DefinitelyTyped? After updating the material-ui library with some new props for the SelectField component, I realized that the typings in DefinitelyTyped are outdated. Is it possible to extend th ...