Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ jobs:
run: |
npm run coverage:merge
npm run coverage:merge-report
- name: Send results to SonarCloud
uses: SonarSource/sonarcloud-github-action@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# - name: Send results to SonarCloud
# uses: SonarSource/sonarcloud-github-action@v1.6
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

test:
needs:
Expand Down
5 changes: 2 additions & 3 deletions index.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
straightTo,
} from "./index";

jest.setTimeout(60000);

const openXfceMenu = async () => {
await mouse.move(straightTo(centerOf(screen.find("menu.png"))));
await mouse.leftClick();
Expand Down Expand Up @@ -47,12 +49,10 @@ describe("E2E tests", () => {
});

it("should throw on invalid images", async () => {
jest.setTimeout(30000);
await expect(screen.find("mouse.png")).rejects.toContain("Failed to load image");
});

it("should perform some calculations", async () => {
jest.setTimeout(30000);
screen.config.resourceDirectory = "./e2e/assets";
await assert.isVisible("mouse.png");
await assert.isVisible("desktop.png");
Expand All @@ -67,7 +67,6 @@ describe("E2E tests", () => {
});

it("drag & drop", async () => {
jest.setTimeout(60000);
screen.config.resourceDirectory = "./e2e/assets";

const expected = new Region(38, 585, 70, 86);
Expand Down
2 changes: 1 addition & 1 deletion lib/keyboard.class.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { jestMatchers, Key, keyboard, screen } from "../index";

jest.setTimeout(30000);
expect.extend(jestMatchers);

const run = async (cmd: string) => {
Expand All @@ -19,7 +20,6 @@ const close = async () => {
describe("Keyboard e2e class", () => {
it("should open gnome calculator via keyboard.", async () => {
// GIVEN
jest.setTimeout(30000);
screen.config.resourceDirectory = "./e2e/assets";
screen.config.confidence = 0.97;
await run("gnome-calculator");
Expand Down
2 changes: 1 addition & 1 deletion lib/keyboard.class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Key } from "./key.enum";
import { Keyboard } from "./keyboard.class";

jest.mock("./adapter/native.adapter.class");
jest.setTimeout(10000);

beforeEach(() => {
jest.resetAllMocks();
Expand Down Expand Up @@ -38,7 +39,6 @@ describe("Keyboard", () => {

it("should pass multiple input strings down to the type call.", async () => {
// GIVEN
jest.setTimeout(10000);
const adapterMock = new NativeAdapter();
const SUT = new Keyboard(adapterMock);
const payload = ["Test input!", "Array test2"];
Expand Down
6 changes: 2 additions & 4 deletions lib/provider/native/clipboardy-clipboard-action.class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ beforeEach(() => {

describe("clipboardy action", () => {
describe("copy", () => {
it("should resolve", async done => {
it("should resolve", async () => {
// GIVEN
const SUT = new ClipboardAction();
const testText = "test";
Expand All @@ -15,11 +15,10 @@ describe("clipboardy action", () => {

// THEN
await SUT.copy(testText);
done();
});
});
describe("hasText", () => {
it("should return true when text has been copied", async done => {
it("should return true when text has been copied", async () => {
// GIVEN
const SUT = new ClipboardAction();
const testText = "test";
Expand All @@ -29,7 +28,6 @@ describe("clipboardy action", () => {

// THEN
await expect(SUT.hasText()).resolves.toBeTruthy();
done();
});
});
});
4 changes: 2 additions & 2 deletions lib/screen.class.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {Screen} from "./screen.class";
import {sleep} from "./sleep.function";
import AbortController from "node-abort-controller";

jest.setTimeout(10000);

describe("Screen.", () => {
it("should capture the screen", () => {
// GIVEN
Expand Down Expand Up @@ -91,7 +93,6 @@ describe("Screen.", () => {

it("should reject after timeout", async () => {
// GIVEN
jest.setTimeout(10000);
const timeout = 5000;
const visionAdapter = new VisionAdapter();
const SUT = new Screen(visionAdapter);
Expand All @@ -113,7 +114,6 @@ describe("Screen.", () => {

it("should abort via signal", (done) => {
// GIVEN
jest.setTimeout(10000);
const timeout = 5000;
const abortAfterMs = 1000;
const controller = new AbortController();
Expand Down
9 changes: 4 additions & 5 deletions lib/util/timeout.function.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {timeout} from "./timeout.function";
import AbortController from "node-abort-controller";
import {sleep} from "../sleep.function";

describe("timeout", () => {
it("should timeout after maxDuration if action rejects", async () => {
Expand Down Expand Up @@ -138,7 +139,7 @@ describe("timeout", () => {
expect(action).toBeCalledTimes(1);
});

it("should fail after timeout if no result is returned from long running action", async (done) => {
it("should fail after timeout if no result is returned from long running action", async () => {
// GIVEN
const updateInterval = 100;
const maxDuration = 200;
Expand All @@ -156,10 +157,8 @@ describe("timeout", () => {
// THEN
await expect(SUT).rejects.toBe(`Action timed out after ${maxDuration} ms`);
expect(action).toBeCalledTimes(1);
setTimeout(() => {
expect(action).toBeCalledTimes(1);
done();
}, 500);
await sleep(500);
expect(action).toBeCalledTimes(1);
});

it("should be externally abortable", async () => {
Expand Down
Loading