ERROR [karma]: [TypeError: Cannot call method 'push' of undefined] when adding HTML output - node.js

I'm using karma and jasmine for some unit testing. I'd like an html output instead of checking the console / terminal and found this: https://www.npmjs.org/package/karma-htmlfile-reporter which is perfect for my requirements.
When I run it I get an error :
`ERROR [karma]: [TypeError: Cannot call method 'push' of undefined]
TypeError: Cannot call method 'push' of undefined
at onBrowserStart (/usr/local/lib/node_modules/karma/lib/reporters/base.js:14:20)
at null.<anonymous> (/usr/local/lib/node_modules/karma/lib/events.js:15:22)
at EventEmitter.emit (events.js:117:20)
at onStart (/usr/local/lib/node_modules/karma/lib/browser.js:128:13)
at Socket.<anonymous> (/usr/local/lib/node_modules/karma/lib/events.js:15:22)
at Socket.EventEmitter.emit [as $emit] (events.js:117:20)
at SocketNamespace.handlePacket (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22)
at Manager.onClientMessage (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38)
at WebSocket.Transport.onMessage (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transport.js:387:20)
at Parser.<anonymous> (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:39:10)
I've hunted on google for an answer but yet to find one, if I remove the 'html' from the reports in the config it works fine. I've not used jasmine / karma before so unsure where to look for help.
The part of the config related to reports: `
reporters: ['progress', 'html'],
htmlReporter: {
outputFile: 'tests/units.html'
},``
Thanks for any assistance.

I switched to karma 0.10 and everything works.
$ npm uninstall karma
and run following in project root:
$ npm install karma#0.10
Good luck

Related

Jasmine test suite doesn't run

