We have an Nodejs api endpoint that creates a pdf stream using the html-pdf and streams it through the response. This is working as expected, we can download the pdf through the browser.
I am trying to write a unit test (chai and mocha) for asserting the contents of the pdf with pdf-parse, it all works fine locally, however when running the same unit test in the Azure pipelines the content is somehow empty even though the size of the buffer is about the same as the pdf.
Test:
chai
.request(server)
.post(`/pdf/download`)
.pipe(concatStream(buff => {
pdfParse(buff).then((data: any) => {
console.log(data.text);
expect(data.text).to.include("Text to be asserted");
});
PS: The pipeline is running on Ubuntu 18.04 and I am using concatStream to convert stream to buffer. Also if there's a better solution for such a test please let me know. Have also tried using pdfreader but same result.
Thanks