Tag: JESTJS
Tengo esta función: function sleep(milliseconds) { return new Promise((resolve) => { setTimeout(resolve, milliseconds); }); } Básicamente esta función retrasa la lógica, por ejemplo: function sleep(milliseconds) { return new Promise((resolve) => { setTimeout(resolve, milliseconds); }); } async function delayedGreeting() { console.log("Hola"); await sleep(2000); //esperará 2 segundos y luego mostrará el siguiente . . . Read more
Estoy tratando de cubrir la siguiente función con la prueba unitaria de Jest. export const submitCampaignForm = ( formData: IFormContextValues, mutate: (formData: IFormContextValues, setCamapignId: any) => void, setCamapignId: (val: string) => void, ): void => { mutate(formData, { onSuccess: (data: ICampaignResponse) => { if (data.id) { setCamapignId(data.id); } }, }); . . . Read more
// Cómo escribir casos de prueba unitarios para la siguiente tarea cron index.js import cron from ‘node-cron’ export const cronJob = cron.schedule(pattern, async() => { // hacer algo } index.spec.js import { cron } from ‘node-cron’; import {cronJob} from ‘.’; jest.mock(‘node-cron’, () => { return { schedule: jest.fn(), }; }); . . . Read more
Me han asignado la tarea de agregar pruebas a un sdk escrito en TypeScript. Este sdk tiene un módulo de acceso público y un módulo interno, y los tipos de estos módulos se extienden en muchos archivos. Por ejemplo: //CustomField.ts modulo deadbreaker { export class CustomField {} } //Music.ts módulo . . . Read more
Estoy tratando de configurar jest para una biblioteca de React Native, pero estoy obteniendo el siguiente error: SyntaxError: react-native/Libraries/polyfills/error-guard.js: Falta un punto y coma. (14: 4) “` react-native version: 0.61.5 app.js import { NativeModules } from ‘react-native’; import { Dimensions } from ‘react-native’; function sum(a, b) { return a + . . . Read more