Skip to content

dylangarcia/should-to-jest-codemod

Repository files navigation

should-to-jest-codemod

CI Build Status

This is a jscodeshift codemod that helps transforms legacy should tests to Jest's expect format. Tests are automatically run via a Github Actions workflow.

Usage

yarn jscodeshift \
  -t index.js \
  file-to-transform.js

Examples

Input

should(something.nested).match(/foo/i);
should.exist(foo);
should.not.exist(foo);
foo(bar)[0].should.match(/bar/);
err.problems[0].should.match(/oopsies/i);

Output

expect(something.nested).toMatch(/foo/i);
expect(foo).toBeDefined();
expect(foo).not.toBe(expect.anything());
expect(foo(bar)[0]).toMatch(/bar/);
expect(err.problems[0]).toMatch(/oopsies/i);

Supported should methods

The latest supported methods are always located in __testfixtures__/should-to-jest.input.js. The transformed output is located in __testfixtures__/should-to-jest.output.js

Running Tests

yarn test
yarn test:watch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published