GithubHelp home page GithubHelp logo

doc22940 / jsdom-devtools-formatter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jsdom/jsdom-devtools-formatter

1.0 0.0 0.0 198 KB

Make jsdom elements look like real DOM elements in Chrome Devtools console

JavaScript 100.00%

jsdom-devtools-formatter's Introduction

jsdom-devtools-formatter Build Status

In a nutshell: Instead of trying to understand what jsdom's elements represents by inspecting their implementation objects like so: before.png

…let's just inspect them like they were real HTML elements: after.png

Typical use-case would be some script/test that utilizes jsdom in a Node.js environment, e.g. Jest.

How to use

npm install jsdom-devtools-formatter
// in some file.js
const jsdomDevtoolsFormatter = require('jsdom-devtools-formatter');
jsdomDevtoolsFormatter.install();

// You can also opt-out at some later point by:
jsdomDevtoolsFormatter.uninstall();

E.g. for Jest it's probably easiest to integrate through setupTestFrameworkScriptFile configuration.

As a one-time thing also need to:

  • Open Chrome's Devtools
  • Click the "⠇" in the upper-right corner > Settings
  • Under "Console", check "Enable custom formatters"

Development

The source code is all plain vanilla JS and standard CommonJS modules. Tests are written using Jest

See package.json's scripts sections for all available commands. The most useul ones are probably:

# run all tests once:
npm test

# run tests in "watch mode"
npm test -- --watch

Testing

In addition to verifying logical changes using the automated tests, it's recommended to verify that things "look & feel" as expected using the manual tests:

  • Open chrome://inspect and click the "Open dedicated DevTools for Node" link (one-time thing)
  • Then run one of the following commands
npm run test:manual_node
# -or-
npm run test:manual_jest

It should stop at the debugger call, from there you can follow the inlined comment with instructions to play with the console output.

Related resources

jsdom-devtools-formatter's People

Contributors

viddo avatar

Stargazers

 avatar

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.