chai-image
Extends Chai with assertions about images
expectbufImage.to.matchImagebufExpectedImage;
Expected | Actual |
---|---|
Diff (LEFT_TOP Aligned) | Diff (CENTER Aligned) |
---|---|
In this case, matchImage
assertion will fail.
Usage
Install chai-image
to get up and running.
$ npm install chai-image --save-dev
Then:
;; chai.usechaiImage; // Then either:;// or:;// or:chai.should;// according to your preference of assertion style
Assertions
matchImage(expected: Buffer, options?: MatchImageOptions)
NOTE: Currently it only supports PNG image format.
Example
// Simple Example; ;; expectbufActual.to.matchImagebufExpected;
// Real-world Example; ; describe"ImageService",;
Tests image matches to given image or not.
Image comparision is proceeded by pixelmatch library.
If output config is provided, chai-image
will create some files to show diff results.
Changelog
See CHANGELOG.
Testing
$ npm run test
Build
$ npm run build
License
See full license on mooyoul.mit-license.org