如何使用Jasmine BDD测试文件上传 [英] How to test file upload with Jasmine BDD

查看:154
本文介绍了如何使用Jasmine BDD测试文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery文件上传插件来管理图片文件上传。使用Jasmine测试图像提交的正确方法是什么。

I'm using jQuery file upload plugin for managing image file uploads. What will be the right way to test image submission with Jasmine.

推荐答案

我将看一下使用帮助库Sinon。 JS。您可以模拟XMLHttpRequest对象来拦截发布请求,并验证您的插件代码是否正确提交图像。特别是,看看Sinon.js文档的这一部分:

I would take a look at using the helper library Sinon.js. You can mock the XMLHttpRequest object to intercept the post request, and verify that your plugin code is submitting images correctly. In particular, take a look at this part of the Sinon.js documentation:

http://sinonjs.org/docs/#server

这篇关于如何使用Jasmine BDD测试文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