percyhanna / chai-react

Chai assertions for React
MIT License
40 stars 3 forks source link

Karma integration #8

Closed kristian-puccio closed 9 years ago

kristian-puccio commented 9 years ago

I'm trying to use chai-react inside karma without much luck.

I spotted this https://github.com/princed/karma-chai-plugins and tried extending it to load chai-react but I get a ReferenceError: Can't find variable: React.

Any ideas?

percyhanna commented 9 years ago

chai-react should support CommonJS/Node, RequireJS/AMD, and standard global/module formats.

Given the error message, it is likely falling back to the default global/module implementation, meaning that you don't have the React module defined globally.

I recently dealt with a support issue for someone trying to use rquery with Karma. They defined React globally and then load that as part of their Karma config. Hopefully that helps out?

kristian-puccio commented 9 years ago

Works perfectly, thanks!

kristian-puccio commented 9 years ago

Awesome thanks for that worked perfectly.

On 25 May 2015 at 14:56, Andrew Hanna notifications@github.com wrote:

chai-react should support CommonJS/Node https://github.com/percyhanna/chai-react/blob/master/chai-react.js#L5, RequireJS/AMD https://github.com/percyhanna/chai-react/blob/master/chai-react.js#L8-12, and standard global/module https://github.com/percyhanna/chai-react/blob/master/chai-react.js#L15-17 formats.

Given the error message, it is likely falling back to the default global/module implementation, meaning that you don't have the React module defined globally https://github.com/percyhanna/chai-react/blob/master/chai-react.js#L16.

I recently dealt with a support issue for someone trying to use rquery with Karma. They defined React globally https://github.com/steffenmllr/rquery-issue/blob/master/tests/globals.js#L4 and then load that as part of their Karma config https://github.com/steffenmllr/rquery-issue/blob/master/tests/karma.config.js. Hopefully that helps out?

— Reply to this email directly or view it on GitHub https://github.com/percyhanna/chai-react/issues/8#issuecomment-105125323 .