ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - skovhus/jest-codemods: Codemods for migrating to Jest https://github.com/facebook/jest 👾
Codemods for migrating to Jest https://github.com/facebook/jest 👾 - skovhus/jest-codemods
Visit Site

GitHub - skovhus/jest-codemods: Codemods for migrating to Jest https://github.com/facebook/jest 👾

GitHub - skovhus/jest-codemods: Codemods for migrating to Jest https://github.com/facebook/jest 👾

Codemods that simplify migrating JavaScript and TypeScript test files from AVA, Chai, Expect.js (by Automattic), [email protected] (by mjackson), Jasmine, Mocha, proxyquire, Should.js, Tape, Sinon, and Node-Tap to Jest.

version downloads Code Coverage MIT License PRs Welcome

Codemods are small programs that help you automate changes to your codebase. Think of them as search and replace on steroids.

We made jest-codemods so you can try out Jest on your existing codebase. We strive to make the migration as smooth as possible, but some manual intervention and tweaks to your tests are to be expected.

Usage (CLI)

To use the interactive CLI run

$ npx jest-codemods

If you do not have npx installed, you can install the jest-codemods command globally by running npm install -g jest-codemods.

For more options

$ npx jest-codemods --help

    Usage:      npx jest-codemods <path> [options]

    Examples:   npx jest-codemods src
                npx jest-codemods src/**/*.test.js

    Options:
      -f, --force       Bypass Git safety checks and force codemods to run
      -d, --dry         Dry run (no changes are made to files)

To transform all test files in a directory run jest-codemods . in your terminal.

Notice the console output for errors, manual intervention and tweaks might be required.

Usage (jscodeshift)

To make the process as simple as possible, we recommend the jest-codemods CLI that wraps the jscodeshift executable. But you can also run the transformations directly using jscodeshift.

$ npm install -g jscodeshift
$ npm install jest-codemods
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/ava.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/chai-assert.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/chai-should.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/expect-js.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/expect.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/jasmine-globals.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/jasmine-this.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/mocha.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/should.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/tape.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/sinon.js test-folder
$ jscodeshift -t node_modules/jest-codemods/dist/transformers/jest-globals-import.js test-folder

Test environment: Jest on Node.js or other

If you're using Jest as your test runner and executing tests on Node.js, you'll want to use the default option when prompted. In this case, jest-codemods assumes that global values such as expect and jest are provided and will not require() them explicitly.

If, however, you are using a different test runner or executing Jest tests in a browser, you may need to choose the option with explicit require() calls.

In the second case, after running jest-codemods, you might need to install a few dependencies:

yarn add --dev expect jest-mock

npm install --save-dev expect jest-mock

pnpm install --save-dev expect jest-mock

Transformations

If possible import / require statements determine if any transformation are carried out. The original code quoting style is preserved. Warnings are made if packages are used that are incompatible with Jest.

Inspiration

Thanks to avajs/ava-codemods for inspiration and original CLI setup.

The Mocha and Chai assert support began its life at paularmstrong/mocha-to-jest-codemod.

Chai Should/Expect came from AlexJuarez/chai-to-jasmine.

Links

Contributing

To get started, run:

pnpm install

When developing:

pnpm verify  # (build/lint/test)
pnpm build
pnpm lint
pnpm test
pnpm test:cov
pnpm test:watch

License

MIT

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory