Skip to content

marcdacz/chai-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chai-pdf

Awesome chai plugin for testing PDF files

Setup

Install the following system dependencies

Install npm module

npm install chai-pdf

Folder Structure

Place your actual and baseline pdfs inside the following folders:

  • /data/actualPdfs
  • /data/baselinePdfs

Usage

// Using BDD style "expect"
const chai = require('chai');
const expect = chai.expect;
chai.use(require('chai-pdf'));

// Compare Pdfs by just indicating their filenames (with or without extension)
await expect("ActualPdfFilename").to.be.samePdfAs("ExpectedPdfFilename")

// You can also add options such as page masking
let options = {
    masks: [
        { pageIndex: 1, coordinates: { x0: 35, y0: 70, x1: 145, y1: 95 } }
    ]
}
await expect("ActualPdfFilename.pdf").to.be.samePdfAs("ExpectedPdfFilename.pdf", options);

// Using BDD style "should"
const chai = require("chai");
const should = chai.should();
chai.use(require("../src/chaiPdf"));

let actualFileName = "maskedSame.pdf";
let baselineFileName = "baseline.pdf";
let options = {
     masks: [{ pageIndex: 1, coordinates: { x0: 35, y0: 70, x1: 145, y1: 95 } }]
};
await actualFileName.should.be.samePdfAs(baselineFileName, options);

About

Awesome chai plugin for testing PDF files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published