Skip to content

Commit 0a2650e

Browse files
committed
Add TypeScript types for Feature.only method
1 parent acb2e13 commit 0a2650e

File tree

2 files changed

+90
-61
lines changed

2 files changed

+90
-61
lines changed

typings/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ declare namespace CodeceptJS {
440440
interface IHook {}
441441
interface IScenario {}
442442
interface IFeature {
443-
(title: string): FeatureConfig
443+
(title: string, opts?: { [key: string]: any }): FeatureConfig
444444
}
445445
interface CallbackOrder extends Array<any> {}
446446
interface SupportObject {
@@ -486,6 +486,7 @@ declare namespace CodeceptJS {
486486
todo: IScenario
487487
}
488488
interface Feature extends IFeature {
489+
only: IFeature
489490
skip: IFeature
490491
}
491492
interface IData {
@@ -545,7 +546,7 @@ declare const Given: typeof CodeceptJS.addStep
545546
declare const When: typeof CodeceptJS.addStep
546547
declare const Then: typeof CodeceptJS.addStep
547548

548-
declare const Feature: typeof CodeceptJS.Feature
549+
declare const Feature: CodeceptJS.Feature
549550
declare const Scenario: CodeceptJS.Scenario
550551
declare const xScenario: CodeceptJS.IScenario
551552
declare const xFeature: CodeceptJS.IFeature
Lines changed: 87 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,123 @@
1-
import { expectError, expectType } from 'tsd';
1+
import { expectError, expectType } from 'tsd'
22

3-
4-
expectError(Feature());
5-
expectError(Scenario());
6-
expectError(Before());
7-
expectError(BeforeSuite());
8-
expectError(After());
9-
expectError(AfterSuite());
3+
expectError(Feature())
4+
expectError(Scenario())
5+
expectError(Before())
6+
expectError(BeforeSuite())
7+
expectError(After())
8+
expectError(AfterSuite())
109

1110
// @ts-ignore
1211
expectType<CodeceptJS.FeatureConfig>(Feature('feature'))
1312

13+
// @ts-ignore
14+
expectType<CodeceptJS.FeatureConfig>(Feature.only('feature'))
15+
16+
// @ts-ignore
17+
expectType<CodeceptJS.FeatureConfig>(Feature.only('feature', {}))
18+
19+
// @ts-ignore
20+
expectType<CodeceptJS.FeatureConfig>(Feature.skip('feature'))
21+
1422
// @ts-ignore
1523
expectType<CodeceptJS.ScenarioConfig>(Scenario('scenario'))
1624

1725
// @ts-ignore
18-
expectType<CodeceptJS.ScenarioConfig>(Scenario(
19-
'scenario',
20-
{}, // $ExpectType {}
21-
() => {} // $ExpectType () => void
22-
))
26+
expectType<CodeceptJS.ScenarioConfig>(
27+
Scenario(
28+
'scenario',
29+
{}, // $ExpectType {}
30+
() => {}, // $ExpectType () => void
31+
),
32+
)
2333

2434
// @ts-ignore
25-
expectType<CodeceptJS.ScenarioConfig>(Scenario(
26-
'scenario',
27-
() => {} // $ExpectType () => void
28-
))
35+
expectType<CodeceptJS.ScenarioConfig>(
36+
Scenario(
37+
'scenario',
38+
() => {}, // $ExpectType () => void
39+
),
40+
)
2941

3042
// @ts-ignore
3143
const callback: CodeceptJS.HookCallback = () => {}
3244

3345
// @ts-ignore
34-
expectType<CodeceptJS.ScenarioConfig>(Scenario(
35-
'scenario',
36-
callback // $ExpectType HookCallback
37-
))
46+
expectType<CodeceptJS.ScenarioConfig>(
47+
Scenario(
48+
'scenario',
49+
callback, // $ExpectType HookCallback
50+
),
51+
)
3852

3953
// @ts-ignore
40-
expectType<CodeceptJS.ScenarioConfig>(Scenario('scenario',
41-
(args) => {
54+
expectType<CodeceptJS.ScenarioConfig>(
55+
Scenario('scenario', args => {
4256
// @ts-ignore
4357
expectType<CodeceptJS.SupportObject>(args)
4458
// @ts-ignore
4559
expectType<CodeceptJS.I>(args.I) // $ExpectType I
46-
}
47-
))
60+
}),
61+
)
4862

4963
// @ts-ignore
50-
expectType<CodeceptJS.ScenarioConfig>(Scenario(
51-
'scenario',
52-
async () => {} // $ExpectType () => Promise<void>
53-
))
64+
expectType<CodeceptJS.ScenarioConfig>(
65+
Scenario(
66+
'scenario',
67+
async () => {}, // $ExpectType () => Promise<void>
68+
),
69+
)
5470

5571
// @ts-ignore
56-
expectType<void>(Before((args) => {
57-
// @ts-ignore
58-
expectType<CodeceptJS.SupportObject>(args)
59-
// @ts-ignore
60-
expectType<CodeceptJS.I>(args.I)
61-
}))
72+
expectType<void>(
73+
Before(args => {
74+
// @ts-ignore
75+
expectType<CodeceptJS.SupportObject>(args)
76+
// @ts-ignore
77+
expectType<CodeceptJS.I>(args.I)
78+
}),
79+
)
6280

6381
// @ts-ignore
64-
expectType<void>(BeforeSuite((args) => {
65-
// @ts-ignore
66-
expectType<CodeceptJS.SupportObject>(args)
67-
// @ts-ignore
68-
expectType<CodeceptJS.I>(args.I)
69-
}))
82+
expectType<void>(
83+
BeforeSuite(args => {
84+
// @ts-ignore
85+
expectType<CodeceptJS.SupportObject>(args)
86+
// @ts-ignore
87+
expectType<CodeceptJS.I>(args.I)
88+
}),
89+
)
7090

7191
// @ts-ignore
72-
expectType<void>(After((args) => {
73-
// @ts-ignore
74-
expectType<CodeceptJS.SupportObject>(args)
75-
// @ts-ignore
76-
expectType<CodeceptJS.I>(args.I)
77-
}))
92+
expectType<void>(
93+
After(args => {
94+
// @ts-ignore
95+
expectType<CodeceptJS.SupportObject>(args)
96+
// @ts-ignore
97+
expectType<CodeceptJS.I>(args.I)
98+
}),
99+
)
78100

79101
// @ts-ignore
80-
expectType<void>(AfterSuite((args) => {
81-
// @ts-ignore
82-
expectType<CodeceptJS.SupportObject>(args)
83-
// @ts-ignore
84-
expectType<CodeceptJS.I>(args.I)
85-
}))
102+
expectType<void>(
103+
AfterSuite(args => {
104+
// @ts-ignore
105+
expectType<CodeceptJS.SupportObject>(args)
106+
// @ts-ignore
107+
expectType<CodeceptJS.I>(args.I)
108+
}),
109+
)
86110

87111
// @ts-ignore
88-
expectType<Promise<boolean>>(tryTo(() => {
89-
return true;
90-
}));
112+
expectType<Promise<boolean>>(
113+
tryTo(() => {
114+
return true
115+
}),
116+
)
91117

92118
// @ts-ignore
93-
expectType<Promise<boolean>>(tryTo(async () => {
94-
return false;
95-
}));
119+
expectType<Promise<boolean>>(
120+
tryTo(async () => {
121+
return false
122+
}),
123+
)

0 commit comments

Comments
 (0)