Estoy usando react jest con la biblioteca de pruebas de reacción para probar mi componente. Estoy enfrentando un problema extraño. Estoy usando el retorno de depuración por renderizado de testing-library.
test('component should work', async () => { const { findByText, debug } = render(<MyComponent />); const myElement = await findByText(/someText/i); debug(); });Como puede ver en la captura de pantalla, hay un desarrollo incompleto y faltan las etiquetas de cierre para los padres.
Debe cambiar el valor de la variable de DEBUG_PRINT_LIMIT (el valor predeterminado es 7000).
Por ejemplo, ejecute sus pruebas con: DEBUG_PRINT_LIMIT=10000 yarn test
Fuente: https://github.com/testing-library/dom-testing-library/blob/master/src/pretty-dom.js#L24
Estoy usando esta versión: "@testing-library/react": "^11.0.4"
capaz de hacer como a continuación, podemos cambiar 300000 como la longitud máxima de salida.
debug(undefined, 300000)El segundo argumento de la función debug() se puede usar para establecer maxLengthToPrint .
Por ejemplo, para imprimir todo en myElement utilizando el enfoque screen recomendado :
import {render, screen} from '@testing-library/react' render(<MyComponent />); const myElement = await screen.findByText(/someText/i); const maxLengthToPrint = 100000 screen.debug(myElement, maxLengthToPrint);Ver: