Z
Z
zlodiak2019-08-24 22:55:23
Angular
zlodiak, 2019-08-24 22:55:23

How to debug unit tests?

Please tell me how to debug a unit test. For example, a project uses jest for testing. in one of the it blocks i have an error. I don’t know what it is, but the message after testing the tests is this:

● PageComponent › should redirect

    Cannot spyOn on a primitive value; undefined given

Maybe I'm giving spyOn a value of the wrong type. I would like to see what. What needs to be done for this?
I tried to add console.log() in the it block, but as a result, nothing could be seen in the console. Even after trying to redirect console output to a text file.
Isn't there a way to debug unit test code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KiT, 2019-08-24
Maverick @kit_de

in JS if two data types
Your test swears that it cannot do something with the primitive. It is quite possible that you got a primitive thinking that it is an object and you are trying to apply the wrong method to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question