Reputation: 51
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:
[email protected] 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.
Upvotes: 0
Views: 671
Reputation: 51
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!
Upvotes: 1