Skip to main content
Version: 29.7

Migrando a Jest

Si deseas probar Jest con un proyecto de código existente, hay un número de maneras de convertir-lo a Jest:

  • If you are using Jasmine, or a Jasmine like API (for example Mocha), Jest should be mostly compatible, which makes it less complicated to migrate to.
  • If you are using AVA, Expect.js (by Automattic), Jasmine, Mocha, proxyquire, Should.js or Tape you can automatically migrate with Jest Codemods (see below).
  • If you like chai, you can upgrade to Jest and continue using chai. Sin embargo, te recomendamos probar las asserciones de Jest y los mensajes de error. Jest Codemods puede migrarse desde chai (véase abajo).

jest-codemods

If you are using AVA, Chai, Expect.js (by Automattic), Jasmine, Mocha, proxyquire, Should.js, Tape, or Sinon you can use the third-party jest-codemods to do most of the dirty migration work. It runs a code transformation on your codebase using jscodeshift.

Para transformar los tests existentes, navega al proyecto que contiene los tests y ejecuta:

npx jest-codemods

More information can be found at https://github.com/skovhus/jest-codemods.