There is a named export in the config.js which sets based on environment variable provided or a default value.
export const Product = process.env.product || 'X';
I want to test this function inside product.js for different Products like X, Y, Z.
import {Product} from './config.js';
export const testProduct(){
   if(Product === 'X') {
     return 'Product X';
   }
   if(Product === 'Y'){
     return 'Product Y';
   }
   if(Product === 'Z'){
     return 'Product Z'; 
   }
   return 'Invalid product';
}
Tests goes here,
import { testProduct } from './product.js';
//pass
it("should test testUser for defaullt Product", ()=> {
   const result = testProduct();
   expect(result).toBe('Product X')
});
//pass since product X is default
it("should test testUser for Product X", ()=> {
   const result = testProduct();
   expect(result).toBe('Product X')
});
//failed
it("should test testUser for Product Y", ()=> {
   const result = testProduct();
   expect(result).toBe('Product Y')
});
//failed
it("should test testUser for Product Z", ()=> {
   const result = testProduct();
   expect(result).toBe('Product Z')
});
I'm not looking for changing the environment variable. I know that is not possible. I want to test the function by mocking the Product value used in the testProduct function to have full test coverage.