Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
javascript: how to wait the result of the callback network.get_gateway_ip in karma configuration

I have a karma.conf.js config, and when I configure it I need an ip address of the current gateway.

I have found this solution to get the ip address:

var network = require('network');
var gatewayIp;
network.get_gateway_ip(function(err, ip) {
  console.log(err || ip); // err may be 'No active network interface found.'
  gatewayIp = ip;
});

config.set({ 
....
 hostname: gatewayIp
....
})

The problem is that I want to set the result of get_gateway_ip in config.set({ .... hostname: gatewayIp ... }) and the gatewayIp is not assigned when it run into config.set function call.

I cannot put the config.set() to the async result because it is not working (test are already running when the async result arrives).

How can I wait for the result of the get_gateway_ip?

I have seen this solution (How to return the response from an asynchronous call), but it not works becasue I cannot make karma's configuration to await.

Karma configuration:

module.exports = function(config) {

  ... 
  config.set({})

};

The function(config) cannot be async, because when I make it async it ignores the configuration:

module.exports = async function(config) {

  ... 
  config.set({}) // ignored
  ...
};

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!