Issues with Code coverage when using FDK Test

When attempting to reach recommended code coverage on an app, I managed to cover all possitive scenarios which produced the following code coverage results.

And when further inspecting server.js code in coverageI saw the following.


To Cover those negative cases (error scenarios) I wrote unit tests with the test frameworks pecificly targetting the code section above. and when running the tests all my tests pass while producing expected console logs. however, when inspecting code coverage, the following happened

  1. Coverage for app.js disappeared
  2. Coverage for server.js instead of increasing as expected decreased.

and the code for server.js when inspected in coverage report looked like this

This is odd considering it’s the same code as shown above in image 2.

This causes problems when publishing the app to marketplace as it’s hard to reach expected code coverage.

Hey @falconZ,

Please ensure that when you are testing the app, there are no code changes and the test frameworks can cover all possible scenarios that way the app is end-to-end tested.

You can follow this guide - Freshworks Developer Docs | Introduction to code coverage for mode info about code coverage.

hey Jones,
Thanks for the response. I did follow the guide and i tried resetting existing coverage by deleting both coverage folder and report.json esentially setting up everything from scratch. And here’s what i observed when i ran the following tests with fdk test

describe("On App Install", function () {
  it("should return a webhook url", function () {
    const url =

    const stubGeneratedURL = this.stub("generateTargetUrl").resolves(url);

    this.invoke("onAppInstall", onAppInstallArgs);


  it("Should store webhook URL in db", function () {
    const stubStoreDataInDB = this.stub("$db", "set").callsFake(function (
    ) {

     this.invoke("onAppInstall", onAppInstallArgs);


  it("should return a error when unable to store webhook url", function () {
    const stubDbStoreError = this.stub("$db", "set").rejects({
      error: "unable to store data in DB",

    this.invoke("onAppInstall", onAppInstallArgs);


  it("should throw error if unable to generate target url", function () {
    const stubErrorGenerateTargetUrl = this.stub("generateTargetUrl").rejects({
      error: "unable to generate target url",

    this.invoke("onAppUninstall", onAppInstallArgs);


which definitely invokes those functions as expected as they produce expected console logs however when inspecting coverage i see the following

Web capture_21-12-2023_173712_wsl.localhost

and when i tried testing the same appInstallHandler with local test simulations on /web/test the following happens

Web capture_21-12-2023_173839_wsl.localhost

And i repeated the same thing again to be sure and when i run fdk test whole coverage gets resetted to the state above in image 1.

Hey Jones,
I tried everything on the guide even rewrote my tests, but nothing seems to be working still running into the same issue. I could cover all cases for the frontend but this app has been mostly built around the backend relying on SMI functions. When trying to test server code via unit testing it resets the coverage generated by testing app.js as the front end relies heavily on data from SMI functions. it is hard to create error scenarios as trying out the strategy described for testing app.js - Intentionally making mistakes like misspelling server invocations doesnt work as even small changes reset the coverage.

This either-or pattern for coverage doesnt make much sense as unit tests should conpensate for regular coverage testing and vice versa. if i only rely on coverage from unit tests my app.js coverage resets, and if i try to coverage for app.js my server.js resets.

Kindly help me with this. I wish to publish this app to marketplace ASAP.