hypertest-cloud / hypertest

Plug-and-play library that distributes tests in the cloud to cut runtime to just your slowest test, ensuring cost-effectiveness.
https://hypertest.cloud
1 stars 0 forks source link

Research Cypress API How to run single test #4

Closed marcinlesek closed 6 months ago

blazbla274 commented 6 months ago

To run a specified suite or test, append .only to the function. All nested suites will also be executed. This gives us the ability to run one test at a time and is the recommended way to write a test suite.

Example:

describe('Unit Test FizzBuzz', () => {
  function numsExpectedToEq(arr, expected) {
    // loop through the array of nums and make
    // sure they equal what is expected
    arr.forEach((num) => {
      expect(fizzbuzz(num)).to.eq(expected)
    })
  }

  it.only('returns "fizz" when number is multiple of 3', () => {
    numsExpectedToEq([9, 12, 18], 'fizz')
  })

  it('returns "buzz" when number is multiple of 5', () => {
    numsExpectedToEq([10, 20, 25], 'buzz')
  })

  it('returns "fizzbuzz" when number is multiple of both 3 and 5', () => {
    numsExpectedToEq([15, 30, 60], 'fizzbuzz')
  })
})

Source: https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests