Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda