Comments (11)
@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.
(You can also use browserify)
from chai-enzyme.
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.
FWIW, I did get this working in browser with tape, enzymejs/enzyme#132 (comment)
from chai-enzyme.
good to know, thanks!
from chai-enzyme.
@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.
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.
@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.
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.
@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.
@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)
- [1.0.0-beta.0] Cannot assert descendant not present HOT 2
- Use of reserved word 'let' in strict mode HOT 3
- [1.0.0-beta.0] className assertion failing when element has multiple classNames HOT 10
- CLOSED: Dependency issues with new version of enzyme HOT 4
- React 15.0.0 and Enzyme 3.2.0 issue HOT 3
- Cannot find module 'enzyme/build/react-compat' HOT 4
- Cannot convert a Symbol value to a string
- to.have.text(undefined) does not break the tests
- Error message for shallow render contains HOT 4
- Patch version bump for fix merged in from PR#215? HOT 2
- Is this library still maintained? `[import Adapter from 'enzyme-adapter-react-15';]` HOT 5
- .should.have.html(...) broken in 1.0.0-beta.1
- .to.have.style() requires kebab-cased keys
- TypeError: to.have.style is not a function HOT 1
- setup is vague
- Flow types HOT 1
- Preact support? HOT 3
- Chai's `assert.` style supported ? HOT 2
- Cannot read property 'have' of undefined
- Support for React 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chai-enzyme.