Services
About
Portfolio
Careers
Blog
Get in touch
Loading articles

Apptension site footer

Taking new projects

Have a product to build, fix or scale?

Apptension is a senior-only software development company headquartered in Poznań, Poland. Since 2012 our engineers have shipped 360+ AI and SaaS products for startups, scale-ups and enterprises across the US, UK and EU: agentic MVPs, RAG and voice AI systems, multi-tenant SaaS and legacy modernization.

Projects shipped
360+
Founded
2012
Senior engineers
30+
Client CSAT
100%

Send a few lines about your product. A person from our team replies within one business day.

Start a projectScope it in Scope Studio
  • Emailcontact@apptension.com
  • Phone+48 533 352 052Poznań, Poland

  • Agentic MVP developmentNew
  • Agentic SDLC implementation
  • Product & SaaS development
  • Legacy modernization
  • Generative AI development
  • SaaS development company
  • Vibe-coded prototype to production
  • End-to-end software development
  • Senior engineering team extension
  • Product consulting & discovery
  • Tech due diligence for investors
  • All services

  • LLM application engineering
  • RAG & retrieval engineering
  • Voice AI agent development
  • MCP server development
  • LangGraph & LangChain agents
  • AI agent evaluation & observability
  • Node.js development company
  • Python & Django development
  • React & Next.js development
  • React Native app development
  • All expertise

  • Open-source SaaS Boilerplate
  • SaaS P&L model template
  • Walkthrough Studio
  • Agentic SDLC playbook
  • AI SDLC maturity assessment
  • Agentic SDLC ROI calculator
  • Founder resources
  • Events & exec dinners
  • Open source
  • Builder's Toolkit

  • Boutique vs large software house
  • Build vs buy vs partner
  • How to choose an AI & RAG partner
  • Team augmentation without chaos
  • Django vs Node.js for SaaS
  • React Native vs Flutter
  • AI in regulated industries
  • All guides

  • About Apptension
  • Case studies
  • Careers
  • Blog
  • Tech Radar
  • Agentic SDLC hub
  • Contact

Senior AI engineers shipping enterprise-grade AI and SaaS with startup speed.

Headquarters

Apptension sp. z o.o.23 Lutego 26
61-743 Poznań, Poland (opens Google Maps)

VAT-ID PL7831720203 · REGON 360404804
KRS 0000534235

Follow Apptension

Client reviews on Clutch

© 2012–2026 Apptension sp. z o.o. All rights reserved.

Privacy policySitemapllms.txt
  • 01Services
  • 02Portfolio
  • 03About
  • 04Careers
  • 05Blog

Services

All services

New · AI-native delivery

Senior engineers with AI coding agents

Ship a production MVP in weeks, or install agents into the team you already have.

Agentic MVPNewA production MVP your customers can rely on. Validate in 1–2 weeks, launch in 4–8, own all of it.Explore
  • Agentic SDLCAI coding agents installed into your delivery process in two weeks, with guardrails and metrics.
Agentic SDLC hub
>_ProductScope StudioFrom an idea to a shareable PRD_> Open_> Open
Emailcontact@apptension.comCall+48 533 352 052

HQ in Poznań, Poland

Start a project
Services
About
Portfolio
Careers
Blog
Get in touch
Loading article

Apptension site footer

Taking new projects

Have a product to build, fix or scale?

Apptension is a senior-only software development company headquartered in Poznań, Poland. Since 2012 our engineers have shipped 360+ AI and SaaS products for startups, scale-ups and enterprises across the US, UK and EU: agentic MVPs, RAG and voice AI systems, multi-tenant SaaS and legacy modernization.

Projects shipped
360+
Founded
2012
Senior engineers
30+
Client CSAT
100%

Send a few lines about your product. A person from our team replies within one business day.

