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

253
Views
vue-test-utils, jest; ReferenceError: Request is not defined

I'm making a POST API call using ES6 Request() constructor in my vue.js application. The implementation works fine but my test suite (I'm using Jest with vue-test-utils) fails with the below error:

ReferenceError: Request is not defined

Here's the code snippet of my test case:

 it('Expect login to pass validation on submit', ()=> {
    const $router = {
      push : jest.fn()
    }
    // const validateLogin = jest.fn();
    const executeLoginSpy = jest.spyOn(wrapper.vm, 'executeLogin');
    wrapper = mount(Login, {
      localVue,
      vuetify,
      mocks: { $router },
      stubs: ['router-link'],
      data() {
        return {
          login: {
              email: 'test@testmail.com',
              password: 'test@@@@@@@@123'
          }
        }
      }
    });
    const button = wrapper.find('.submit-btn');
    button.trigger('click');
    expect(executeLoginSpy).toHaveBeenCalled();
    expect($router.push).toBeCalledWith('/');
});

I'm also attaching a snippet of my implementation using Request().

  const request = new Request('/api/token', {
    method: 'POST',
    body: formData,
  });

Any help would be appreciated. Thanks in advance!

about 4 years ago · Juan Pablo Isaza
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!