What is the right way to create instance of jsom while working with ES6?
See original GitHub issueI use jsdom 13.2 and ES6. On npm page the following example is given:
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
When I changed this code to:
import { jsdom } from "jsdom";
const { JSDOM } = jsdom;
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
I got error.
The only way I made it work is:
import { JSDOM } from 'jsdom';
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
However, I didn’t find anyone used the same way. Is this a right way?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Working with objects - JavaScript - MDN Web Docs - Mozilla
Define the object type by writing a constructor function. There is a strong convention, with good reason, to use a capital initial letter....
Read more >How to conditionally build an object in JavaScript with ES6
The first is parameter object destructuring, which is a good pattern if you want to deal with lots of arguments in a function....
Read more >Create instance of ES6 class from JSON result - Stack Overflow
What's the easiest way to create an instance of an ES6 class from a JSON object? E.g., given something like: class Foo constructor(bar) ......
Read more >JavaScript ES6 - W3Schools
You don't need the function keyword, the return keyword, and the curly brackets. Example. // ES5 var x = function(x, y) {
Read more >Working with JavaScript in Visual Studio Code
While IntelliSense should just work for most JavaScript projects without ... For example, on Windows, you would add a path like this to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@domenic Besides, node.js developers already work at adding es6 modules and it is already possible to use it in experimental mode. So, again, this issue does make sense.
jsdom works with Node.js, which does not support that syntax. So this issue doesn’t make sense.
If you are using some nonstandard tool to work with jsdom, you need to file this help request on them.