You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create any empty angular project using official Angular CLI. Its content actually does not matter.
You can use the following command:
ng new cypress-bug-demo --directory .
Install Cypress
npm install cypress --save-dev
Enable Angular component testing
npx cypress open
Select "Component Testing section " and press "Continue" many times (until all unboarding screens will be closed).
Create cypress/test.cy.ts file with the following content:
import{ChangeDetectionStrategy,Component}from'@angular/core';import{mount}from'cypress/angular';
@Component({standalone: true,template: `wow`,changeDetection: ChangeDetectionStrategy.OnPush,})exportclassMyComponent{constructor(){console.log('=[constructor.sync]=');setTimeout(()=>{console.log('=[constructor.setTimeout]=');},5_000);}ngOnInit(){console.log('=[ngOnInit.sync]=');setTimeout(()=>{console.log('=[ngOnInit.setTimeout]=');},1_000);}}describe('How it can be possible?',()=>{it('???',()=>{mount(MyComponent);cy.wait(6_000);});});
Run the created tests. Open DevTools console and the following order of logs:
import{ChangeDetectionStrategy,Component}from'@angular/core';import{mount}from'cypress/angular';
@Component({standalone: true,template: `wow`,changeDetection: ChangeDetectionStrategy.OnPush,})exportclassMyComponent{constructor(){console.log('=[constructor.sync]=');setTimeout(()=>{console.log('=[constructor.setTimeout]=');},5_000);}ngOnInit(){console.log('=[ngOnInit.sync]=');setTimeout(()=>{console.log('=[ngOnInit.setTimeout]=');},1_000);}}describe('How it can be possible?',()=>{it('???',()=>{mount(MyComponent);cy.wait(6_000);});});
Cypress Version
13.15.0
Node version
v20.15.1
Operating System
MacOS 14.5
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered:
Current behavior
Create any empty angular project using official Angular CLI. Its content actually does not matter.
You can use the following command:
Install Cypress
Enable Angular component testing
Select "Component Testing section " and press "Continue" many times (until all unboarding screens will be closed).
Create
cypress/test.cy.ts
file with the following content:Run the created tests. Open DevTools console and the following order of logs:
logs-order.mov
Desired behavior
See how it works in Real World application (open dev tools and see order of logs)
https://stackblitz.com/edit/cypress-bug-timers-inside-constructor?file=src%2Fmain.ts
Test code to reproduce
Cypress Version
13.15.0
Node version
v20.15.1
Operating System
MacOS 14.5
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: