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

CH11: Testing Controllers with Authentication #55

Open
Waddas opened this issue Oct 10, 2017 · 0 comments
Open

CH11: Testing Controllers with Authentication #55

Waddas opened this issue Oct 10, 2017 · 0 comments

Comments

@Waddas
Copy link

Waddas commented Oct 10, 2017

When running mocha on the updated test/server/controllers/api/posts.spec.js file, the test fails with the following error:

 2 passing (287ms)
  1 failing

  1) controllers.api.posts
       POST /api/posts
         "before each" hook:
     Uncaught TypeError: websockets.broadcast is not a function
      at controllers/api/posts.js:41:13
      at RedisClient.<anonymous> (pubsub.js:12:3)
      at return_pub_sub (node_modules/redis/index.js:786:18)
      at RedisClient.return_reply (node_modules/redis/index.js:833:9)
      at JavascriptRedisParser.returnReply (node_modules/redis/index.js:192:18)
      at JavascriptRedisParser.execute (node_modules/redis-parser/lib/parser.js:574:12)
      at Socket.<anonymous> (node_modules/redis/index.js:274:27)
      at readableAddChunk (_stream_readable.js:176:18)
      at Socket.Readable.push (_stream_readable.js:134:10)
      at TCP.onread (net.js:547:20)

In the controllers/api/posts.js file, this is where the code breaks:

pubsub.subscribe('new_post', function(post) {
	websockets.broadcast('new_post', post)
})

My guess is that websockets is not available to the testing code, but i'm unsure on how to resolve this.

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

1 participant