Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: Can't find variable: chai #21

Closed
catamphetamine opened this issue Jul 17, 2015 · 8 comments
Closed

ReferenceError: Can't find variable: chai #21

catamphetamine opened this issue Jul 17, 2015 · 8 comments

Comments

@catamphetamine
Copy link

What does it mean?

17 07 2015 16:45:31.239:INFO [karma]: Karma v0.13.1 server started at http://localhost:9876/
17 07 2015 16:45:31.249:INFO [launcher]: Starting browser PhantomJS
17 07 2015 16:45:31.481:INFO [PhantomJS 1.9.8 (Linux 0.0.0)]: Connected on socket 3EAMNnOhXQnVs70-AAAA with id 12171161
PhantomJS 1.9.8 (Linux 0.0.0) ERROR
  ReferenceError: Can't find variable: chai
  at /home/kuchumovn/pussy_face/node_modules/karma-sinon-chai/node_modules/sinon-chai/lib/sinon-chai.js:9


[16:45:31] 'test' errored after 14 s
[16:45:31] Error: 1
  at formatError (/usr/local/lib/node_modules/gulp/bin/gulp.js:169:10)
  at Gulp.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp.js:195:15)
  at Gulp.EventEmitter.emit (events.js:95:17)
  at Gulp.Orchestrator._emitTaskDone (/home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
  at /home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/index.js:275:23
  at finish (/home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
  at cb (/home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
  at removeAllListeners (/home/kuchumovn/pussy_face/node_modules/karma/lib/server.js:301:7)
  at Server.<anonymous> (/home/kuchumovn/pussy_face/node_modules/karma/lib/server.js:312:9)
  at Server.g (events.js:180:16)
  at Server.EventEmitter.emit (events.js:117:20)
  at net.js:1273:10
  at process._tickCallback (node.js:415:13)

They say:

Your unit test has the line require('../index'), but the problem is that your test is going to run in a browser environment, which does not have a native require function (hence the ReferenceError). If you need to include a separate file you could us the "requirejs" library (which is intended for browsers). Or you could use a <script> tag in your HTML file? Or maybe just a simple Ajax call...
@bobfields
Copy link

Downgrading karma-sinon-chai from 1.0.0 to 0.3.2 fixes this issue for us, all other dependencies (grunt, karma, sinon, chai) kept at the latest versions. Somebody else posted the same issue to stackoverflow: http://stackoverflow.com/questions/31469889/karma-sinon-chai-fails-after-moving-to-windows/31480290.

@catamphetamine
Copy link
Author

Oh, ok, thanks

@bobfields
Copy link

But it is still an issue with v1.0.0, wondering why the issue was closed.

@catamphetamine
Copy link
Author

@bobfields oh, okay, I thought you ment me to close this one. reopening it then.

@bobfields
Copy link

Reverting karma-sinon-chai index.js in v1.0.0 to the version contained in v0.3.2 fixes the problem, even with the updated chai, sinon, sinon-chai dependency versions. Looks like extensive changes to the way sinon and chai are resolved and the sinon files are mapped.

@leoyuholo
Copy link

I run into the same issue today, and curious why it didn't cause problem before. I just found out that chai updated to 3.1.0 yesterday ('3.1.0': '2015-07-16T21:42:30.681Z') using npm view chai and dependence in package.json is "chai": "~3.0"

By the way, issue #20 also mentioned a similar problem and index.js is updated but not yet propagated to npm.

Are these related? Wondering the problem is known and solved, but just not yet propagated to npm.

@eddiemonge
Copy link

@kmees still around? If you want help maintaining this, I'm sure people would love to contribute.

@kevicency
Copy link
Owner

@eddiemonge yeah, just had to take a break. contributions are welcome, hope everything is fixed in 1.1.0 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants