Skip to content

Commit c5c5d02

Browse files
authored
Fixing issue with freeze image (#94)
Fixing issue with freeze image
1 parent 0125e27 commit c5c5d02

File tree

9 files changed

+45
-14
lines changed

9 files changed

+45
-14
lines changed

API.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,25 @@ In this example, differencify will got to different pages and compare screenshot
441441
In this example, you can specify the custom path for storing images.
442442
443443
444+
## Freezing an image
445+
446+
```js
447+
(async () => {
448+
await differencify
449+
.init()
450+
.newPage()
451+
.setViewport({ width: 1600, height: 1200 })
452+
.goto('https://i.giphy.com/media/xTiTnoUnHxVaaVNWhO/giphy.webp')
453+
.waitFor('body > img')
454+
.freezeImage('body > img')
455+
.screenshot()
456+
.toMatchSnapshot()
457+
.close()
458+
.end();
459+
})();
460+
```
461+
In this example, you can freeze an image by specifying the selector path.
462+
463+
444464
445465

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.4.2] - 2018-7-13
2+
### Fixed
3+
- Fixing issue with freezeImage command
4+
15
## [1.4.1] - 2018-6-22
26
### Added
37
- A prepare script to keep the artifact uptodated

CONTRIBUTING.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,9 @@ Differencify operates under a forking model. In order to contribute, please fork
1212

1313
### steps
1414
- Open terminal
15-
- cd to project root and build image
16-
```
17-
docker build -t differencify .
18-
```
19-
- And then run
20-
```
21-
docker run -t -d --name differencify differencify
22-
```
2315
- To run integration tests run
2416
```
25-
docker exec -it differencify npm run test:integration
17+
npm run test:integration
2618
```
2719
- Then copy over generated snapshots
2820
```

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "differencify",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "Perceptual diffing tool",
55
"main": "dist/index.js",
66
"scripts": {

src/helpers/functionToString.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const functionToString = (func, ...args) => {
1313
}
1414
});
1515
const functionSource = func.toString();
16-
return `return (${functionSource})(${funcArguments.join()})`;
16+
return `(${functionSource})(${funcArguments.join()})`;
1717
};
1818

1919
export default functionToString;

src/helpers/functionToString.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ const foo = function foo(a, b, c) { return a + b + c; };
55
describe('functionToString', () => {
66
it('Convert function to string with right arguments', () => {
77
const strFunc = functionToString(foo, 1, 2, '3');
8-
expect(strFunc).toEqual('return (function foo(a, b, c) {return a + b + c;})(1,2,"3")');
8+
expect(strFunc).toEqual('(function foo(a, b, c) {return a + b + c;})(1,2,"3")');
9+
expect(eval(strFunc)).toEqual('33'); // eslint-disable-line no-eval
910
});
1011
it('Convert function to string with no arguments', () => {
1112
const strFunc = functionToString(foo);
12-
expect(strFunc).toEqual('return (function foo(a, b, c) {return a + b + c;})()');
13+
expect(strFunc).toEqual('(function foo(a, b, c) {return a + b + c;})()');
14+
expect(eval(strFunc)).toEqual(NaN); // eslint-disable-line no-eval
1315
});
1416
it('Return null if non function passed', () => {
1517
const strFunc = functionToString('function');
61.3 KB
Loading

src/integration.tests/integration.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,17 @@ describe('Differencify', () => {
268268
await customDifferencify.cleanup();
269269
expect(result).toEqual(true);
270270
}, 30000);
271+
it('Freeze image in page', async () => {
272+
await differencify
273+
.init()
274+
.newPage()
275+
.setViewport({ width: 1600, height: 1200 })
276+
.goto('https://i.giphy.com/media/xTiTnoUnHxVaaVNWhO/giphy.webp')
277+
.waitFor('body > img')
278+
.freezeImage('body > img')
279+
.screenshot()
280+
.toMatchSnapshot()
281+
.close()
282+
.end();
283+
}, 30000);
271284
});

0 commit comments

Comments
 (0)