Can't get test framework to work

I started looking at using the test framework in the FDK and followed the documentation I found on the forum but when I run fdk test I get the following error in the console.

(node:9284) UnhandledPromiseRejectionWarning: TypeError: this.invoke is not a function
at Object. (C:\XXXXXXXXXXXX\test\onTicketUpdate.test.js:4:6)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at C:\Users\XXXXX\AppData\Roaming\npm\node_modules\fdk\node_modules\mocha\lib\mocha.js:250:27
at Array.forEach ()
at Mocha.loadFiles (C:\Users\XXXXX\AppData\Roaming\npm\node_modules\fdk\node_modules\mocha\lib\mocha.js:247:14)
at (C:\Users\XXXXXX\AppData\Roaming\npm\node_modules\fdk\node_modules\mocha\lib\mocha.js:576:10)
at (C:\Users\XXXXX\AppData\Roaming\npm\node_modules\fdk\lib\cli\test.js:167:8)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async runCLI (C:\Users\XXXXX\AppData\Roaming\npm\node_modules\fdk\index.js:261:5)
(node:9284) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9284) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The test script in onTicketUpdate.test.js is:

const ticketUpdateArg = require(’./test_data/onTicketUpdate.json’)
this.invoke(‘onTicketUpdate’, ticketUpdateArg);

Hi Rob,

I hope the test files are placed in the wrong folder and in the wrong name.
The test framework is supported only for the Serverless app. So, it should placed under <App root dir>/server/test/ and the files should match with the files in the actual serverless component of the app.

Could you refer to this example app and replicate the file structure before trying again? Let us know if it works.

1 Like

Hi Raviraj,

That example app is perfect. I can now see what I was doing wrong. Automating the serverless testing will be a good time saver.

Many thanks for the quick response.



Hi Raviraj,

I can confirm I have it working now and can automate tests on the serverless app. Thanks for your help.


1 Like

A post was split to a new topic: How to dynamically change iparams automatically for serverless tests?

Hi @RobAtOpinyin,

Thanks for your confirmation.

For your follow up question, I have moved it to a new topic for a different discussion on that.