Skip to content

Commit b081928

Browse files
authored
Merge pull request octalmage#568 from rayfoss/harden-screen-test
Harden screen test
2 parents eee4ec5 + 0083d6a commit b081928

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"typings": "index.d.ts",
77
"scripts": {
88
"test": "run-script-os",
9-
"test:darwin:linux": "jasmine 'test/**/*.js'",
9+
"test:darwin:linux": "jasmine test/**/*.js",
1010
"test-keyboard": "node test/keyboard.js",
1111
"test:win32": "jasmine test/**/*.js",
1212
"install": "prebuild-install || node-gyp rebuild",

test/integration/screen.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@ describe('Integration/Screen', () => {
1717
target = null;
1818
});
1919

20-
it('reads a pixel color', () => {
21-
var color_1 = elements.color_1;
22-
const color = robot.getPixelColor(color_1.x, color_1.y);
23-
expect(color).toEqual('c0ff33');
20+
it('reads a pixel color', (done) => {
21+
const maxDelay = 1000
22+
jasmine.DEFAULT_TIMEOUT_INTERVAL = maxDelay + 1000
23+
const expected = 'c0ff33'
24+
const color_1 = elements.color_1;
25+
const sleepTime = robot.getPixelColor(color_1.x, color_1.y) === expected ? 0
26+
: maxDelay
27+
28+
setTimeout(() => {
29+
const color = robot.getPixelColor(color_1.x, color_1.y);
30+
expect(color).toEqual(expected);
31+
done()
32+
}, sleepTime)
2433
});
2534
});

0 commit comments

Comments
 (0)