【问题标题】:How do I regex a Content-Disposition header value in postman?如何在邮递员中正则表达式 Content-Disposition 标头值?
【发布时间】:2021-12-04 01:19:48
【问题描述】:

我在我的邮递员 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");

【问题讨论】:

    标签: testing postman postman-testcase


    【解决方案1】:

    你可以这样做:

    pm.test("My test file name is downloaded successfully", () => { 
        const content = pm.response.headers.get("Content-Disposition");
        pm.expect(content).to.match(/^attachment.+xlsx$/);
    });
    

    【讨论】:

      猜你喜欢
      • 2014-05-28
      • 2015-05-12
      • 1970-01-01
      • 2021-11-25
      • 2011-02-02
      • 2012-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多