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

208
Views
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 answers
Answer question

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 Report
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!