cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Angular schematic generate component testing files by default

Open geromegrignon opened this issue 2 years ago • 2 comments

Current behavior

By answering 'No' to component testing support when adding Cypress for Angular with ng add @cypress/schematics, the schematic added still overrides the generic component schematic and creates a cy.ts test file in place of the spec.ts file.

Desired behavior

If Component Testing support is not chosen by adding Cypress, creating a new component with ng g generate should create a spec.ts file by using ng generate component schematic.

Test code to reproduce

  • create a Angular project npx -p @angular/cli ng new projectName
  • move to your root folder with cd projectName
  • add Cypress with ng add @cypress/schematics
  • answer 'No' to component testing support
  • create a Angular component with ng generate component home
  • a home-component.cy.ts file is created.

Cypress Version

13.0.0

Node version

v18.16.1

Operating System

macOS 13.5

Debug Logs

No response

Other

No response

geromegrignon avatar Aug 30 '23 14:08 geromegrignon

I'm seeing this, too. Angular CLI v15.1.6, Cypress v12.10.0.

Of note (perhaps) is that I didn't have this problem when I was using Angular CLI v13.3.0.

pgates-brownadvisory avatar Sep 29 '23 19:09 pgates-brownadvisory

I have the same problem.

miguelarcjr avatar Jan 31 '24 00:01 miguelarcjr

Same problem

Jhamu21 avatar Jun 13 '24 08:06 Jhamu21

I started having the same problem at some point in an old project and was able to "fix" it by reordering schematics in angular.json file.

Before:

  "cli": {
    "schematicCollections": [
      "@cypress/schematic",
      "@angular-eslint/schematics",
      "@schematics/angular"
    ],
    "analytics": false
  }

After:

  "cli": {
    "schematicCollections": [
      "@schematics/angular",
      "@angular-eslint/schematics",
      "@cypress/schematic"
    ],
    "analytics": false
  }

altso avatar Jun 13 '24 12:06 altso

I started having the same problem at some point in an old project and was able to "fix" it by reordering schematics in angular.json file.

Before:

  "cli": {
    "schematicCollections": [
      "@cypress/schematic",
      "@angular-eslint/schematics",
      "@schematics/angular"
    ],
    "analytics": false
  }

After:

  "cli": {
    "schematicCollections": [
      "@schematics/angular",
      "@angular-eslint/schematics",
      "@cypress/schematic"
    ],
    "analytics": false
  }

Thankyou it worked!

Jhamu21 avatar Jun 14 '24 03:06 Jhamu21

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot avatar Dec 12 '24 02:12 cypress-app-bot

This issue has been closed due to inactivity.

cypress-app-bot avatar Dec 27 '24 01:12 cypress-app-bot