1

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

Over Age
  • 21
  • 3
  • Are you running with a host azure devops agent or self-host one? If you are running the self-host agent, suggest you try to remote to the build agent, then run the test locally in the build agent. This will narrow down if this related to Azure DevOps Pipeline Configuration. Sounds more like a Node.js side issue. – PatrickLu-MSFT Feb 28 '20 at 08:19
  • Thanks for the reply, its not self hosted sadly – Over Age Feb 28 '20 at 09:27
  • HI Over Age, according to your description. It's really hard to determine if this issue related to Azure DevOps side or your agent environment. I would suggest you deploy a self-host agent and make sure the environment is as same as local. Then run the build/test on the self-host agent. This will help you narrow down the issue related to Azure DevOps or not. About how to deploy self-host agent, you could refer this link: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops – PatrickLu-MSFT Mar 03 '20 at 13:23
  • 1
    Hi again thanks for the reply, found the issue, its related to ubuntu. Somehow one of the san serif fonts we are using in our pdf generator makes the text un-selectable when parsing it with the above pdf parser, but only in ubuntu... – Over Age Mar 04 '20 at 15:39
  • Glad to hear this, always better when you fix it yourself. You could move your comment to below as an answer. Then you could [mark your reply as an answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), which will also helps others in the community. – PatrickLu-MSFT Mar 04 '20 at 15:41

0 Answers0