lundi 1 juillet 2019

Hoo to fix moxios test failing with axiosInstance.get('url').then(...).finally is not a function

Hi I am trying to write a simple test case with help of moxios I have the project setup in my multiple systems(pc) and the code is in sync with git. The problem is that test is failing for one system only. It is working in all pc except one.

I have tried import * as axios from 'axios';

and also tried to clear npm cache but of no use

describe('test suite', () => {
   let axiosInstance;
   beforeEach(() => {
      axiosInstance = axios.create();
      moxios.install(axiosInstance);
   });
   afterEach(() => {
      moxios.uninstall(axiosInstance);
   });
   it('should pass', (done) => {
      moxios.stubRequest('url', {
         status: 200,
         responseText: 'reducedAsxResponse'
      });
      axiosInstance.get('url')
         .then(res => assert(res.status === 200))
         .finally(done);
   });
});

Could you please tell where could be a problem. Does the npm or node version affect the test case as it is different for different pc. I have installed the same dependencies in all the systems but at different point of times so could it be that a minor version upgrade could have broken the test code. If there is amy other possibility please help me out.

Aucun commentaire:

Enregistrer un commentaire