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

210
Vistas
Unable to Jest Test constant variable having ternary operator

I am using jest react testing library to unit test my application. I am unable to unit test my constant file containing ternary operator for a constant variable.

Code to be tested:

export const ApplicationConstant = {
    type: process.env.REACT_APP_NODE_ENV === 'production' ? 'production' : 'development',
} 

Unit test code:

import {ApplicationConstant} from './application.constant.js';
test('Check application type',()=>({
    expect(ApplicationConstant.type).toBe('production'); //Fails

});

How to get 100% coverage for ternary operator for constant file containing constants?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

import {ApplicationConstant} from './application.constant.js';
test('Check application type',()=>({
    Object.defineProperty(ApplicationConstant, 'type', {
        value: 'production',
    })
    expect(ApplicationConstant.type).toBe('production'); 

});
about 4 years ago · Juan Pablo Isaza Denunciar
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