Jest è un framework di test di unità JavaScript realizzato da Facebook basato su Jasmine e fornisce la creazione automatizzata di mock e un ambiente jsdom. Viene spesso utilizzato per testare i componenti React.
Ho un punto in mapModulecui importa i componenti e li esporto: import ComponentName from '../components/ComponentName'; export default { name: ComponentName, }; Come posso verificare che mapModuleabbia le chiavi e i valori esportati corretti e che non siano nulli o indefiniti?
Mi piacerebbe cambiare l'implementazione di una dipendenza deriso su una base per basi di prova unico per l'estensione del finto di default 's comportamento e tornando indietro per l'implementazione originale quando il prossimo esegue test. Più brevemente questo è ciò che sto cercando di ottenere: finta dipendenza modificare / estendere …
Sto usando il gancio UseHistory nel router di reazione v5.1.2 con dattiloscritto? Durante l'esecuzione del test unitario, ho riscontrato un problema. TypeError: impossibile leggere la proprietà 'history' di undefined. import { mount } from 'enzyme'; import React from 'react'; import {Action} from 'history'; import * as router from 'react-router'; import …
Ho un'applicazione React (che non usa Create React App) creata usando TypeScript, Jest, Webpack e Babel. Quando provo a eseguire "jest filato", viene visualizzato il seguente errore: Ho provato a rimuovere tutti i pacchetti e ad aggiungerli di nuovo. Non risolve questo. Ho esaminato domande e documentazione simili e sto …
Sto scrivendo un unit test con jest, per il mio componente API composizione in vue.js. Ma non riesco ad accedere alle funzioni nell'installazione dell'API di composizione (). Indicator.vue <template> <div class="d-flex flex-column justify-content-center align-content-center"> <ul class="indicator-menu d-flex justify-content-center"> <li v-for="step in steps" :key="step"> <a href="#" @click="updateValue(step)" :class="activeClass(step, current)"> </a> </li> …
Ho un servizio API in cui ho diversi metodi per effettuare chiamate alle API. Ho testato con successo tutte le richieste GET ma ho problemi a testare le richieste POST. Questo è il metodo: export default class ApiService { static makeApiCall = <T>( url: string, oneCb: <T>(d: Data) => T, …
Sto provando alcuni test unitari, ho creato un sandbox con un esempio falso https://codesandbox.io/s/wizardly-hooks-32w6l (in realtà ho un modulo) class App extends React.Component { constructor(props) { super(props); this.state = { number: 0 }; } handleSubmit = (number1, number2) => { this.setState({ number: this.handleMultiply(number1, number2) }) } handleMultiply = (number1, number2) …
We use cookies and other tracking technologies to improve your browsing experience on our website,
to show you personalized content and targeted ads, to analyze our website traffic,
and to understand where our visitors are coming from.
By continuing, you consent to our use of cookies and other tracking technologies and
affirm you're at least 16 years old or have consent from a parent or guardian.