JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q55334F
  • License ISC

Codemod to convert jest test suites to ava

Package Exports

  • to-ava

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (to-ava) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

to-ava

Codemod to convert tests written in jest to ava.

Check fixtures/ folder to see some example.

Usage

Install

npm i -g to-ava

Run it on a Javascript file

to-ava ./jest.test.js

Run it on a Typescript file

to-ava -p=ts ./jest.test.ts

Run it on a folder

to-ava -p=ts ./tests

Notes

It excludes files that are not test files. A file is supposed to contain tests if its name includes either test. either spec.

Support

Supported Assertions

  • .toEqual
  • .toBe
  • .toBeNull
  • .toBeFalsy
  • .toBeTruthy
  • .toMatchSnapshot
  • .toBeDefined
  • .toBeUndefined
  • .toBeInstanceOf
  • .toBeGreaterThan
  • .toBeGreaterThanOrEqual
  • .toBeLessThan
  • .toBeLessThanOrEqual
  • .toHaveLength
  • .toHaveProperty

Other things supported

  • test.each()
  • trasnformation of test hooks (before(), beforeEach(), after(), afterAll())

Assertions not supported

All the other assertions are not supported. Including all the assertions used in combination with .not - for example .not.toBeDefined()

Those assertions will be still transformed, however not into an ava assertion, but as a comment with the "TODO: " symbol. Thanks for the "TODO: " symbol, it will be possible to find all the assertions not transformed, and fix them manually.

For example

expect(res).toContain('0')

// will be transformed into

// TODO: expect(res).toContain('0');

Other things not supported

  • nested describe() - require manual rewriting of jest tests in order to remove nested describe()
  • skipped tests describe.skip(), it.skip()

Test

npm t

TODO

  • add support for beforeEach, beforeAll, afterEach, afterAll
  • refactor: split the transformer into multiple functions, with clear names
  • add support for more jest assertion. The list follows:
    • .not.toBeDefined
    • .not.toBeNull
    • .not.toContain
    • .not.toEqual
  • add support for nested describes

Resources