I am using the Test Harness for my cloud code scripts logic.
I would like to see (without using the debugger), the output of various variables for easy reference.
How can I write/add to the output in the test harness?
For instance, I'd like to do something like...
console.log("The total count was : " + myCount);
But console.log is not recognised. Is there a way to do this?
Best Answer
C
Customer Support
said
over 5 years ago
Hi Andrew,
You can use scriptData to do this. In your script use Spark.setScriptData("result", value) to do it. Replace the values with whatever is relevant to you. You'll see the scriptData in the test harness inspectors response.
to capture whatever it is you want to debug. Then through the NoSQL Explorer, do a find on the log collection. Your most recent logs will appear at the bottom. If you'd like to make logs show up at the top, simply put {ts:-1} in the "Sort" box.
Hope this answers your question, let me know if you have any more issues.
-Pádraig
A
Andrew Silber
said
over 5 years ago
That works, but it's a slow workflow process, having to go in and out of the DB, query all, dig out what you want, then delete the log, each time you run. Would be much better if there were some convenient way to output to a window or something.
Andrew
Customer Support
said
over 5 years ago
Answer
Hi Andrew,
You can use scriptData to do this. In your script use Spark.setScriptData("result", value) to do it. Replace the values with whatever is relevant to you. You'll see the scriptData in the test harness inspectors response.
Regards,
Liam
A
Andrew Silber
said
over 5 years ago
But what if I have more than one piece of data? It means I'd have to build up an array of result text... Which is possible, but it seems a little hacky ;) Ideally there'd be something like:
TestHarness.log()
Of course I don't know what your system is architected like under the hood, so maybe that's just not possible without a massive rewrite... ?
Cheers, Andrew
Customer Support
said
over 5 years ago
Hey Andrew,
You can use use Spark.setScriptData multiple times in a script so long as the value is different.
Greg Quinn
I am using the Test Harness for my cloud code scripts logic.
I would like to see (without using the debugger), the output of various variables for easy reference.
How can I write/add to the output in the test harness?
For instance, I'd like to do something like...
console.log("The total count was : " + myCount);
But console.log is not recognised. Is there a way to do this?
Hi Andrew,
You can use scriptData to do this. In your script use Spark.setScriptData("result", value) to do it. Replace the values with whatever is relevant to you. You'll see the scriptData in the test harness inspectors response.
Regards,
Liam
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Greg,
We have a way of logging debug messages that will be saved in the rumtime collection "log".
You can simply put:
Spark.getLog().debug(<Your Debug Message here>)
to capture whatever it is you want to debug. Then through the NoSQL Explorer, do a find on the log collection. Your most recent logs will appear at the bottom. If you'd like to make logs show up at the top, simply put {ts:-1} in the "Sort" box.
Hope this answers your question, let me know if you have any more issues.
-Pádraig
Andrew Silber
Andrew
Customer Support
Hi Andrew,
You can use scriptData to do this. In your script use Spark.setScriptData("result", value) to do it. Replace the values with whatever is relevant to you. You'll see the scriptData in the test harness inspectors response.
Regards,
Liam
Andrew Silber
Ideally there'd be something like:
TestHarness.log()
Of course I don't know what your system is architected like under the hood, so maybe that's just not possible without a massive rewrite... ?
Cheers,
Andrew
Customer Support
You can use use Spark.setScriptData multiple times in a script so long as the value is different.
Sean
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics