Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "assertView", "moveCursorTo" and "currentTest" types #933

Merged
merged 2 commits into from
May 29, 2024

Conversation

DudaGod
Copy link
Member

@DudaGod DudaGod commented May 20, 2024

No description provided.

@@ -3,9 +3,48 @@
/// <reference types="mocha" />
/// <reference types="webdriverio" />

interface Test extends Pick<Mocha.Test, "fn", "parent"> {
Copy link
Member Author

@DudaGod DudaGod May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary fast solution in order to not rewrite on TS files from src/test-reader/test-object

UPD: as a result, I rewrote the necessary files to typescript

export type AssertViewElementCommand = (
this: WebdriverIO.Element,
this: WebdriverIO.Element | ChainablePromiseElement<WebdriverIO.Element>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to be able write code like - await browser.$("foo").assertView("plain"). Without this I should write it like this - await (await browser.$("foo")).assertView("plain");

@DudaGod DudaGod changed the title fix: "assertView" and "currentTest" types fix: "assertView", "moveCursorTo" and "currentTest" types May 28, 2024
@@ -18,7 +18,7 @@ type GroupName = Exclude<keyof StatsResult, "total" | "perBrowser">;
type StatEvent = {
group: GroupName;
id: string;
browserId: string;
browserId?: string;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to source code browserId can be undefined (default value) so I fix it here.
But actually I don't remember the case where it can be undefined, but I don't want crash something, so just add necessary types.

only: (title: string, fn: (this: Mocha.Suite) => void) => Mocha.Suite;
skip: (title: string, fn: (this: Mocha.Suite) => void) => Mocha.Suite;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these types to test-reader/test-object/types

@@ -1,3 +1,7 @@
type TestDefinition = import("../src/test-reader/test-object/types").TestDefinition;
type SuiteDefinition = import("../src/test-reader/test-object/types").SuiteDefinition;
type TestHookDefinition = import("../src/test-reader/test-object/types").TestHookDefinition;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only with the help of this syntax that it is possible to import types correctly

@@ -18,7 +18,7 @@ describe("test-reader/controllers/only-controller", () => {
};

const mkTestObject_ = ({ browserId } = {}) => {
const testObject = ConfigurableTestObject.create({});
const testObject = new ConfigurableTestObject({});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove static create method from ConfigurableTestObject and implement it on each runnable (suite, test, hook)

@DudaGod DudaGod merged commit f6458c5 into master May 29, 2024
2 checks passed
@DudaGod DudaGod deleted the INFRADUTY-26931.fix_ts branch May 29, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants