Skip to content

Commit 74026f5

Browse files
committed
imroved TS definitions
1 parent 5584e11 commit 74026f5

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

Diff for: lib/command/definitions.js

+43-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ const path = require('path');
1111
const template = `
1212
type ICodeceptCallback = (i: CodeceptJS.{{I}}) => void;
1313
14+
declare class FeatureConfig {
15+
retry(integer): FeatureConfig
16+
timeout(integer): FeatureConfig
17+
config(object): FeatureConfig
18+
config(string, object): FeatureConfig
19+
}
20+
21+
declare class ScenarioConfig {
22+
throws(any) : ScenarioConfig;
23+
fails() : ScenarioConfig;
24+
retry(integer): ScenarioConfig
25+
timeout(integer): ScenarioConfig
26+
inject(object): ScenarioConfig
27+
config(object): ScenarioConfig
28+
config(string, object): ScenarioConfig
29+
}
30+
1431
interface ILocator {
1532
xpath?: string;
1633
css?: string;
@@ -21,14 +38,37 @@ interface ILocator {
2138
ios?: string;
2239
}
2340
41+
declare class Locator implements ILocator {
42+
or(locator): Locator;
43+
find(locator): Locator;
44+
withChild(locator): Locator;
45+
find(locator): Locator;
46+
at(position): Locator;
47+
first(): Locator;
48+
last(): Locator;
49+
inside(locator): Locator;
50+
before(locator): Locator;
51+
after(locator): Locator;
52+
withText(text): Locator;
53+
withAttr(attr): Locator;
54+
as(output): Locator;
55+
}
56+
2457
declare const actor: () => CodeceptJS.{{I}};
25-
declare const Feature: (string: string) => void;
26-
declare const Scenario: (string: string, callback: ICodeceptCallback) => void;
58+
declare const Feature: (string: string) => FeatureConfig;
59+
declare const Scenario: (string: string, callback: ICodeceptCallback) => ScenarioConfig;
2760
declare const Before: (callback: ICodeceptCallback) => void;
2861
declare const BeforeSuite: (callback: ICodeceptCallback) => void;
2962
declare const After: (callback: ICodeceptCallback) => void;
3063
declare const AfterSuite: (callback: ICodeceptCallback) => void;
31-
declare const within: (selector: string, callback: Function) => void;
64+
declare const locate: (selector: string) => Locator;
65+
declare const locate: (selector: ILocator) => Locator;
66+
declare const within: (selector: string, callback: Function) => Promise;
67+
declare const within: (selector: ILocator, callback: Function) => Promise;
68+
declare const session: (selector: string, callback: Function) => Promise;
69+
declare const session: (selector: ILocator, callback: Function) => Promise;
70+
declare const session: (selector: string, config: any, callback: Function) => Promise;
71+
declare const session: (selector: ILocator, config: any, callback: Function) => Promise;
3272
3373
declare namespace CodeceptJS {
3474
export interface {{I}} {

Diff for: typings/index.d.ts

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
// Project: https://github.com/codeception/codeceptjs/
33
// Definitions by: Michael Bodnarchuk <http://github.com/DavertMik>, Drew Diamantoukos <https://github.com/KennyRules>
44

5+
declare class Locator {
6+
or(locator): Locator;
7+
find(locator): Locator;
8+
withChild(locator): Locator;
9+
find(locator): Locator;
10+
at(position): Locator;
11+
first(): Locator;
12+
last(): Locator;
13+
inside(locator): Locator;
14+
before(locator): Locator;
15+
after(locator): Locator;
16+
withText(text): Locator;
17+
withAttr(attr): Locator;
18+
as(output): Locator;
19+
}
20+
521
declare module NodeJS {
622
interface Process {
723
profile: string;
@@ -17,7 +33,9 @@ declare module NodeJS {
1733
Helper: any;
1834
pause: any;
1935
within: any;
36+
session: any;
2037
DataTable: any;
38+
locate: Locator,
2139
by: any;
2240

2341
// Used by Protractor helper
@@ -36,6 +54,7 @@ declare interface Window {
3654

3755
declare var window: Window;
3856

57+
3958
/**
4059
* Special Mocha definitions for reporter Base and Suite.
4160
* The mocha type definitions on DefinitelyTyped are for an older version of Mocha!

0 commit comments

Comments
 (0)