S
S
seredaes2020-06-09 14:24:20
Software testing
seredaes, 2020-06-09 14:24:20

How to overcome error in Vue-test?

5edf712acf99b066919321.png

I connect the component and I don’t even run any test yet ... but it writes an error as in the screenshot.
Can you please tell me how to correct the error or how to remake the component?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2020-06-09
@UPSA

Without seeing the component code ... it's hard ))) for me ))) and it's interesting ))) I got up on callback functions)))
Why
window.$axios.get....
And not
import axios from 'axios';
...
axios.get
callback function is not defined.... probably the object is not the right one)))

S
seredaes, 2020-06-09
@seredaes

In general, I solved the problem like this:

// MOCK AXIOS REQUESTS
    axios.get.mockImplementation(url => {
      if (url === "/offers") {
        return Promise.resolve({
          data: {
            name: 12
          }
        });
      } else if (url === "/publishers") {
        return Promise.resolve({
          data: {
            name: 12
          }
        });
      }
    });

And the test worked great!
Might be useful to someone :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question