Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
How do I write unit tests in Cypress? Is that even possible?

I am using Cypress with Cucumber to develope a front-end with vue.js using behaviour driven development (BDD). I can already use Cypress for end-to-end testing, but I was also required to create and run unit tests. I could not find anything on the official Cypress website. How can I create and run unit tests for this front-end?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can find all recipes related to the unit tests in the official docs.

Let's say you want to unit test math functions from the application's code, you can do so with Cypress:

/// <reference types="cypress" />

import math from '../../math'

describe('Unit Test Application Code', function () {
  const { add, divide, multiply, subtract } = math

  before(() => {
    // check if the import worked correctly
    expect(add, 'add').to.be.a('function')
  })

  context('math.js', function () {
    it('can add numbers', function () {
      expect(add(1, 2)).to.eq(3)
    })

    it('can subtract numbers', function () {
      expect(subtract(5, 12)).to.eq(-7)
    })

    it('can divide numbers', function () {
      expect(divide(27, 9)).to.eq(3)
    })

    it('can muliple numbers', function () {
      expect(multiply(5, 4)).to.eq(20)
    })
  })
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!