Skip to content

beef-noodles/js-test-cases

 
 

Repository files navigation

Window 对象的测试(jest)方法总结

test method

Dummy Fake Mock Stub Spy

  • 对属性(property)的test

  • 对方法(method) 的test

  • delete - 在原对象上进行测试

  • Object.defineProperty - 重新定义属性

  • mockfile - mock 整个被测文件

  • spyOn - 对特定方法进行mock

test method

Dummy Fake Mock Stub Spy

Ref

https://remarkablemark.org/blog/2018/11/17/mock-window-location/ https://wildwolf.name/jest-how-to-mock-window-location-href/ https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty https://www.jyt0532.com/2018/01/24/jinyong-test-double/