Domande taggate «jestjs»

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.



4
Come deridere l'usoHistory hook in jest?
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 …

1
Perché getComputedStyle () in un test JEST restituisce risultati diversi agli stili calcolati in Chrome / Firefox DevTools
Ho scritto un pulsante personalizzato ( MyStyledButton) basato su material-ui Button . import React from "react"; import { Button } from "@material-ui/core"; import { makeStyles } from "@material-ui/styles"; const useStyles = makeStyles({ root: { minWidth: 100 } }); function MyStyledButton(props) { const buttonStyle = useStyles(props); const { children, width, ...others …


1
Come test unitario con jest in Vue composizione componente API?
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> …

2
Impossibile verificare i metodi di post con Jest a causa di un errore non è in grado di leggere la simulazione di implementazione non definita
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, …

1
Come testare i componenti della classe in reagire
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) …
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.