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

Typescript requires that the argument passed is undefined

Typescript: 2.4.1 I am exploring the creation of a helper function to produce redux action creators. Here is what I have: interface IAction<T extends string, P = undefined> { type: T; payload: P; } function createAction<T extends strin ...

Investigating TypeScript Bugs in Visual Studio Code

As I navigate through various sources, I notice that there is a plethora of information available on older versions of VSCode (v1.16.1 - the most recent version at the time of writing) or deprecated attributes in the launch.json file. I have experimented ...

Can you explain the functionality of this Observable in the context of this Angular 2 example?

I'm not too familiar with JavaScript/TypeScript and I have a question about how this code snippet works: onGet() { this.serverService.getServers() .subscribe( (servers: any[]) => this.servers = servers, // an array of anythin ...

Bring in properties from a separate file in Vue3

Currently, I am utilizing Vue3 along with the options API. Within my setup, there are various Vue components that rely on a shared prop defined as: exercise: { type: Object as PropType<Exercise>, required: true, }, To streamline this pro ...

Error: TypeScript cannot find @types declaration for restify-client

Currently, I am attempting to upgrade to the most recent version of restify (6.4.2). Our application is written in TypeScript. The clients have now been separated into their own package starting from the previous version of restify we were using (4.3.2) - ...

Dealing with changing elements using cucumber and capybara

(Click for image) I've been working on a project where I need to create a scenario to test the login feature. However, I've encountered an issue with Capybara not being able to access dynamic elements. To Reproduce the Issue: 1) Go to Redfin.co ...

Wait for a minimum of X milliseconds using RxJS

I'm attempting to achieve a specific functionality using RxJS: Trigger an event Make an API call Upon receiving the API response, do one of the following: Wait for at least X milliseconds after triggering the event If X milliseconds have already p ...

The sanitizer variable becomes null when accessed outside of the NgOnInit function in Angular using TypeScript

At first, I added DomSanitizer to the component: import { DomSanitizer, SafeResourceUrl} from '@angular/platform-browser'; Next, a class was created and included in the constructor: export class BlocklyComponent implements OnInit { primar ...

Fetching JSON data using Promise.all results in an empty response

I'm facing an issue in my code where I am trying to fetch data from two different JSON files and then return them as arrays. Even after implementing the solution below, it doesn't seem to be working as expected. Can someone guide me on how I can ...

Steps to create a formGroup in Angular 12

import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-signup', templateUrl: './signup.component.html', ...

Angular 5 error: Decorators do not support function expressions

I am struggling to compile my angular project using the command ng build --prod The issue arises in the IndexComponent : index.componenent.ts import { Component, OnInit } from '@angular/core'; import { indexTransition } from './index.anim ...

Adding TH into a TABLE in Angular 2 by verifying TD elements

I am seeking a way to automatically generate thead and th, using td in the template : <Datatable> <tr #lineSelected *ngFor="let subscription of results"> <td nameColumn="Nom">{{subscription.name}}</td> <td n ...

Having trouble launching the freshly developed Angular app

I'm encountering an issue with my newly created app - I can't seem to launch it. Error: The loader “C:/C#/Angular/my-app/src/app/app.component.css” is not providing a string as expected. I've attempted reinstallation of Angular and Nod ...

Encountering an XHR error when using a systemjs module in TypeScript

Error: GET http://localhost:63342/Dog.js 404 (Not Found) XHR error (404 Not Found) loading http://localhost:63342/Dog.js <br/><br/>Below is the script in my index.html file. ...

Incorporate a JavaScript script into an Angular 9 application

I have been experiencing issues trying to add a script.js file to angular.json and use it in one component. Adding a script tag directly to my HTML file is not the ideal solution. Can someone suggest an alternative approach or point out what I may be missi ...

The build error TS1036 is thrown when a function with a return statement is moved to index.d.ts, even though it worked perfectly in a standard TS file

In my project using Node v14.x and StencilJS (React) v2.3.x, I encountered an issue with a test-helper file containing a function that converts string-arrays to number-arrays: export function parseNumericStringOrStringArrayToIntegers(value: string | (strin ...

Managing optgroup in select dropdown using Angular 4

Is there a way to retrieve the optgroup label value within an onchange function on a select box in Angular 4? In my form, I have a select box with multiple dates as option groups and time slots in 24-hour format for booking (e.g. 1000 for 10AM, 1200 for 1 ...

What could have caused the sudden halt of fetching on all server branches in the backend?

Following a code refactor on a separate branch, the fetch function ceases to work in any branch despite everything else functioning correctly. The error message reads: ...server/KE/utils.ts:44 const response = await fetch( ^ ReferenceError ...

What techniques can I use to modify an object while it's being iterated through?

I've been attempting to manipulate the object while looping through it, but unfortunately, it's not working. How can I modify it so that the constant patient includes the property lastActivity inside the this.model array? My code looks like this ...

Reacting to shared routes across various layouts

My React application has two layouts: GuestLayout and AuthLayout. Each layout includes a Navbar, Outlet, and Footer, depending on whether the user is logged in: AuthLayout.tsx interface Props { isAllowed: boolean redirectPath: string children: JSX.E ...