Giter Site home page Giter Site logo

Comments (2)

nvh95 avatar nvh95 commented on June 25, 2024

Debug should be able to watch for dom changes, so that we can put debug at the beginning of the test, and then have the latest dom represented at time of failure.

Hi @benguenter, it will be the Automatic Mode in the future release, similar to what jest-preview's Automatic Mode.

But in the meantime, you can use this setup to watch the dom changes whenever a test fails, thanks to @BrandonGoren
#21 (comment)

import { debug } from 'vitest-preview';
import { cleanup } from '@testing-library/react';

afterEach(context => {
  // Run vitest-preview's debug if the test fails
  if (context?.meta?.result?.state === 'fail') {
    debug();
  }
  // Clean up react-testing-library. We need to manually do this because we
  // turn off the automatic teardown in the vite.config.
  // This needs to happen after vitest-preview.
  cleanup();
});

from vitest-preview.

nknapp avatar nknapp commented on June 25, 2024

Another way is to call debug from the getElementError hook in the testing-library.

But if you want, you can open a PR at https://dom-preview.knappi.org/ which I developed as an alternative to vitest-preview. The setup is a little more complex though.

from vitest-preview.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.