How to test socket io from vue jest?

168 views Asked by At

this is my code from vue.js:

async getUserInformation(user_id){
   return await new Promise((resolve, reject) => {
      this.$socket.client.emit('getUserInfo', user_id, (err,res) => {
         err ? reject(err) : resolve(res)
      })
   })
},
async selectAction() {
  let getReponse= await this.getUserInformation(this.user_id)
  this.userInformation = getResponse
}

this is my code from vue jest

describe('editUser.vue', () => {
    let wrapper
  
    beforeEach(() => {
        wrapper = shallowMount(editUser, {
            mixins: [global]
        })
    });
    

    it('trigger submit button w/o data input from text fields', async () => {
        await wrapper.find('[data-testid="get_user_button"]').trigger('click')
    });
});

Picture below is the error message I received after I run unit testing enter image description here

0

There are 0 answers