[英]Testing an AJAX API that uses session authentication with Jasmine?
I have a restful API provided by Django and Tastypie protected with SessionAuthentication and DjangoAuthorization. 我有一个由Django和Deliciouspie提供的Restful API,受SessionAuthentication和DjangoAuthorization保护。 How can I get Jasmine to authenticate or step through the login page before each API test?
在每次进行API测试之前,如何让Jasmine进行身份验证或逐步完成登录页面?
Jasmin is a unit test framework. Jasmin是一个单元测试框架。 In unit test you should test your units without the need of external dependencies.
在单元测试中,您应该测试单元而无需外部依赖项。 So you shouldn't run your unit test again a real API.
因此,您不应再使用真实的API来运行单元测试。 Mock out your API with sinon server .
用sinon服务器模拟出您的API。
If you wanna run test with your real side and real API you should choose a integration test framework like Selenium or CapserJS 如果您想使用真实的方面和真实的API运行测试,则应该选择集成测试框架,例如Selenium或CapserJS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.