Start a projectScope it in Scope Studio
  • Emailcontact@apptension.com
  • Phone+48 533 352 052Poznań, Poland

  • Agentic MVP developmentNew
  • Agentic SDLC implementation
  • Product & SaaS development
  • Legacy modernization
  • Generative AI development
  • SaaS development company
  • Vibe-coded prototype to production
  • End-to-end software development
  • Senior engineering team extension
  • Product consulting & discovery
  • Tech due diligence for investors
  • All services

  • LLM application engineering
  • RAG & retrieval engineering
  • Voice AI agent development
  • MCP server development
  • LangGraph & LangChain agents
  • AI agent evaluation & observability
  • Node.js development company
  • Python & Django development
  • React & Next.js development
  • React Native app development
  • All expertise

  • Open-source SaaS Boilerplate
  • SaaS P&L model template
  • Walkthrough Studio
  • Agentic SDLC playbook
  • AI SDLC maturity assessment
  • Agentic SDLC ROI calculator
  • Founder resources
  • Events & exec dinners
  • Open source
  • Builder's Toolkit

  • Boutique vs large software house
  • Build vs buy vs partner
  • How to choose an AI & RAG partner
  • Team augmentation without chaos
  • Django vs Node.js for SaaS
  • React Native vs Flutter
  • AI in regulated industries
  • All guides

  • About Apptension
  • Case studies
  • Careers
  • Blog
  • Tech Radar
  • Agentic SDLC hub
  • Contact

Senior AI engineers shipping enterprise-grade AI and SaaS with startup speed.

Headquarters

Apptension sp. z o.o.23 Lutego 26
61-743 Poznań, Poland (opens Google Maps)

VAT-ID PL7831720203 · REGON 360404804
KRS 0000534235

Follow Apptension

Client reviews on Clutch

© 2012–2026 Apptension sp. z o.o. All rights reserved.

Privacy policySitemapllms.txt
Services
About
Portfolio
Careers
Blog
Get in touch
QA
6 min read
May 24, 2023
Grzegorz Wienconek

Comparison of 3 popular Cypress timekeeping methods

Accurate timekeeping is essential for measuring performance and validating time-based functionalities in web applications during testing. In Cypress, a popular end-to-end testing framework, developers have several options for capturing timestamps. This post provides an in-depth comparative review of three commonly used Cypress timekeeping methods: Date.now(), new Date(), and Performance.now().

Comparison of 3 popular Cypress timekeeping methods

The site https://demoqa.com/ contains various challenges for people wanting to improve their skills in test automation.

As a part of our monthly test automation workshops, which support the QA work in our end-to-end software development projects, we were challenged to develop tests in Cypress for a specific case under the https://demoqa.com/alerts address, which would test if, after clicking the second button from the top alert will appear after 5 seconds.

The most significant difference between solutions was in methods used to measure passing time. In this article, I will present those different approaches and describe how each method affected the results of the tests.

Part 1 – accessing alert

The major problem we encountered was accessing the alert that should appear after 5 seconds which is quite tricky when using Cypress.

We used cy.stub to deal with it.

