Skip to content

Commit 958ce75

Browse files
authored
Merge pull request #114 from nut-tree/feature/109/test_stability
Feature/109/test stability
2 parents 5bef854 + fe278ae commit 958ce75

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# nut.js (Native UI Toolkit) [![Build Status](https://travis-ci.com/nut-tree/nut.js.svg?branch=master)](https://travis-ci.com/nut-tree/nut.js) [![SonarCloud badge](https://sonarcloud.io/api/project_badges/measure?project=nut-tree%3Anut.js&metric=alert_status)](https://sonarcloud.io/dashboard?id=nut-tree%3Anut.js) [![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=nut-tree%3Anut.js&metric=coverage)](https://sonarcloud.io/component_measures?id=nut-tree%3Anut.js&metric=coverage)
1+
# nut.js (Native UI Toolkit) [![Build Status](https://travis-ci.com/nut-tree/nut.js.svg?branch=master)](https://travis-ci.com/nut-tree/nut.js) [![SonarCloud badge](https://sonarcloud.io/api/project_badges/measure?project=nut-tree%3Anut.js&metric=alert_status)](https://sonarcloud.io/dashboard?id=nut-tree%3Anut.js) [![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=nut-tree%3Anut.js&metric=coverage)](https://sonarcloud.io/component_measures?id=nut-tree%3Anut.js&metric=coverage) [![Downloads per month](https://img.shields.io/npm/dm/@nut-tree/nut-js)](https://www.npmjs.com/package/@nut-tree/nut-js)
22
<p align="center">
33
Native UI testing / automation with node.js
44
</p>
55
<br/>
66
<p align="center">
77
<a target="_blank" href="https://github.com/justadudewhohacks/opencv4nodejs">
8-
<img src="https://img.shields.io/badge/Built_with-opencv4nodejs-C86414.svg?style=flat-square" alt="Built with opencv4nodejs" />
8+
<img src="https://img.shields.io/badge/Built_with-opencv4nodejs-C86414.svg?style=flat-square" alt="Built with opencv4nodejs" /></a>
99
</p>
1010

1111
# About
@@ -14,7 +14,7 @@ Native UI testing / automation with node.js
1414
<img src="https://github.com/nut-tree/nut.js/raw/master/.gfx/nut.png" alt="logo" width="200"/>
1515
</p>
1616

17-
`nut.js` is a cross-platform native UI testing tool.
17+
`nut.js` is a cross-platform native UI automation / testing tool.
1818

1919
It allows for native UI interactions via keyboard and / or mouse,
2020
but additionally gives you the possibility to navigate the screen based on image matching.
@@ -26,7 +26,7 @@ The following snippet shows a valid NUT example (on macOS)
2626
```js
2727
"use strict";
2828

29-
const { keyboard, Key, mouse, left, right, up, down } = require("@nut-tree/nut-js");
29+
const { keyboard, Key, mouse, left, right, up, down, screen } = require("@nut-tree/nut-js");
3030

3131
const square = async () => {
3232
await mouse.move(right(500));

lib/sleep.function.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {busyWaitForNanoSeconds, sleep} from "./sleep.function";
22

3+
const maxTimeDeltaInMs = 3;
4+
35
describe("sleep", () => {
46
it("should resolve after x ms", async () => {
57
// GIVEN
@@ -11,7 +13,7 @@ describe("sleep", () => {
1113
const after = Date.now();
1214

1315
// THEN
14-
expect(after - before).toBeGreaterThanOrEqual(timeout);
16+
expect(after - before).toBeGreaterThanOrEqual(timeout - maxTimeDeltaInMs);
1517
});
1618
});
1719

@@ -27,6 +29,6 @@ describe("busyWaitForNanoSeconds", () => {
2729
const after = Date.now();
2830

2931
// THEN
30-
expect(after - before).toBeGreaterThanOrEqual(timeoutMs);
32+
expect(after - before).toBeGreaterThanOrEqual(timeoutMs - maxTimeDeltaInMs);
3133
});
3234
});

lib/util/poll-action.function.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe("poll-action", () => {
2020

2121
// THEN
2222
expect((end - start)).toBeGreaterThanOrEqual(maxDuration);
23-
expect(action).toBeCalledTimes((maxDuration / updateInterval));
2423
});
2524

2625
it("should timeout after maxDuration if action resolve != true", async () => {
@@ -42,7 +41,6 @@ describe("poll-action", () => {
4241

4342
// THEN
4443
expect((end - start)).toBeGreaterThanOrEqual(maxDuration);
45-
expect(action).toBeCalledTimes((maxDuration / updateInterval));
4644
});
4745

4846
it("should resolve after updateInterval if action resolves", async () => {
@@ -93,12 +91,12 @@ describe("poll-action", () => {
9391
});
9492

9593
// WHEN
96-
await timeout(updateInterval, maxDuration, action);
94+
const result = await timeout(updateInterval, maxDuration, action);
9795
const end = Date.now();
9896

9997
// THEN
10098
expect((end - start)).toBeGreaterThanOrEqual(delay);
101-
expect(action).toBeCalledTimes(4);
99+
expect(result).toBeTruthy();
102100
});
103101

104102
it("should fail after timeout if timeout < retry interval", async () => {

0 commit comments

Comments
 (0)