Browser Testing

Browser testing is very similar to Unit Testing so we recommend reading that first.

The only real difference with browser testing is you get access to window, document and all other DOM APIs

👉

All Browser tests have to end in .test.tsx or .spec.tsx

Basic Browser Test

// __tests__/browserTest.test.tsx`

import { expect } from 'chai'

import { runTestInBrowser } from '@testickle/client'

const getThreads = () => {
  const threads = window.navigator.hardwareConcurrency
  return threads < 8 ? threads : 8
}

runTestInBrowser('Threads checking', {
  beforeAll: () => {
    const threads = window.navigator.hardwareConcurrency

    return { threads }
  },
  'Verify thread count': ({ threads }) => {
    expect(getThreads()).to.be.lessThanOrEqual(threads)
  },
  'Expect threads to be less than 8': () => {
    expect(getThreads()).to.be.lessThanOrEqual(8)
  }
})

Type Definition

const runTestInBrowser = (groupName: string, tests: TestGroup) => Promise<void>

Learn more about Test Group