@applitools/screenshoter 3.3.2 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/package.json +26 -15
- package/src/image.js +15 -12
- package/src/scroll-into-viewport.js +16 -7
- package/src/take-viewport-screenshot.js +8 -30
- package/.bongo/dry-run/package-lock.json +0 -73
- package/.bongo/dry-run/package.json +0 -5
- package/.bongo/dry-run.tgz +0 -0
- package/.eslintrc +0 -39
- package/test/e2e/android.spec.js +0 -335
- package/test/e2e/external.spec.js +0 -155
- package/test/e2e/ios.spec.js +0 -338
- package/test/e2e/web-ios.spec.js +0 -72
- package/test/e2e/web.spec.js +0 -334
- package/test/fixtures/android/app-fully-non-scrollable.png +0 -0
- package/test/fixtures/android/app-fully-recycler.png +0 -0
- package/test/fixtures/android/app-fully-scroll-statusbar.png +0 -0
- package/test/fixtures/android/app-fully-scroll.png +0 -0
- package/test/fixtures/android/app-statusbar.png +0 -0
- package/test/fixtures/android/app.png +0 -0
- package/test/fixtures/android/element.png +0 -0
- package/test/fixtures/android/region.png +0 -0
- package/test/fixtures/android/x-app-fully-collapsing.png +0 -0
- package/test/fixtures/android/x-app-fully-recycler.png +0 -0
- package/test/fixtures/android/x-element-fully.png +0 -0
- package/test/fixtures/external/agl.png +0 -0
- package/test/fixtures/image/house.cropped-rect.png +0 -0
- package/test/fixtures/image/house.cropped-region.png +0 -0
- package/test/fixtures/image/house.framed-higher-wider.png +0 -0
- package/test/fixtures/image/house.framed-higher.png +0 -0
- package/test/fixtures/image/house.framed-shorter-thinner.png +0 -0
- package/test/fixtures/image/house.framed-wider.png +0 -0
- package/test/fixtures/image/house.png +0 -0
- package/test/fixtures/image/house.rotated.png +0 -0
- package/test/fixtures/image/house.scaled.png +0 -0
- package/test/fixtures/image/house.stitched.png +0 -0
- package/test/fixtures/ios/app-fully-collapsing.png +0 -0
- package/test/fixtures/ios/app-fully-collection.png +0 -0
- package/test/fixtures/ios/app-fully-overlapped-statusbar.png +0 -0
- package/test/fixtures/ios/app-fully-overlapped.png +0 -0
- package/test/fixtures/ios/app-fully-scroll-statusbar.png +0 -0
- package/test/fixtures/ios/app-fully-scroll.png +0 -0
- package/test/fixtures/ios/app-fully-superview.png +0 -0
- package/test/fixtures/ios/app-fully-table.png +0 -0
- package/test/fixtures/ios/app-statusbar.png +0 -0
- package/test/fixtures/ios/app.png +0 -0
- package/test/fixtures/ios/element-fully.png +0 -0
- package/test/fixtures/ios/element.png +0 -0
- package/test/fixtures/ios/region.png +0 -0
- package/test/fixtures/ios/webview-fully.png +0 -0
- package/test/fixtures/ios/webview.png +0 -0
- package/test/fixtures/pattern/iPad_5th_landscape.png +0 -0
- package/test/fixtures/pattern/iPad_5th_portrait.png +0 -0
- package/test/fixtures/pattern/iPad_9th_landscape.png +0 -0
- package/test/fixtures/pattern/iPad_9th_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_11_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_11_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_13_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_13_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_SE_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_SE_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait_nomarker.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait_noviewport.png +0 -0
- package/test/fixtures/web/element-fully.png +0 -0
- package/test/fixtures/web/element.png +0 -0
- package/test/fixtures/web/frame-fully.png +0 -0
- package/test/fixtures/web/frame.png +0 -0
- package/test/fixtures/web/inner-element-fully.png +0 -0
- package/test/fixtures/web/inner-element.png +0 -0
- package/test/fixtures/web/inner-frame-fully.png +0 -0
- package/test/fixtures/web/inner-frame.png +0 -0
- package/test/fixtures/web/inner-region-fully.png +0 -0
- package/test/fixtures/web/inner-region.png +0 -0
- package/test/fixtures/web/page-fully.png +0 -0
- package/test/fixtures/web/page.png +0 -0
- package/test/fixtures/web/region-fully.png +0 -0
- package/test/fixtures/web/region.png +0 -0
- package/test/fixtures/web-ios/page-fully.png +0 -0
- package/test/fixtures/web-ios/page.png +0 -0
- package/test/it/find-pattern.spec.js +0 -33
- package/test/it/image.spec.js +0 -146
package/test/it/image.spec.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const pixelmatch = require('pixelmatch')
|
|
4
|
-
const makeImage = require('../../src/image')
|
|
5
|
-
|
|
6
|
-
describe('image', () => {
|
|
7
|
-
it('should provide access to image width/height before it parsed', async () => {
|
|
8
|
-
const buffer = fs.readFileSync('./test/fixtures/image/house.png')
|
|
9
|
-
const image = makeImage(buffer)
|
|
10
|
-
assert.strictEqual(image.width, 612)
|
|
11
|
-
assert.strictEqual(image.height, 512)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('should crop by region', async () => {
|
|
15
|
-
const actual = await makeImage('./test/fixtures/image/house.png')
|
|
16
|
-
.crop({x: 200, y: 220, width: 200, height: 200})
|
|
17
|
-
.toObject()
|
|
18
|
-
const expected = await makeImage('./test/fixtures/image/house.cropped-region.png').toObject()
|
|
19
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('should crop by rect', async () => {
|
|
23
|
-
const actual = await makeImage('./test/fixtures/image/house.png')
|
|
24
|
-
.crop({left: 100, right: 110, top: 120, bottom: 130})
|
|
25
|
-
.toObject()
|
|
26
|
-
const expected = await makeImage('./test/fixtures/image/house.cropped-rect.png').toObject()
|
|
27
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('should crop a big image without heap overflow', async () => {
|
|
31
|
-
const actual = await makeImage({width: 1000, height: 50000})
|
|
32
|
-
.crop({x: 0, y: 0, width: 1000, height: 49500})
|
|
33
|
-
.toObject()
|
|
34
|
-
assert.strictEqual(actual.width, 1000)
|
|
35
|
-
assert.strictEqual(actual.height, 49500)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('should scale', async () => {
|
|
39
|
-
const actual = await makeImage('./test/fixtures/image/house.png')
|
|
40
|
-
.scale(0.5)
|
|
41
|
-
.toObject()
|
|
42
|
-
const expected = await makeImage('./test/fixtures/image/house.scaled.png').toObject()
|
|
43
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('should rotate', async () => {
|
|
47
|
-
const actual = await makeImage('./test/fixtures/image/house.png')
|
|
48
|
-
.rotate(90)
|
|
49
|
-
.toObject()
|
|
50
|
-
const expected = await makeImage('./test/fixtures/image/house.rotated.png').toObject()
|
|
51
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('should rotate a big image without heap overflow', async () => {
|
|
55
|
-
const actual = await makeImage({width: 1000, height: 50000})
|
|
56
|
-
.rotate(270)
|
|
57
|
-
.toObject()
|
|
58
|
-
assert.strictEqual(actual.width, 50000)
|
|
59
|
-
assert.strictEqual(actual.height, 1000)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('should copy one image to another', async () => {
|
|
63
|
-
const image = makeImage('./test/fixtures/image/house.png')
|
|
64
|
-
const composedImage = makeImage({width: image.width, height: image.height * 2})
|
|
65
|
-
await composedImage.copy(image, {x: 0.1, y: 0.2})
|
|
66
|
-
await composedImage.copy(image, {x: 0, y: image.height})
|
|
67
|
-
const actual = await composedImage.toObject()
|
|
68
|
-
const expected = await makeImage('./test/fixtures/image/house.stitched.png').toObject()
|
|
69
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('should copy a big image without heap overflow', async () => {
|
|
73
|
-
const source = makeImage({width: 1000, height: 50000})
|
|
74
|
-
const composedImage = makeImage({width: 1000, height: 50000})
|
|
75
|
-
await composedImage.copy(source, {x: 100, y: 500})
|
|
76
|
-
const actual = await composedImage.toObject()
|
|
77
|
-
assert.strictEqual(actual.width, 1000)
|
|
78
|
-
assert.strictEqual(actual.height, 50000)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('should frame image in a higher and wider region', async () => {
|
|
82
|
-
const image = makeImage('./test/fixtures/image/house.png')
|
|
83
|
-
const srcImage = makeImage({
|
|
84
|
-
width: 200,
|
|
85
|
-
height: 200,
|
|
86
|
-
data: Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0, 0xff])),
|
|
87
|
-
})
|
|
88
|
-
const combinedImage = await srcImage.frame(image, image, {x: 200, y: 200, width: 100, height: 100})
|
|
89
|
-
const actual = await combinedImage.toObject()
|
|
90
|
-
const expected = await makeImage('./test/fixtures/image/house.framed-higher-wider.png').toObject()
|
|
91
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it('should frame image in a higher region', async () => {
|
|
95
|
-
const image = await makeImage('./test/fixtures/image/house.png')
|
|
96
|
-
const srcImage = makeImage({
|
|
97
|
-
width: 200,
|
|
98
|
-
height: 200,
|
|
99
|
-
data: Buffer.alloc(200 * 200 * 4, Buffer.from([0, 0xff, 0, 0xff])),
|
|
100
|
-
})
|
|
101
|
-
const combinedImage = await srcImage.frame(image, image, {x: 200, y: 200, width: 200, height: 100})
|
|
102
|
-
const actual = await combinedImage.toObject()
|
|
103
|
-
const expected = await makeImage('./test/fixtures/image/house.framed-higher.png').toObject()
|
|
104
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it('should frame image in a wider region', async () => {
|
|
108
|
-
const image = await makeImage('./test/fixtures/image/house.png')
|
|
109
|
-
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0, 0, 0xff, 0xff]))
|
|
110
|
-
const actual = await makeImage({width: 200, height: 200, data})
|
|
111
|
-
.frame(image, image, {x: 200, y: 200, width: 100, height: 200})
|
|
112
|
-
.toObject()
|
|
113
|
-
const expected = await makeImage('./test/fixtures/image/house.framed-wider.png').toObject()
|
|
114
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
it('should frame image in a shorter and thinner region', async () => {
|
|
118
|
-
const image = await makeImage('./test/fixtures/image/house.png')
|
|
119
|
-
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0xff, 0xff]))
|
|
120
|
-
const actual = await makeImage({width: 200, height: 200, data})
|
|
121
|
-
.frame(image, image, {x: 100, y: 100, width: 250, height: 250})
|
|
122
|
-
.toObject()
|
|
123
|
-
const expected = await makeImage('./test/fixtures/image/house.framed-shorter-thinner.png').toObject()
|
|
124
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it('should frame image in a shorter region', async () => {
|
|
128
|
-
const image = await makeImage('./test/fixtures/image/house.png')
|
|
129
|
-
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0xff, 0xff]))
|
|
130
|
-
const actual = await makeImage({width: 200, height: 200, data})
|
|
131
|
-
.frame(image, image, {x: 100, y: 100, width: 200, height: 250})
|
|
132
|
-
.toObject()
|
|
133
|
-
const expected = await makeImage('./test/fixtures/image/house.framed-shorter-thinner.png').toObject()
|
|
134
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it('should frame image in a thinner region', async () => {
|
|
138
|
-
const image = await makeImage('./test/fixtures/image/house.png')
|
|
139
|
-
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0xff, 0xff]))
|
|
140
|
-
const actual = await makeImage({width: 200, height: 200, data})
|
|
141
|
-
.frame(image, image, {x: 100, y: 100, width: 250, height: 200})
|
|
142
|
-
.toObject()
|
|
143
|
-
const expected = await makeImage('./test/fixtures/image/house.framed-shorter-thinner.png').toObject()
|
|
144
|
-
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
145
|
-
})
|
|
146
|
-
})
|