0

I wanted to test the following method but failing. "npm ERR! code ELIFECYCLE" "This is probably not a problem with npm. There is likely additional logging output above."

const co2cal = (tm, d, output) => {
    switch (tm) {
          case 'small-diesel-car': 
              if(output === 'g') {
                  console.log(`Your trip caused ${transportationMethod['small-diesel-car'] * d}g of CO2-equivalent`);
              } else {
                  console.log(`Your trip caused ${(transportationMethod['small-diesel-car'] * d / 1000).toFixed(1)} kg of CO2-equivalent`);
              }
              break;
          case 'small-petrol-car': 
              if(output === 'g') {
                  console.log(`Your trip caused ${transportationMethod['small-petrol-car'] * d}g of CO2-equivalent`);
            } else {
                  console.log(`Your trip caused ${(transportationMethod['small-petrol-car'] * d / 1000).toFixed(1)} kg of CO2-equivalent`);
            }
          break;
    default: console.log('No transportation method in this name');


}
};
     


    //Test method Error -- 'Received: undefined'
    const testCo2cal = require('./co2cal');
    test('should return 2.1', () => {
      expect(testCo2cal("small-diesel-car", 15)).toEqual(2.1);
    }); 
Azief
  • 3
  • 2

0 Answers0