Cypress mistakenly looks for cypress.config.js instead of .ts and attempts to find a file in an incorrect directory

Working within a NX mono repo, I am running component tests for an Angular app using Cypress. However, I keep encountering an error in the cypress app that occurs when a test reruns after making changes to the testing code:

Your configFile threw an error from: cypress.config.js

We stopped running your tests because your config file crashed.

Searching the repo for a cypress.config.js file only yields cypress.config.ts files, as the entire NX repo is TypeScript-based.

The content of my cypress.config.ts file is as follows:

import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';

export default defineConfig(nxComponentTestingPreset(__filename));

I attempted to resolve the issue by modifying the configuration like this:

import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';

export default defineConfig({
  component: {
    ... nxComponentTestingPreset(__filename),
    devServer: {
      ... nxComponentTestingPreset(__filename).devServer,
      options: {
        projectConfig: {
          ... nxComponentTestingPreset(__filename).devServer.options.projectConfig,
          root: 'apps/angular-app'
        }
      }
    }
  },
});

However, this change did not resolve the problem.

The stack trace error is showing strange behavior by duplicating file paths. It's doubling the path to the component-index.html file:

Error: ENOENT:

no such file or directory, utime '/Users/USER/projects/frontends/apps/angular-app/Users/USER/projects/frontends/apps/angular-app/cypress/support/component-index.html' at utimesSync (node:fs:2047:3)

Could it be related to using a newer version of Angular? When launching the Cypress testing app with

USER@machine angular-app % npx cypress open
, I receive the following warning:

Warning: Component Testing Mismatched Dependencies

We detected that you have versions of dependencies that are not officially supported:

@angular/platform-browser-dynamic. Expected ^=13.0.0 || ^=14.0.0 || ^=15.0.0, found 16.0.1. If you're experiencing problems, downgrade dependencies and restart Cypress.

Blockquote

Answer №1

The source indicates that the correct syntax is as follows:

export default defineConfig({
  component: {
    ...nxComponentTestingPreset(__filename)
    // add your own config here
  }
})

In your initial attempt, it seems you forgot to include the component: {...} wrapper.

I believe the duplication of paths is a result of resolving paths within the configuration. To verify this, you can log the paths generated by

nxComponentTestingPreset(__filename)
.

All paths supplied to component: {...} should be relative, not absolute.

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

Error encountered when attempting to export a TypeScript class from an AngularJS module