>_ $
1
2
3
4
it('counts 5 seconds', () => {
      cy.window().then((win) => {
        cy.stub(win, 'alert').as('alert')
      })

Part 2 – measuring time

After dealing with the problem of accessing the alert, the next thing was to test if it actually appeared after 5 seconds after clicking the button.

The primary approach to making this test was the same in all cases.

  1. Make the 1st timestamp after clicking the button.
  2. Make the 2nd timestamp after the alert window appears.
  3. Subtract the value of the 1st timestamp from the 2nd to get the time passed after clicking the button.
  4. Make an assertion that will check if the value from step 3 is bigger than 5 seconds/5000 milliseconds.

The main difference was in which method each person used to measure time. Below is a quick summary of them, including code examples and the time they measured.

You may also like: How go around Cypress restrictions on two different superdomains?

Date.now()

>_ $
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
it('Click second button, alert will appear after 5 seconds', () => {
  let startTime, alertTime;

  cy.window().then($win => {
    cy.stub($win, 'alert').as('alert');
  });
  cy.clickButton('Click me', 1).then(() => {
    startTime = Date.now();
  });
  cy.get('@alert').should('have.been.calledOnceWithExactly',
    'This alert appeared after 5 seconds').then(() => {
    alertTime = Date.now() - startTime;
    expect(alertTime).to.be.within(4850, 5100);
    cy.log('Alert time: ' + alertTime + 'ms');
  });
});

Results in milliseconds:

  1. 4965
  2. 4963
  3. 4968
  4. 4968
  5. 4971

new Date()

>_ $
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
describe("Alert", () => {
  it("Should wait for alert", () => {
    cy.visit("/alerts", {
      onBeforeLoad(win) {
        cy.stub(win, "alert").as("alert");
      },
    });
    let timestamp;
    cy.get("#timerAlertButton").click().then(() => {
      timestamp = new Date();
    })

    cy.get("@alert").should(
      "have.been.calledOnceWithExactly",
      "This alert appeared after 5 seconds"
    ).then(() => {
      const loadTime = new Date();
      const actualTime = loadTime - timestamp;
      cy.log(actualTime);
      expect(actualTime).to.be.within(4750, 5250);
    })
  });
});

Results in milliseconds:

  1. 4972
  2. 4957
  3. 4961
  4. 4957
  5. 4950

Performance.now()

>_ $
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
describe('counter', () => {
  it('counts 5 seconds', () => {
    cy.window().then((win) => {
      cy.stub(win, 'alert').as('alert')
    })

    cy.visit('https://demoqa.com/alerts')
    cy.get('button[id=timerAlertButton]').then(() => {
      const t0 = performance.now()

      cy.get('button[id=timerAlertButton]').click()

      cy.on('window:alert', (text) => {
        expect(text).to.contains(
          'This alert appeared after 5 seconds');
        const t1 = performance.now()
        const alertTime = ((t1 - t0) / 1000)
        expect(alertTime).to.be.greaterThan(5)
        cy.log(`Alert appeared after ${alertTime} seconds.`);
      })
    })
  })
});

Results in seconds:

  1. 5.073599999994039
  2. 5.0685
  3. 5.07609999999404
  4. 5.091200000017881
  5. 5.091400000005961

Comparison of results

As we can see in the case of using Date.now() and new Date() results were quite similar, but they were never above 5 seconds. So if the assertion is strict and requires the results to be bigger than 5 seconds, tests would not pass. But when we look at the results when using performance.now(), they are always above 5 seconds. So, in this case, the assertion would be positive.

What causes such difference is the point in time to which each method relates. Both Date.now() and newDate() is relative to the Unix epoch (1970-01-01T00:00:00Z) and dependent on the system clock. On the other hand, Performance.now() is relative to page load and relies on monotonic time. Therefore it is not affected by time adjustments that the system clock may be target off.

So, performance.now() is better suited for monitoring the time in which a piece of code was executed, which in the case described in this article is the time passed since clicking the button to the time the alert appears on the screen. Another benefit is that Performance.now() makes timestamps with precision up to microseconds.

>>>Ready to start your project?

Let's discuss how we can help bring your ideas to life.

Apptension site footer

Taking new projects

Have a product to build, fix or scale?

Apptension is a senior-only software development company headquartered in Poznań, Poland. Since 2012 our engineers have shipped 360+ AI and SaaS products for startups, scale-ups and enterprises across the US, UK and EU: agentic MVPs, RAG and voice AI systems, multi-tenant SaaS and legacy modernization.

Projects shipped
360+
Founded
2012
Senior engineers
30+
Client CSAT
100%

Send a few lines about your product. A person from our team replies within one business day.

Start a projectScope it in Scope Studio
  • Emailcontact@apptension.com
  • Phone+48 533 352 052Poznań, Poland

  • Agentic MVP developmentNew
  • Agentic SDLC implementation
  • Product & SaaS development
  • Legacy modernization
  • Generative AI development
  • SaaS development company
  • Vibe-coded prototype to production
  • End-to-end software development
  • Senior engineering team extension
  • Product consulting & discovery
  • Tech due diligence for investors
  • All services

  • LLM application engineering
  • RAG & retrieval engineering
  • Voice AI agent development
  • MCP server development
  • LangGraph & LangChain agents
  • AI agent evaluation & observability
  • Node.js development company
  • Python & Django development
  • React & Next.js development
  • React Native app development
  • All expertise

  • Open-source SaaS Boilerplate
  • SaaS P&L model template
  • Walkthrough Studio
  • Agentic SDLC playbook
  • AI SDLC maturity assessment
  • Agentic SDLC ROI calculator
  • Founder resources
  • Events & exec dinners
  • Open source
  • Builder's Toolkit

  • Boutique vs large software house
  • Build vs buy vs partner
  • How to choose an AI & RAG partner
  • Team augmentation without chaos
  • Django vs Node.js for SaaS
  • React Native vs Flutter
  • AI in regulated industries
  • All guides

  • About Apptension
  • Case studies
  • Careers
  • Blog
  • Tech Radar
  • Agentic SDLC hub
  • Contact

Senior AI engineers shipping enterprise-grade AI and SaaS with startup speed.

Headquarters

Apptension sp. z o.o.23 Lutego 26
61-743 Poznań, Poland (opens Google Maps)

VAT-ID PL7831720203 · REGON 360404804
KRS 0000534235

Follow Apptension

Client reviews on Clutch

© 2012–2026 Apptension sp. z o.o. All rights reserved.

Privacy policySitemapllms.txt