- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想伪造一个以 xml 格式响应的服务器。我该怎么做?
server.respondWith(
"GET",
"testurl",
[
200,
{
"Content-Type": "application/xml",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "max-age=0, must-revalidate",
"Connection": "close"
},
<note></note>
]
);
最佳答案
当您使用 respondWith
模拟响应时,该方法的第三个参数是一个描述所需响应的数组。数组的第三个元素,其中有 <note></note>
是响应的主体,因此您可以将 XML 作为字符串放在那里。
var xml = getXmlStringSomehow();
server.respondWith(
"GET",
"testurl",
[
200,
{
"Content-Type": "application/xml",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "max-age=0, must-revalidate",
"Connection": "close"
},
xml
]);
关于javascript - sinon fakeserver 可以发送 xml 响应吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35305673/
我将 QUnit 与 sinon 一起使用。我怎样才能制作 sinon 的 fakeserver响应由相同方法调用的链式 ajax? module('demo', { beforeEach:
根据documentation ,Sinon fakeserver 可以使用正则表达式模式来匹配 URL: server.respondWith(method, urlRegExp, response
Sinon documentation声明可以访问请求对象: server.respondWith(response); [...] When the response is a Function,
我正在尝试使用 sinon.fakeServer 或 sinon.useFakeXMLHttpRequest 和 require.js 来模拟 Backbone.Model.fetch 请求。 这是我
我正在尝试使用 Sinon.js 模拟服务器对 POST 请求的响应。它似乎工作正常,只是不会触发成功回调。 # In the Exercise model: submit: (query) ->
我想伪造一个以 xml 格式响应的服务器。我该怎么做? server.respondWith( "GET", "testurl", [
我正在尝试为 API 调用设置测试。我在 before 方法中创建了假服务器,并使用 $.ajax 与实际的 api 调用来测试基本实现。但是,我在 server.requests 中没有看到任何请求
我有以下 Jasmine 规范: describe "plugins", -> beforeEach -> @server = sinon.fakeServer.create()
我正在努力弄清楚如何在我的单元测试中使用 sinon 来伪造服务器。 他们文档中的例子是: setUp: function () { this.server = sinon.f
你好,我是 sinon.js 的新手。我正在编写 Jasmine BDD 测试代码。我想制作一个从 flickr 获取照片 的小应用程序。 describe("with stub", functio
你好,我是 sinon.js 的新手。我正在编写 Jasmine BDD 测试代码。我想做一个小应用程序从 flickr 获取照片。 describe "with stub", -> before
我是一名优秀的程序员,十分优秀!