This repository was archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: chai screenshot plugin #306
Merged
stoffeastrom
merged 20 commits into
qlik-oss:master
from
cbt1:feat/chai-screenshot-plugin
Aug 9, 2018
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
61e1dc5
add chai sceenshot plugin
cbt1 4184e2d
use screenshot plugin in protractor
cbt1 bbbf0eb
fix plugin tests
cbt1 ce57687
support explicit type
cbt1 32addc6
remove plugin from protractor
cbt1 445fe15
preset screenshot plugin
cbt1 8de84a1
make package private
cbt1 f3778ea
do not require platform and browser name
cbt1 8c2c91e
use takeImageOf context when applicable
cbt1 195d056
Merge branch 'master' into feat/chai-screenshot-plugin
cbt1 431f3b9
Merge branch 'master' into feat/chai-screenshot-plugin
cbt1 6ec41e2
fix breaking parameter change
cbt1 4097949
only create required directories
cbt1 9d9ac4a
fix tests
cbt1 abe9885
Merge branch 'master' into feat/chai-screenshot-plugin
cbt1 3726933
add toImage tests
cbt1 097f910
add docs
cbt1 e8cf64a
add snapshot example
cbt1 2776e73
Update after review
cbt1 9cfbec1
fix example
cbt1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,21 @@ describe('button', () => { | |
| </p> | ||
| </details> | ||
|
|
||
| ## Screenshot testing | ||
|
|
||
| When using the preset-env option. A screenshot assertion plugin is added to Chai. This allows comperisons of images. | ||
|
|
||
| ```javascript | ||
| describe('screenshot', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixup the example |
||
| it('image should be equal', () => { | ||
| const img = Promise.resolve('<base64-encoded-image>'); // Promise that resolves to Buffer or a base64 encoded image | ||
| expect(img).to.equal('<name-of-my-img-on-disk>', { | ||
| artifactsPath: 'tests/__artifacts__', | ||
| tolerance: 0.002 | ||
| }); | ||
| }); | ||
| }); | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
|
|
@@ -57,6 +72,7 @@ describe('button', () => { | |
| <p> | ||
|
|
||
| ```javascript | ||
| const screenshotPlugin = require('@after-work.js/chai-plugin-screenshot'); | ||
| const sinon = require('sinon'); | ||
| const chai = require('chai'); | ||
| const sinonChai = require('sinon-chai'); | ||
|
|
@@ -70,6 +86,7 @@ global.expect = chai.expect; | |
| chai.use(sinonChai); | ||
| chai.use(chaiAsPromised); | ||
| chai.use(chaiSubset); | ||
| chai.Assertion.addMethod('matchImageOf', screenshotPlugin.matchImageOf); | ||
| ``` | ||
|
|
||
| This enables writing your tests like this: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo comperisons