1

I am adding some tests into my postman API request and I was wondering how I can give a regex into the Content-Disposition header value, I have something like this but date is dynamic and just wanted to regex or do some other approach, any ideas?

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");
Cesar
  • 49
  • 1
  • 3

1 Answers1

3

You can do this:

pm.test("My test file name is downloaded successfully", () => { 
    const content = pm.response.headers.get("Content-Disposition");
    pm.expect(content).to.match(/^attachment.+xlsx$/);
});
lucas-nguyen-17
  • 5,516
  • 2
  • 9
  • 20