1.0.9 • Published 4 years ago

chai-pdf v1.0.9

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

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);
1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago