testing - 如何在邮递员中正则表达式 Content-Disposition 标头值?
问题描述
我在我的邮递员 API 请求中添加了一些测试,我想知道如何将正则表达式添加到 Content-Disposition 标头值中,我有类似的东西,但日期是动态的,只是想使用正则表达式或做一些其他方法,任何想法?
pm.test("My test file name is downloaded successfully", function () {
pm.response.to.have.header("Content-Disposition", "attachment; filename=Test Project_information_10_15_2021.xlsx");
解决方案
你可以这样做:
pm.test("My test file name is downloaded successfully", () => {
const content = pm.response.headers.get("Content-Disposition");
pm.expect(content).to.match(/^attachment.+xlsx$/);
});
推荐阅读
- sql - SQL - 根据前一行创建和关闭日期
- vba - 可以从两个源断开的 ADO 记录集计算第三个断开的 ADO 记录集吗?
- string - Python 3 中字符串属性的顺序
- python - 在 Google App Engine (Python) 中将数据从产品数据存储区传输到本地开发环境数据存储区
- ios - 离子原生存储在 iOS 上不起作用
- c# - 在 WPF 中将 Control2 的 DP 绑定到 Control1 的 DP
- java - java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
- selenium - nightwatch.js 如何创建警告
- html - 如何在 laravel 中使用带有刀片引擎的 vue-gettext 翻译静态文本?
- javascript - 如何使用 webpack 访问 $q 库?