1

The way my Google Home app is organizaed is a class containing all intent methods and then

at the bottom a line

exports.myapp = functions.https.onRequest(
  (request, response) => new MyApp(request, response).run()
);

Since the functions in MyApp depend on request to get parameters from, I assume a unit test has to have a faked input request correct?

From the Actions On Google simulator, I've been able to get requests, but I'm not sure how to fake the response for the response parameter to `MyApp constructor, especially since the returning thing from Actions on Google seems to be after running my actual code.

All of the following would be helpful: generic code snippets, links to test files/cases, request/response constructor arguments, etc.

Thank you!

Ggrimaldo
  • 327
  • 1
  • 7
rzs
  • 99
  • 1
  • 3
  • 8
  • for reference, I am trying to use TDD Mocha, but that may be relatively unrelated – rzs Feb 05 '18 at 03:59
  • 2
    You can take a look at [some of the tests](https://github.com/actions-on-google/actions-on-google-nodejs/tree/master/test) done in the library itself. If you have a mock of express objects, you may be able to simulate what the response should be. – Nick Felker Feb 05 '18 at 08:20
  • Nick is right :) ...and in order to fake the response, you should take the code from: https://github.com/actions-on-google/actions-on-google-nodejs/blob/master/test/utils/mocking.js it's a good example for that. – Ido Green Feb 05 '18 at 17:59
  • I see, from the link posted by @IdoGreen, at line 80, where do I get that request from? It doesn't seem to be the same format as given by the Actions on Google Simulator, nor from the DialogFlow JSON request? – rzs Feb 06 '18 at 02:36

0 Answers0