- Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
- Opcional: Si usamos Fetch API en el proyecto:
function parseJwt (token) { | |
var base64Url = token.split('.')[1]; | |
var base64 = base64Url.replace('-', '+').replace('_', '/'); | |
return JSON.parse(window.atob(base64)); | |
}; |
import { render, RenderOptions } from '@testing-library/react'; | |
import React from 'react'; | |
import { Provider } from 'react-redux'; | |
import { store } from '../../store'; | |
const Providers: React.FC = ({ children }) => { | |
return ( | |
<Provider store={store}> | |
{children} | |
</Provider> |
export const timeSince = ( date: string ) => { | |
const baseDate = new Date(date) | |
const seconds = Math.floor(( new Date().getTime() - baseDate.getTime() ) / 1000); | |
let interval = seconds / 31536000; |