Get Started

Testickle is a slightly different test framework than you are used to. When using Testickle you can bring your own testing api or assertion library

Installing the runner

npm install testickle

yarn add testickle

pnpm add testickle

Choose your client

The idea is you can choose whatever test api you like and use that instead of being forced to use one

We recommend @testickle/client, it is our own custom test api which we think is cleaner.

However for backwards compatibility we have a @testickle/jest which supports jest api

Install your client

npm install @testickle/client

yarn add @testickle/client

pnpm add @testickle/client

Types of Tests

As testickle can write a few different kinds of tests we have an convention on naming files

  • name.test.ts ➡️ Unit test which run within node
  • name.test.tsx ➡️ Unit test which run inside the browser
👉

React tests can also be called name.test.tsx

  • name.e2e.tsx ➡️ E2E test which runs inside the browser

You can also names file name.spec.ts|tsx, if you want

Writing your first test

By default, all tests are expected to be inside a __tests__ folder, but this can be changed

Basic unit test

// __tests__/firstTest.test.ts
import { runTestGroup } from '@testickle/client'
import { expect } from 'chai'

runTestGroup(
  'Text Tests',
  {
    beforeAll: () => {
      const text = new Text({ text: 'Hello world', style: { fontSize: 96 } })
      return { text }
    },
    'Create Text': ({ text }) => {
      expect(text.text).to.equal('Hello world')
      expect(text.style.fontSize).to.equal(96)
    },
    'Add static media to store': ({ text }) => {
      mediaStore.addStaticMedia(text)
      const mediaElement = text.mediaElement

      expect(mediaElement, 'Media element is  not undefined').to.be.not
        .undefined
    }
  },
  true
)