Skip to content

Configuração Jest

Fhilype Medeiros Melo edited this page Jan 20, 2023 · 1 revision

FROM > https://jestjs.io/docs/getting-started

yarn add --dev jest

--- package.json ---

{
  "scripts": {
    "test": "jest"
  }
}

yarn add --dev @babel/preset-typescript

--- babel.config.js ---

module.exports = function (api) {
  api.cache(true);
  return {
    presets: [
      'babel-preset-expo',
      ['@babel/preset-env', { targets: { node: 'current' } }],
      '@babel/preset-typescript',
    ],
    plugins: ['module:react-native-dotenv'],
  };
};

yarn add --dev ts-jest

yarn add --dev @jest/globals

yarn add --dev @types/jest

--- Example --- index.tsx | index.ts create a file: index.test.ts

import { describe, expect, test } from '@jest/globals';

describe('', () => {
    test('', () => {
        expect(1+1).toBe(2)
    })
})

Clone this wiki locally