because there is logic in the code to determine whether it is a mobile phone / PC, so you need to change the ua in the test code to test. How can it be implemented?
because there is logic in the code to determine whether it is a mobile phone / PC, so you need to change the ua in the test code to test. How can it be implemented?
configure jest config testEnvironmentOptions.userAgent
, refer to https://codeshelper.com/q/10.... Or use setupFiles
, for example
Object.defineProperty(global.window.navigator, "userAgent", {
writable: false,
value: "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.4(0x17000428) NetType/4G Language/zh_CN"
});
I don't know if it's all right, but I haven't tested it.
Previous: Vue router parameter transfer
there are mostly examples of testing static react or puppet components on the Internet, and there seems to be no example of testing components after getting data asynchronously. Do I understand the wrong test idea? Or is it the wrong way? ...
Hello, bosses. I encountered a problem when I was doing the jest test select the drop-down content of antd s select is displayed in dom and requires a mouse click. I used enzyme s mount method, and then simulated clicks through simulate ( change )...
jest test report clicks into the code details page, and some annotated screenshots are as follows What is the meaning of 5x on the left side of ? E hint else path not token what do you mean? solve. ...