GithubHelp home page GithubHelp logo

Comments (11)

vesln avatar vesln commented on June 9, 2024

@jbinto thanks for your work!

chai-enzyme is transpiled to es2015 with babel, so this shouldn't be the issue.

i believe it's the fact that we are trying to run commonjs code in a browser environment without any preparation. both mocha and chai come with a browser bundle see https://github.com/xdissent/karma-chai/blob/master/index.js#L9

i believe we can use webpack to accomplish it see https://webpack.github.io/docs/configuration.html#output-librarytarget

this can be done either in this repository, a separate one or in your karma plugin.

let me know if you wanna try to tackle this... i'll be very happy to assist in any way possible

from chai-enzyme.

ljharb avatar ljharb commented on June 9, 2024

(You can also use browserify)

from chai-enzyme.

marr avatar marr commented on June 9, 2024

I am having trouble getting this working with browserify and tape. Unrelated to karma but it seems appropriate:

$ browserify -t babelify test/components/my-component.spec.js
Error: Cannot find module 'react/lib/ReactContext' from '/Users/dm/src/my-boilerplate/node_modules/enzyme/build'
    at /Users/dm/src/my-boilerplate/node_modules/resolve/lib/async.js:46:17
    at process (/Users/dm/src/my-boilerplate/node_modules/resolve/lib/async.js:173:43)
    at ondir (/Users/dm/src/my-boilerplate/node_modules/resolve/lib/async.js:188:17)
    at load (/Users/dm/src/my-boilerplate/node_modules/resolve/lib/async.js:69:43)
    at onex (/Users/dm/src/my-boilerplate/node_modules/resolve/lib/async.js:92:31)
    at /Users/dm/src/my-boilerplate/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

Here is a repo I am working on: https://github.com/marr/my-boilerplate

from chai-enzyme.

marr avatar marr commented on June 9, 2024

FWIW, I did get this working in browser with tape, enzymejs/enzyme#132 (comment)

from chai-enzyme.

vesln avatar vesln commented on June 9, 2024

good to know, thanks!

from chai-enzyme.

ayrton avatar ayrton commented on June 9, 2024

@jbinto is it possible you can get it working by requiring like this:

var chai-enzyme = require('chai-enzyme').default

// vs.

var chai-enzyme = require('chai-enzyme')

This is something we will have to address soon, let me know if that fixes it for you if so I'll make some time to get this working out of the box. For future me see babel-plugin-add-module-exports.

from chai-enzyme.

ljharb avatar ljharb commented on June 9, 2024

Actually a better solution would be for chai-enzyme's main entry point to use module.exports = theDefault instead of export default theDefault. Consumers should never have to interact with babel's CommonJS interop.

from chai-enzyme.

ayrton avatar ayrton commented on June 9, 2024

@jbinto this should be no longer an issue as of v0.3.0, feel free to re-open if you still have any problems.

from chai-enzyme.

reintroducing avatar reintroducing commented on June 9, 2024

I'm trying to get this working with a Karma/webpack setup and I'm pretty lost as to how to do this. What is the proper way to get this working with Karma? Is there documentation anywhere that would show this? Would really appreciate any help offered.

from chai-enzyme.

ayrton avatar ayrton commented on June 9, 2024

@reintroducing I'm not familiar with karma, but I saw @jbinto figured this out in react-boilerplate/react-boilerplate#119 & react-boilerplate/react-boilerplate#150. Maybe checking out react-boilerplate's karma.conf.js will help you out.

from chai-enzyme.

reintroducing avatar reintroducing commented on June 9, 2024

@ayrton I looked it over before posting but the setup is slightly different than mine. I'm going to try again with that exact setup when I get a moment and see if I can chase this down. Thanks for the links.

from chai-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.