In my application using Angular and TypeScript, I have encountered a scenario where I want to inherit a class from one module into another file: generics.ts: module app.generics{ export class BaseClass{ someMethod(): void{ alert(" ...

The solution to resolving setState not updating within a react context

I am encountering a problem where my context does not seem to update when I attempt to modify it using a react hook. The code snippet is provided below, and I have a feeling that I might be overlooking something minor. appContext.tsx import React, { use ...

The "npx prisma db seed" command encountered an issue: Exit code 1 error occurred during the execution of the command: ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts

this is a sample package.json file when I try to execute the command "npx prisma db seed", I encounter the following error: An error occurred while running the seed command: Error: Command failed with exit code 1: ts-node --compiler-options {&qu ...

Leveraging Angular 8's HttpClient to retrieve and display a complex JSON object in an HTML table

I am currently working with Angular 8, where I need to query an endpoint to fetch an object. Upon calling the endpoint using Advanced REST Client, I receive the following JSON response: GET: http://localhost:8090/curso_conductor/ Response: { "dato": [ ...

Managing the outcome of numerous asynchronous calls before accessing the database post-result collection

Hey everyone, I'm just getting started with node.js and I'm working on the following tasks: Calling the AWS API to create Cognito users by passing data. After all requests are completed, inserting all the records into the database. In my code, ...

Validation of emails in Angular through the utilization of reactive forms

Hello there, I'm new to Angular and looking for some assistance. Specifically, I am currently working on validating an email input using a reactive form with the keyup event. registerform:any; ngOnInit(): void { this.registerform = new F ...

IONIC 3 [ERROR] There was a problem encountered during the execution of cordova run android, resulting in an exit code of 1

While trying to run the command 'ionic cordova run android' for Ionic 3, I encountered an error that has left me stumped. Here's a snapshot of the error message: This Result Error [13:29:45] preprocess started ... [13:29:45] deeplinks sta ...

Displaying a default input placeholder in Kendo UI Datepicker for Angular 2

I've recently implemented the [Datepicker feature from Telerik Kendo UI][1] While the datepicker functions perfectly, I have encountered a single issue where it displays undefined when the date value is not defined: [![enter image description here][ ...

"Users have reported that the file upload preview feature in Angular 6 only works after the

I am currently utilizing Angular 6. In my application, I have a simple input type="file" field that passes data to an image source which displays the image I intend to upload. The issue I am facing is that when I select an image for the first time, nothi ...

Adding parameters to Angular HTML element selector directives can be achieved by utilizing the directive's input properties

I have created a straightforward directive that targets an img element. @Directive( { selector: 'img' } ) export class ImageDirective { ... } Is there a way for me to add a boolean parameter to this directive? @Input() enabled: boolean = fals ...

The operation of assigning the value to the property 'baseUrl' of an undefined object cannot be executed

I recently created a JavaScript client using NSWAG from an ASP .NET Rest API. However, I am encountering some errors when attempting to call an API method. The specific error message I am receiving is: TypeError: Cannot set property 'baseUrl' of ...

Angular - Utilizing NgRx selector for efficient data update notifications

Is there a method to create a "data updated" indicator when I am not interested in the actual updated data itself? Consider a scenario with a reducer: const initialState: SomeReducer = { dataInQuestion: Array<SomeDto>, ... } Following an action ...

Visualization of pie charts in Angular2 using Google library

Currently, I am in the process of building a web application using Angular2 that includes a Google pie chart. One of the components of the application is a Directive specifically designed for the pie chart. Below is the code snippet for the Directive: @D ...

Encountered a higher number of hooks rendered compared to the previous render error on a component without any conditional hook usage

Within my codebase, I have a component that is responsible for rendering a clickable link to initiate a file upload process. import { gql, useLazyQuery, useMutation } from '@apollo/client'; import { useEffect, useState } from 'react'; i ...

Transmitting MQTT information through an application programming interface

In my project using Ionic React, I am developing an application to showcase temperature data. To achieve this, I have established an API that transmits MQTT temperature information and utilize Axios for data retrieval. Despite my efforts, I am encountering ...

Having trouble accessing the 'add' property of Rxjs Subscription

I have been working on optimizing my code and I encountered an issue with unsubscribing from multiple subscriptions in ngOnDestroy. Specifically, when trying to invoke the add() method to include additional child subscriptions, I keep getting an error me ...

What steps are involved in switching the package manager for the Angular CLI, for example, replacing npm with pnpm when using `ng add`?

I couldn't find a lot of information on this topic, so I decided to ask a question on Stack Overflow. When it comes to commands like ng add @angular/material, I prefer using the package manager pnpm. ...

Failed to set the reference: The first argument includes an undefined property. This error occurred within the context of

My journey with Firebase began just 4 days ago, although I've been a bit inconsistent. My goal was to create a user in the database, and while the user was successfully created, I encountered an issue when trying to return to the profile picture page. ...

What is the best way to locate every object based on its ID?

Currently, I am facing an issue where I have a list of IDs and I need to search for the corresponding object in the database. My tech stack includes Nodejs, Typescript, TypeORM, and Postgres as the database. The IDs that I am working with are UUIDs. ...

When there are multiple tabs open in the browser, I notice a difference in the time displayed. This occurs in an Angular 2 environment

https://i.sstatic.net/l4YQ1.pngAfter a successful login, I am fetching server time from the back-end (in Java) and adding 1 second at intervals. Observable.interval(1000).map(() => { return this.time.add(1, 'seconds'); }). ...