Search code examples
node.jsmocha.jsdomain-driven-designwolkenkit

"Failed to get configuration" using Wolkenkit client in Mocha test through Node


I am trying to interact with my Wolkenkit application through a Mocha test in Node.

Following the tutorial on client connections, when running the test, I get the following error:

Error: Failed to get configuration.
  at ConfigurationWatcher.wentOffline (node_modules/wolkenkit-client/dist/ConfigurationWatcher.js:113:28)
  at /home/aef/Projects/experiments/wolkenkit_bullet/node_modules/wolkenkit-client/dist/ConfigurationWatcher.js:101:16
  at tryCatch (node_modules/es6-promise/dist/es6-promise.js:409:12)
  at invokeCallback (node_modules/es6-promise/dist/es6-promise.js:424:13)
  at publish (node_modules/es6-promise/dist/es6-promise.js:398:7)
  at publishRejection (node_modules/es6-promise/dist/es6-promise.js:339:3)
  at flush (node_modules/es6-promise/dist/es6-promise.js:128:5)
  at processTicksAndRejections (internal/process/task_queues.js:79:11)

Any help on resolving this is highly appreciated.

I added the following dependencies in package.json:

"devDependencies": {
  "chai": "^4.2.0",
  "mocha": "^7.0.1"
},
"dependencies": {
  "wolkenkit": "^3.1.2",
  "wolkenkit-client": "^3.1.0"
},

My test code looks like this:

'using strict';

const expect = require('chai').expect;
const wolkenkit = require('wolkenkit-client');

describe("wolkenkit app", () => {
    it("first test", async () => {
        const app = await wolkenkit.connect({host: 'local.wolkenkit.io', port: 3000});
    });
})

Solution

  • While setting the environment variable within Node didn't work, the problem has been solved by setting NODE_TLS_REJECT_UNAUTHORIZED to 0 in the system environment like:

    export NODE_TLS_REJECT_UNAUTHORIZED=0
    

    Thanks to @mattwagl for pointing into the right direction.