GithubHelp home page GithubHelp logo

Comments (8)

mgeduld avatar mgeduld commented on April 28, 2024 3

I figured it out. You can close this or leave it to help others. What I needed to do was load jsdom as a global object in my node test script:

import jsdom as 'jsdom';
const doc = jsdom.jsdom('<!doctype html><html><body></body></html>');
const win = doc.defaultView;
global.document = doc;
global.window = win;

from enzyme.

silvenon avatar silvenon commented on April 28, 2024 3

I consider Stack Overflow a good place to find help for something you want to do with the library which is not a shortcoming of the library itself, but your own knowledge.

To me this seems like a legit question to post as an issue, because the library is indeed tied to Mocha, which might be something that should be fixed or at least documented.

from enzyme.

aymericbouzy avatar aymericbouzy commented on April 28, 2024 1

Not sure why, but your code wasn't working for me.

My version:

import {JSDOM} from 'jsdom'
const dom = new JSDOM('<!doctype html><html><body></body></html>')
global.window = dom.window
global.document = dom.window.document

from enzyme.

blainekasten avatar blainekasten commented on April 28, 2024

It might be good to post these things on stack overflow as it's a first resource for most developers these days.

from enzyme.

mgeduld avatar mgeduld commented on April 28, 2024

"the library is indeed tied to Mocha"

The documentation implies that you can use it without mocha. Which is what I do, so far without problems, except for not knowing how to get jsdom working. Now that I've done that, everything is going well.

from enzyme.

lelandrichardson avatar lelandrichardson commented on April 28, 2024

@silvenon @mgeduld We agree this is a legitimate issue. We are working on a 2.0 release that will gut out all ties to mocha, and also include guides/documentation on getting enzyme up and running in every popular testing framework. I apologize for the issues thus far, but I'm glad you've gotten it up and running!

from enzyme.

defvol avatar defvol commented on April 28, 2024

@mgeduld your jsdom hack worked πŸ‘Œ for me, thanks!

from enzyme.

mgeduld avatar mgeduld commented on April 28, 2024

Yay!

from enzyme.

Related Issues (20)

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.