I can't figure out what I've done to mess up Jasmine.
Here's a link to the repo I'm working on:
https://github.com/bryanbeus/04-09-bloccit/tree/v0.1.3
The problem is somehow related to the files /spec/integration/flairs_spec.js, /spec/integration/post_spec.js, and probably more.
The problem can be seen when running a command like npm test. I get the following result:
04-09-bloccit#1.0.0 test /home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit
export NODE_ENV=test && jasmine
npm ERR! Test failed. See above for more details.
It used to be that this ERR would only occur if I had an non-compilable error somewhere in my code. (For example, a simple thing like ; out of place, or an improper use of this.)
Recently, I've heard from someone else that this type of failure for Jasmine isn't normal. Usually, if there's a problem in the code, Jasmine is still supposed to say something. ?
Whatever the problem is, it is now spreading to general usage.
I'm trying to call the server npm module for a test with this command:
const server = require("../../src/server");
If that line is anywhere in my files, the entire Jasmine test fails in the exact same manner. (npm ERR... and no other details.)
If I run npm test /spec/integration/flairs_spec.js with that call to server active, the test fails in the npm ERR... manner.
However, if I comment out the call to server, then Jasmine at least runs. It returns this error:
....................
Started
F
Failures:
1) routes : flairs GET /topics/:topicId/posts/:postId/flairs/new should render a new flair form
Message:
Expected Error: connect ECONNREFUSED 127.0.0.1:3000 to be null.
Stack:
Error: Expected Error: connect ECONNREFUSED 127.0.0.1:3000 to be null.
at
at Request.request.get [as _callback] (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/spec/integration/flairs_spec.js:57:21)
at self.callback (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:186:22)
at Request.emit (events.js:160:13)
at Request.onRequestError (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:878:8)
at ClientRequest.emit (events.js:160:13)
at Socket.socketErrorListener (_http_client.js:389:9)
at Socket.emit (events.js:160:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at process._tickCallback (internal/process/next_tick.js:152:19)
Message:
Expected undefined to contain 'New Flair'.
Stack:
Error: Expected undefined to contain 'New Flair'.
at
at Request.request.get [as _callback] (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/spec/integration/flairs_spec.js:58:22)
at self.callback (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:186:22)
at Request.emit (events.js:160:13)
at Request.onRequestError (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:878:8)
at ClientRequest.emit (events.js:160:13)
at Socket.socketErrorListener (_http_client.js:389:9)
at Socket.emit (events.js:160:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at process._tickCallback (internal/process/next_tick.js:152:19)
1 spec, 1 failure
Finished in 0.399 seconds
npm ERR! Test failed. See above for more details.
.......
So, removing the server call at least lets Jasmine run.
Any help on this is appreciated. Thank you for helping a novice programmer.
I found the source of the error.
Using git diff v0.1.2..v0.1.3 I was able to see the differences between the last working branch, and the current one.
From here, I saw that in db/src/controllers/flairController.js I had placed this in the controller for the flair object:
const flairQueries = require("./db/queries.flairs.js");
The problem with that is that the directory isn't correct. I replaced it with this:
const flairQueries = require("../db/queries.flairs.js");
After this, the Jasmine test suite worked.
I understand that this means that the controller couldn't load properly. The full understanding of this is still elusive, so if anyone has time to try to explain, I would appreciate it. Otherwise, we can consider this question closed. Thanks!

Mocha-allure-reporter not working with node js

I am facing issue when I run my tests with mocha-allure-reporter ,the tests are running successfully with mocha ,but mocha --reporter mocha-allure-reporter returns the following error
> notifications-api#1.0.0 test /app
> mocha --reporter mocha-allure-reporter
2016-11-15T06:13:26.762Z - info: Notification API up and running on port 4000
2016-11-15T06:13:26.773Z - error: Tue, 15 Nov 2016 06:13:26 GMT uncaughtException
2016-11-15T06:13:26.775Z - error: TypeError: test.currentRetry is not a function
at Runner.<anonymous> (/app/node_modules/mocha-allure-reporter/index.js:29:19)
at emitOne (events.js:77:13)
at Runner.emit (events.js:169:7)
at next (/app/node_modules/mocha/lib/runner.js:517:10)
at Runner.runTests (/app/node_modules/mocha/lib/runner.js:556:3)
at /app/node_modules/mocha/lib/runner.js:637:10
at next (/app/node_modules/mocha/lib/runner.js:283:14)
at Immediate._onImmediate (/app/node_modules/mocha/lib/runner.js:319:5)
at processImmediate [as _immediateCallback] (timers.js:383:17)
npm ERR! Test failed. See above for more details.
Can anyone help to fix this issue?
The issues can be resolved by updating your mocha to the latest version probably to v3 or above and allure reporter too. If the issue still persists regarding TypeError: test.currentRetry is not a function , please replace the line of code
if (!test.currentRetry()) {
with the following
if (typeof test.currentRetry !== "function" || !test.currentRetry()) {

MMO server crash node.js and mongodb

so ive been following this tutorial series the guy whos series it is has been no help but when i run i receive this error, has anyone had this error before or knows how to fix it please help me
"C:\Program Files (x86)\JetBrains\WebStorm 10.0.4\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" server.js --env=test
test
Loading Initializer: 00_packetmodels.js
Loading Initializer: 01_mongodb.js
js-bson: Failed to load c++ bson extension, using pure JS version
Loading Model: user.js
Loading Map: prison_1.js
Initialize Completed, Server runnng on port: 8082 for environment: test
c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\base.js:246
throw message;
^
TypeError: Cannot read property 'length' of undefined
at processResults (c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1581:31)
at c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1619:20
at c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1157:7
at c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1890:9
at Server.Base._callHandler (c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\base.js:448:41)
at c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:481:18
at MongoReply.parseBody (c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\responses\mongo_reply.js:68:5)
at null.<anonymous> (c:\Users\poeketis\WebstormProjects\Prison rp\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:439:20)
at emitOne (events.js:77:13)
at emit (events.js:169:7)
Process finished with exit code 1
and here is a picture of the mongo log
http://i.imgur.com/ZXcBojJ.png
this is a very common issue (https://www.google.com.ua/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=js-bson%3a%20failed%20to%20load%20c%2b%2b%20bson%20extension%2c%20using%20pure%20js%20version).
Such issues often occur if bson was compiled against a Node version different from the one you run your application with.

OpenID for Node.js cannot run the sample server

When I try to run the sample nodejs server using openid found at
http://ox.no/software/node-openid
I get the following trace:
/home/ubuntu/node_modules/openid/openid.js:868
return callback({ message: 'No providers found for the given identifier'
^
TypeError: undefined is not a function
at /home/ubuntu/node_modules/openid/openid.js:868:14
at /home/ubuntu/node_modules/openid/openid.js:656:13
at /home/ubuntu/node_modules/openid/openid.js:612:11
at /home/ubuntu/node_modules/openid/openid.js:254:9
at IncomingMessage.<anonymous> (/home/ubuntu/node_modules/openid/openid.js:258:32)
at IncomingMessage.emit (events.js:88:20)
at HTTPParser.onMessageComplete (http.js:137:23)
at CleartextStream.ondata (http.js:1150:24)
at CleartextStream._push (tls.js:375:27)
at SecurePair.cycle (tls.js:734:20)
Perhaps the problem is the openid_identifier I supply on the first page. I have tried
yahoo.com
www.google.com/accounts/o8/id
www.google.com/accounts/o9/ud
When I try www.google.com/accounts/o8/id I get a slightly different trace:
/home/ubuntu/node_modules/openid/openid.js:895
return callback(null, authUrl);
^
TypeError: undefined is not a function
at successOrNext (/home/ubuntu/node_modules/openid/openid.js:895:18)
at /home/ubuntu/node_modules/openid/openid.js:1008:3
at successOrNext (/home/ubuntu/node_modules/openid/openid.js:909:9)
at /home/ubuntu/node_modules/openid/openid.js:931:5
at /home/ubuntu/node_modules/openid/openid.js:678:7
at /home/ubuntu/node_modules/openid/openid.js:544:16
at /home/ubuntu/node_modules/openid/openid.js:254:9
at IncomingMessage.<anonymous> (/home/ubuntu/node_modules/openid/openid.js:258:32)
at IncomingMessage.emit (events.js:88:20)
at HTTPParser.onMessageComplete (http.js:137:23)
Anyone have any idea what I've done wrong, how I can fix it?
At least for me the following worked like a charm:
git clone git#github.com:havard/node-openid.git
cd node-openid/
sudo node sample.js
I then launched my browser to localhost and logged in with Google's address: https://www.google.com/accounts/o8/id
It worked fine. So it looks like the sample on their website is a bit out of date while the one in their git repo works.

hubot fails to start with flowdock adapter

node: 0.10.0
npm: 1.2.14
I've set the environment variables HUBOT_FLOWDOCK_LOGIN_EMAIL and HUBOT_FLOWDOCK_LOGIN_PASSWORD, and then tried the following.
Pulled down the prebuilt hubot from the hubot site.
Modified the package.json as above.
Run npm install
Added
"hubot-flowdock": ">= 0.0.1",
just underneath dependencies in my package.json
Removed redis from hubot-scripts.json
run npm install
then running ./bin/hubot -a flowdock -d
With this implementation, ./bin/hubot - flowdock
Produces the following stacktrace:
TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at Session.EventEmitter.emit (events.js:74:15)
at Request._callback (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/lib/flowdock.js:49:17)
at Request.self.callback (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/node_modules/request/main.js:122:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/node_modules/request/main.js:661:16)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/node_modules/request/main.js:623:14)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:870:14
Looking at /Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/lib/flowdock.js:49:17, that is a fail on a response statusCode > 300.
So far so good. Adding a console.log to the line above produces "401" unauthorized.
How? The credentials are correct (I log in with that email/password routinely).
For anyone who cares, eventually I realized that my password was incorrect. I was attempting to use my email password, while the correct answer is to use the password you set up when you first connect to flowdock

Resources