@cepharum/contextual-gherkin 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,17 +1,29 @@
1
1
  declare module "@cepharum/contextual-gherkin" {
2
- import {Browser, BrowserContextOptions, Expect, Mouse} from "@playwright/test";
2
+ import {Browser, BrowserContextOptions, Expect, LaunchOptions, Locator, Mouse} from "@playwright/test";
3
+
4
+ type PlaywrightActualBrowserName = "chromium" | "firefox" | "webkit";
5
+
6
+ type PlaywrightSupportedBrowserName = PlaywrightActualBrowserName | "chrome" | "safari" | "edge";
3
7
 
4
8
  /**
5
9
  * Exposes helper functions for conveniently integrating contextual-gherkin
6
10
  * with different frameworks for running tests.
7
11
  */
8
- const use = {
12
+ namespace use {
9
13
  /**
10
14
  * Generates adapter for running tests based on contextual-gherkin with
11
- * playwright as test runner. The returned promise resolves with an
12
- * adapter suitable for use with function ContextualGherkin().
13
- */
14
- async playwright(): Promise<PlaywrightAdapter> {}
15
+ * playwright. The returned promise resolves with an adapter suitable
16
+ * for use with function ContextualGherkin().
17
+ *
18
+ * @param browserName name of browser to use, defaults to "chromium"
19
+ * @param browserOptions options used on launching the selected browser
20
+ * @param contextOptions options used on creating (another) context in selected browser
21
+ */
22
+ function playwright(
23
+ browserName?: PlaywrightSupportedBrowserName,
24
+ browserOptions?: LaunchOptions,
25
+ contextOptions?: BrowserContextOptions
26
+ ): Promise<PlaywrightAdapter>;
15
27
  }
16
28
 
17
29
  /**
@@ -29,13 +41,13 @@ declare module "@cepharum/contextual-gherkin" {
29
41
  * @param adapter interface for interacting with a browser instance
30
42
  * @returns promise for instance of contextual-gherkin
31
43
  */
32
- async function ContextualGherkin(configuration?: Configuration, adapter?: BrowserAdapter): Promise<Api>;
44
+ function ContextualGherkin(configuration?: Configuration, adapter?: BrowserAdapter): Promise<Api>;
33
45
 
34
46
  /**
35
47
  * Implements singleton API instance for interacting with contextual-gherkin
36
48
  * in current runtime.
37
49
  */
38
- class Api<B = BrowserAdapter<C, A>, C = AbstractContext, A = Assertions> {
50
+ class Api<C = AbstractContext, A = Assertions, B = BrowserAdapter<C, A>> {
39
51
  /**
40
52
  * Creates singleton instance of contextual-gherkin API in current
41
53
  * runtime on first invocation or augments configuration of existing
@@ -44,13 +56,13 @@ declare module "@cepharum/contextual-gherkin" {
44
56
  * @param config configuration of singleton instance, gets merged with previously provided configuration
45
57
  * @param browser adapter for interacting with a browser, required on first invocation, rejected on succeeding invocations
46
58
  */
47
- static async setup( config: Configuration, browser?: B ): Promise<Api<C, A, B>>;
59
+ static setup<C = AbstractContext, A = Assertions, B = BrowserAdapter<C, A>>( config: Configuration, browser?: B ): Promise<Api<C, A, B>>;
48
60
 
49
61
  /**
50
62
  * Provides singleton instance of current runtime's contextual-gherkin
51
63
  * API for interacting with content of one or more browser views.
52
64
  */
53
- static access<BA = B, AC = C, AS = A>(): Api<BA, AC, AS>;
65
+ static access<C = AbstractContext, A = Assertions, B = BrowserAdapter<C, A>>(): Api<C, A, B>;
54
66
 
55
67
  /**
56
68
  * Exposes normalized configuration of contextual-gherkin.
@@ -85,13 +97,13 @@ declare module "@cepharum/contextual-gherkin" {
85
97
  /**
86
98
  * Explicitly creates view with provided name.
87
99
  *
88
- * @param name name of view to create
89
- * @param sharedSession if true, created view shares its session with current one (e.g. having same user authenticated)
90
- * @param select if true, created view is implicitly selected to be current one in follow-up interactions
100
+ * @param name name of view to create, "default" when omitted
101
+ * @param sharedSession if true, created view shares its session with current one (e.g. having same user authenticated), defaults to true
102
+ * @param select if true, created view is implicitly selected to be current one in follow-up interactions, defaults to false
91
103
  * @returns promise for context to interact with named view
92
104
  * @throws TypeError if named view has been created before
93
105
  */
94
- async createView( name: string = "default", sharedSession: boolean = true, select: boolean = false ): Promise<C>;
106
+ createView( name: string, sharedSession: boolean, select: boolean ): Promise<C>;
95
107
 
96
108
  /**
97
109
  * Fetches view by its name, creating it if necessary.
@@ -100,10 +112,10 @@ declare module "@cepharum/contextual-gherkin" {
100
112
  * current view. Use @see Api#createView() to create a view with a
101
113
  * dedicated session.
102
114
  *
103
- * @param name name of view to fetch
115
+ * @param name name of view to fetch, "default" when omitted
104
116
  * @returns promise for context to interact with named view
105
117
  */
106
- async getViewByName( name: string = "default" ): Promise<C>;
118
+ getViewByName( name?: string ): Promise<C>;
107
119
 
108
120
  /**
109
121
  * Fetches view by its name, creating it if necessary, and selects it as
@@ -113,10 +125,10 @@ declare module "@cepharum/contextual-gherkin" {
113
125
  * current view. Use @see Api#createView() to create a view with a
114
126
  * dedicated session.
115
127
  *
116
- * @param name name of view to select
128
+ * @param name name of view to select, "default" when omitted
117
129
  * @returns promise for context to interact with named view
118
130
  */
119
- async selectViewByName( name: string = "default" ): Promise<C>;
131
+ selectViewByName( name?: string ): Promise<C>;
120
132
 
121
133
  /**
122
134
  * Clears histories of all currently managed views.
@@ -168,7 +180,7 @@ declare module "@cepharum/contextual-gherkin" {
168
180
  *
169
181
  * @returns promise resolved when test runner has been resumed
170
182
  */
171
- async debug(): Promise<void>;
183
+ debug(): Promise<void>;
172
184
 
173
185
  /**
174
186
  * Creates promise resolved after giving number of milliseconds.
@@ -176,7 +188,7 @@ declare module "@cepharum/contextual-gherkin" {
176
188
  * @param ms number of milliseconds to wait before resolving returned promise
177
189
  * @returns promise resolved after given number of milliseconds
178
190
  */
179
- async wait( ms: number ): Promise<void>;
191
+ wait( ms: number ): Promise<void>;
180
192
 
181
193
  /**
182
194
  * Gets all aliases of provided type name.
@@ -242,13 +254,13 @@ declare module "@cepharum/contextual-gherkin" {
242
254
  * @param shareSessionWith provides reference on a previously created view's context to share session with
243
255
  * @returns promise created view's context
244
256
  */
245
- async createView( api: Api<BrowserAdapter, C>, shareSessionWith?: C ): Promise<C>;
257
+ createView( api: Api<BrowserAdapter, C>, shareSessionWith?: C ): Promise<C>;
246
258
 
247
259
  /**
248
260
  * Destructs connection to browser by means of closing the controlled
249
261
  * browser invalidating all its views implicitly.
250
262
  */
251
- async disconnect(): Promise<void>;
263
+ disconnect(): Promise<void>;
252
264
 
253
265
  /**
254
266
  * Compiles set of methods available for triggering actions on elements
@@ -256,12 +268,12 @@ declare module "@cepharum/contextual-gherkin" {
256
268
  *
257
269
  * @param locator description of elements resulting actions are performed on
258
270
  */
259
- async getActions( locator: any ): Promise<Actions>;
271
+ getActions( locator: any ): Promise<Actions>;
260
272
 
261
273
  /**
262
274
  * Provides assertions library for assessing state of elements.
263
275
  */
264
- async getAssertions(): Promise<() => A>;
276
+ getAssertions(): Promise<() => A>;
265
277
  }
266
278
 
267
279
  /**
@@ -271,7 +283,7 @@ declare module "@cepharum/contextual-gherkin" {
271
283
  constructor( browser: PlaywrightBrowser, contextOptions?: PlaywrightBrowserContextOptions );
272
284
 
273
285
  /** @inheritDoc */
274
- async createView( api: Api<PlaywrightAdapter, PlaywrightContext>, shareSessionWith: PlaywrightContext = undefined ): Promise<PlaywrightContext>;
286
+ createView( api: Api<PlaywrightAdapter, PlaywrightContext>, shareSessionWith?: PlaywrightContext ): Promise<PlaywrightContext>;
275
287
  }
276
288
 
277
289
  /**
@@ -513,7 +525,7 @@ declare module "@cepharum/contextual-gherkin" {
513
525
  subIndex?: number;
514
526
  }
515
527
 
516
- /**
528
+ /**
517
529
  * Defines common API of a context.
518
530
  *
519
531
  * Every context is managing a set of elements in the document of a connected
@@ -523,18 +535,19 @@ declare module "@cepharum/contextual-gherkin" {
523
535
  * Contexts can be tracked and recovered to implement follow-up queries and
524
536
  * actions.
525
537
  */
538
+ // @ts-ignore
526
539
  abstract class AbstractContext<C = AbstractContext> {
527
540
  /**
528
541
  * @param framework names the framework this context is working with
529
542
  * @param source context this instance is starting as a duplicate of
530
543
  */
531
- constructor( framework: ContextFramework, source?: T );
544
+ constructor( framework: ContextFramework, source?: C );
532
545
 
533
546
  /**
534
547
  * Provides history of recently queried elements tracked per type of
535
548
  * element.
536
549
  */
537
- history: ContextHistoryByElementType<T>;
550
+ history: ContextHistoryByElementType<C>;
538
551
 
539
552
  /**
540
553
  * Names framework current context is used to interact with a connected
@@ -554,7 +567,7 @@ declare module "@cepharum/contextual-gherkin" {
554
567
  * It usually addresses ascendants of current context's set of matching
555
568
  * elements.
556
569
  */
557
- parent?: Context;
570
+ parent?: C;
558
571
 
559
572
  /**
560
573
  * Exposes singular form of type name used to pick a query for
@@ -662,7 +675,7 @@ declare module "@cepharum/contextual-gherkin" {
662
675
  * @param defaultSelector selector to use in case none has been configured for the given type
663
676
  * @returns another context representing all matching elements found as descendants of elements in current context
664
677
  */
665
- find( typeOfElement: string, defaultSelector?: SimpleSelector ): Context;
678
+ find( typeOfElement: string, defaultSelector?: SimpleSelector ): AbstractContext;
666
679
 
667
680
  /**
668
681
  * Reduces current set of matching elements to the one at given index.
@@ -674,7 +687,7 @@ declare module "@cepharum/contextual-gherkin" {
674
687
  * @param index non-nullish index into current context's set of matching elements to pick
675
688
  * @returns another context representing that selected element, only, current context if index is nullish
676
689
  */
677
- nth( index: number|null ): Context;
690
+ nth( index: number|null ): AbstractContext;
678
691
 
679
692
  /**
680
693
  * Reduces current context's set of matching elements to those matching
@@ -688,7 +701,7 @@ declare module "@cepharum/contextual-gherkin" {
688
701
  * @param defaultSelector selector to use if none has been configured for the named type of elements
689
702
  * @returns another context representing only those matching elements of current context that match selector of given name, too
690
703
  */
691
- filter( typeOfElement: string, defaultSelector?: SimpleSelector ): Context;
704
+ filter( typeOfElement: string, defaultSelector?: SimpleSelector ): AbstractContext;
692
705
 
693
706
  /**
694
707
  * Reduces current context's set of matching elements to those marked as
@@ -704,7 +717,7 @@ declare module "@cepharum/contextual-gherkin" {
704
717
  * @param closureScope set of simple values to be provided as closure scope to invoked callback
705
718
  * @returns another context representing only those matching elements of current context that cause provided callback to return truthy
706
719
  */
707
- filterFn( fn: SelectorFn, closureScope?: { [key: string]: any } ): Context;
720
+ filterFn( fn: SelectorFn, closureScope?: { [key: string]: any } ): AbstractContext;
708
721
 
709
722
  /**
710
723
  * Reduces current context's set of matching elements to those having
@@ -728,7 +741,7 @@ declare module "@cepharum/contextual-gherkin" {
728
741
  * @param closureScope set of simple values to be provided as closure scope to invoked callback
729
742
  * @returns another context representing only those matching elements of current context that have children causing provided callback to return truthy
730
743
  */
731
- filterBySubsWithFn( typeOfSub: string, defaultSelector: SimpleSelector, fn: SelectorFn, closureScope?: { [key: string]: any } ): Context;
744
+ filterBySubsWithFn( typeOfSub: string, defaultSelector: SimpleSelector, fn: SelectorFn, closureScope?: { [key: string]: any } ): AbstractContext;
732
745
 
733
746
  /**
734
747
  * Implements a convenient helper to filter current set of matching
@@ -741,7 +754,7 @@ declare module "@cepharum/contextual-gherkin" {
741
754
  * @param partially if true, given text or regular expression is expected to be a part of a child's normalized textual content, only
742
755
  * @returns another context limited to those matching elements of current context that have children with a given text
743
756
  */
744
- filterBySubsWithText( typeOfSub: string, defaultSelector: SimpleSelector, text: string|RegExp, partially?: boolean ): Context;
757
+ filterBySubsWithText( typeOfSub: string, defaultSelector: SimpleSelector, text: string|RegExp, partially?: boolean ): AbstractContext;
745
758
 
746
759
  /**
747
760
  * Limits set of matching elements to those with a named attribute
@@ -751,7 +764,7 @@ declare module "@cepharum/contextual-gherkin" {
751
764
  * @param value value to expect in a matching element's attribute
752
765
  * @returns another context with all those elements of current one which have a matching value in named attribute
753
766
  */
754
- withAttribute( name: string, value: string|RegExp|boolean ): Context;
767
+ withAttribute( name: string, value: string|RegExp|boolean ): AbstractContext;
755
768
 
756
769
  /**
757
770
  * Limits set of matching elements to those with a named DOM property
@@ -768,7 +781,7 @@ declare module "@cepharum/contextual-gherkin" {
768
781
  * @param value value to expect in a matching element's DOM property, use callback invoked with found value to return truthy on a match
769
782
  * @returns another context with all those elements of current one which have a matching value in named DOM property
770
783
  */
771
- withProperty( name: string, value: string|RegExp|boolean|SelectorFn ): Context;
784
+ withProperty( name: string, value: string|RegExp|boolean|SelectorFn ): AbstractContext;
772
785
 
773
786
  /**
774
787
  * Limits set of matching elements to those with a named DOM property
@@ -777,10 +790,10 @@ declare module "@cepharum/contextual-gherkin" {
777
790
  *
778
791
  * @param name name of DOM property to inspect, might be mapped internally according to selectors configuration
779
792
  * @param value value to expect in a matching element's DOM property, use callback invoked with found value to return truthy on a match
780
- * @param negated if true, value must not be included with any named property of currently matching elements
793
+ * @param negated if true, value must not be included with any named property of currently matching elements, false by default
781
794
  * @returns another context with all those elements of current one which have a matching value in named DOM property
782
795
  */
783
- withListProperty( name: string, value: string, negated: boolean = false ): Context;
796
+ withListProperty( name: string, value: string, negated?: boolean ): AbstractContext;
784
797
 
785
798
  /**
786
799
  * Detaches current context from its original query used to address
@@ -792,7 +805,7 @@ declare module "@cepharum/contextual-gherkin" {
792
805
  *
793
806
  * @param cardinality cardinality of resulting context
794
807
  */
795
- detach( cardinality?: Cardinality ): Promise<Context>;
808
+ detach( cardinality?: Cardinality ): Promise<AbstractContext>;
796
809
 
797
810
  /**
798
811
  * Tracks detached version of current context in history of contexts for
@@ -812,7 +825,7 @@ declare module "@cepharum/contextual-gherkin" {
812
825
  * @param cardinality selects expected number of elements in match to find
813
826
  * @returns previously tracked context matching parameters
814
827
  */
815
- getTracked( typeOfElement, index, cardinality = null ): Context;
828
+ getTracked( typeOfElement, index, cardinality? ): AbstractContext;
816
829
 
817
830
  /**
818
831
  * Looks up runtime configuration for a selector matching provided
@@ -830,11 +843,11 @@ declare module "@cepharum/contextual-gherkin" {
830
843
  * provided data extracted from a {cardinal-word} expression.
831
844
  *
832
845
  * @param cardinal data of an encountered {cardinal-word} expression
833
- * @param track controls if current context should be tracked in history after passing check
834
- * @param message custom message to display if check fails
846
+ * @param track controls if current context should be tracked in history after passing check, true by default
847
+ * @param message custom message to display if check fails, "expecting %amount" by default
835
848
  * @returns promise resolved when check has passed and context has been optionally tracked
836
849
  */
837
- checkCardinalWord(cardinal: NumberAndWord, track: boolean = true, message: string = "expecting %amount" ): Promise<void>;
850
+ checkCardinalWord(cardinal: NumberAndWord, track?: boolean, message?: string ): Promise<void>;
838
851
 
839
852
  /**
840
853
  * Conveniently asserts that some or all matching elements of current
@@ -850,11 +863,11 @@ declare module "@cepharum/contextual-gherkin" {
850
863
  *
851
864
  * @param filteredContext another context of matching elements to compare with current one
852
865
  * @param contextualWord parsed instance of `{contextual-word}` used to fetch current context from history
853
- * @param requireAll if true, provided context has to list all elements of current context, otherwise it has to list at least one element
854
- * @param track if true, this context is tracked if it has been reduced after fetching it from context due to provided `phrase`
866
+ * @param requireAll if true, provided context has to list all elements of current context, otherwise it has to list at least one element, true by default
867
+ * @param track if true, this context is tracked if it has been reduced after fetching it from context due to provided `phrase`, true by default
855
868
  * @returns promise resolved when check has passed and context has been optionally tracked in history
856
869
  */
857
- checkFilteredInContext( filteredContext: Context, contextualWord: ContextualWord, requireAll: boolean = true, track: boolean = true ): Promise<void>;
870
+ checkFilteredInContext( filteredContext: AbstractContext, contextualWord: ContextualWord, requireAll?: boolean, track?: boolean ): Promise<void>;
858
871
  }
859
872
 
860
873
  /**
@@ -908,7 +921,7 @@ declare module "@cepharum/contextual-gherkin" {
908
921
  *
909
922
  * @param target context addressing target element(s) is/are dragged to
910
923
  */
911
- dragTo(target: context): Promise<void>;
924
+ dragTo(target: AbstractContext): Promise<void>;
912
925
 
913
926
  /**
914
927
  * Dispatches custom event to elements matching current context.
@@ -992,7 +1005,7 @@ declare module "@cepharum/contextual-gherkin" {
992
1005
  * Provides the locator used to query a connected browser's page for
993
1006
  * matching elements.
994
1007
  */
995
- locator: Locator;
1008
+ locator: PlaywrightLocator;
996
1009
  }
997
1010
 
998
1011
  // re-define some playwright types with a custom name so for using it in
@@ -1003,32 +1016,32 @@ declare module "@cepharum/contextual-gherkin" {
1003
1016
 
1004
1017
  type Action = "click" | "hover" | "enter";
1005
1018
 
1006
- async function globalFind( cardinal: NumberAndWord ): Promise<void>;
1007
- async function globalFindByAttribute( cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1008
- async function globalFindByProperty( cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1009
- async function globalFindByClass( cardinal: NumberAndWord, className: string, negated: boolean ): Promise<void>;
1010
- async function globalFindByLabel( cardinal: NumberAndWord, label: string, partially: boolean ): Promise<void>;
1011
- async function globalFindByTextContent( cardinal: NumberAndWord, text: string, partially: boolean ): Promise<void>;
1012
-
1013
- async function globalActionByAttribute( cardinal: NumberAndWord, name: string, value: string|RegExp, action: Action, input?: string ): Promise<void>;
1014
- async function globalActionByProperty( cardinal: NumberAndWord, name: string, value: string|RegExp, action: Action, input?: string ): Promise<void>;
1015
- async function globalActionByClass( cardinal: NumberAndWord, className: string, negated?: boolean, action: Action, input?: string ): Promise<void>;
1016
- async function globalActionByLabel( cardinal: NumberAndWord, label: string, partially: boolean, action: Action, input?: string ): Promise<void>;
1017
- async function globalActionByTextContent( cardinal: NumberAndWord, text: string, partially: boolean, action: Action, input?: string ): Promise<void>;
1018
-
1019
- async function localFind( phrase: ContextualWord, cardinal: NumberAndWord ): Promise<void>;
1020
- async function localFindByAttribute( phrase: ContextualWord, cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1021
- async function localFindByProperty( phrase: ContextualWord, cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1022
- async function localFindByClass( phrase: ContextualWord, cardinal: NumberAndWord, className: string, negated: boolean ): Promise<void>;
1023
- async function localFindByLabel( phrase: ContextualWord, cardinal: NumberAndWord, label: string, partially: boolean ): Promise<void>;
1024
- async function localFindByTextContent( phrase: ContextualWord, cardinal: NumberAndWord, text: string, partially: boolean ): Promise<void>;
1025
-
1026
- async function localAction( phrase: ContextualWord, action: Action, input?: string ): Promise<void>;
1027
-
1028
- async function localStateByAttribute( phrase: ContextualWord, all: boolean, name: string, value: string|RegExp ): Promise<void>;
1029
- async function localStateByProperty( phrase: ContextualWord, all: boolean, name: string, value: string|RegExp ): Promise<void>;
1030
- async function localStateByClass( phrase: ContextualWord, all: boolean, className: string, negated: boolean ): Promise<void>;
1031
- async function localStateByLabel( phrase: ContextualWord, label: string, partially: boolean ): Promise<void>;
1032
- async function localStateByTextContent( phrase: ContextualWord, text: string, partially: boolean ): Promise<void>;
1033
- async function localStateExists( phrase: ContextualWord, mustExist: boolean ): Promise<void>;
1019
+ function globalFind( cardinal: NumberAndWord ): Promise<void>;
1020
+ function globalFindByAttribute( cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1021
+ function globalFindByProperty( cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1022
+ function globalFindByClass( cardinal: NumberAndWord, className: string, negated: boolean ): Promise<void>;
1023
+ function globalFindByLabel( cardinal: NumberAndWord, label: string, partially: boolean ): Promise<void>;
1024
+ function globalFindByTextContent( cardinal: NumberAndWord, text: string, partially: boolean ): Promise<void>;
1025
+
1026
+ function globalActionByAttribute( cardinal: NumberAndWord, name: string, value: string|RegExp, action: Action, input?: string ): Promise<void>;
1027
+ function globalActionByProperty( cardinal: NumberAndWord, name: string, value: string|RegExp, action: Action, input?: string ): Promise<void>;
1028
+ function globalActionByClass( cardinal: NumberAndWord, className: string, negated: boolean, action: Action, input?: string ): Promise<void>;
1029
+ function globalActionByLabel( cardinal: NumberAndWord, label: string, partially: boolean, action: Action, input?: string ): Promise<void>;
1030
+ function globalActionByTextContent( cardinal: NumberAndWord, text: string, partially: boolean, action: Action, input?: string ): Promise<void>;
1031
+
1032
+ function localFind( phrase: ContextualWord, cardinal: NumberAndWord ): Promise<void>;
1033
+ function localFindByAttribute( phrase: ContextualWord, cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1034
+ function localFindByProperty( phrase: ContextualWord, cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
1035
+ function localFindByClass( phrase: ContextualWord, cardinal: NumberAndWord, className: string, negated: boolean ): Promise<void>;
1036
+ function localFindByLabel( phrase: ContextualWord, cardinal: NumberAndWord, label: string, partially: boolean ): Promise<void>;
1037
+ function localFindByTextContent( phrase: ContextualWord, cardinal: NumberAndWord, text: string, partially: boolean ): Promise<void>;
1038
+
1039
+ function localAction( phrase: ContextualWord, action: Action, input?: string ): Promise<void>;
1040
+
1041
+ function localStateByAttribute( phrase: ContextualWord, all: boolean, name: string, value: string|RegExp ): Promise<void>;
1042
+ function localStateByProperty( phrase: ContextualWord, all: boolean, name: string, value: string|RegExp ): Promise<void>;
1043
+ function localStateByClass( phrase: ContextualWord, all: boolean, className: string, negated: boolean ): Promise<void>;
1044
+ function localStateByLabel( phrase: ContextualWord, label: string, partially: boolean ): Promise<void>;
1045
+ function localStateByTextContent( phrase: ContextualWord, text: string, partially: boolean ): Promise<void>;
1046
+ function localStateExists( phrase: ContextualWord, mustExist: boolean ): Promise<void>;
1034
1047
  }
@@ -3,7 +3,7 @@ import { PlaywrightContext } from "../context/playwright.js";
3
3
  import { clientHelper } from "../support/playwright/client-helper.js";
4
4
 
5
5
  /**
6
- * @implements {BrowserAdapter}
6
+ * @extends {BrowserAdapter}
7
7
  */
8
8
  export class PlaywrightAdapter {
9
9
  /**
@@ -33,7 +33,7 @@ export class PlaywrightAdapter {
33
33
  }
34
34
 
35
35
  /**
36
- * @param {cgApi} api
36
+ * @param {Api} api
37
37
  * @param {PlaywrightContext} shareSessionWith
38
38
  */
39
39
  async createView( api, shareSessionWith = undefined ) {
package/lib/api.js CHANGED
@@ -84,7 +84,9 @@ export class Api {
84
84
  */
85
85
  static access() {
86
86
  if ( !singleton ) {
87
- throw new Error( "missing contextual-gherkin API ... see https://cepharum-foss.gitlab.io/contextual-gherkin/api/configuration.html" );
87
+ throw Object.assign( new Error( "missing contextual-gherkin API ... see https://cepharum-foss.gitlab.io/contextual-gherkin/api/configuration.html" ), {
88
+ missingContextualGherkin: true,
89
+ } );
88
90
  }
89
91
 
90
92
  return singleton;
package/lib/cli.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import File from "node:fs/promises";
2
- import OS from "node:os";
3
2
  import Path from "node:path";
4
3
  import { fileURLToPath, pathToFileURL } from "node:url";
5
4
 
@@ -13,25 +12,6 @@ export function getMyFolder() {
13
12
  return Path.resolve( fileURLToPath( import.meta.url ), "../.." );
14
13
  }
15
14
 
16
- /**
17
- * Gathers information on named file without throwing in case the file simply
18
- * does not exist.
19
- *
20
- * @param {string} filename name of file to inspect
21
- * @returns {Promise<Stats|null>} promise for found file's information, null if file is missing
22
- */
23
- export async function statFile( filename ) {
24
- try {
25
- return await File.stat( filename );
26
- } catch ( cause ) {
27
- if ( cause.code === "ENOENT" ) {
28
- return null;
29
- }
30
-
31
- throw cause;
32
- }
33
- }
34
-
35
15
  /**
36
16
  * Reads single package.json file.
37
17
  */
@@ -237,40 +217,6 @@ export function parseArguments( argv ) {
237
217
  };
238
218
  }
239
219
 
240
- /**
241
- * Inspects npm executable used to invoke cucumber-js.
242
- *
243
- * @paranm {Object<string,string>} env set of environment variables
244
- * @returns {Promise<Object<string,any>>} promise for options to properly spawn npm
245
- */
246
- export async function detectNpmOptions( env ) {
247
- const envPath = env.PATH ?? env.Path;
248
- const isWindows = OS.platform() === "win32";
249
-
250
- for ( const path of envPath.split( Path.delimiter ) ) {
251
- const candidate = Path.resolve( path, isWindows ? "npm.cmd" : "npm" );
252
- const npmStat = await statFile( candidate ); // eslint-disable-line no-await-in-loop
253
-
254
- if ( npmStat?.isFile() || npmStat?.isSymbolicLink() ) {
255
- const spawnOptions = {
256
- shell: candidate.endsWith( ".cmd" ),
257
- };
258
-
259
- if ( !spawnOptions.shell ) {
260
- const file = await File.readFile( candidate, "utf8" ); // eslint-disable-line no-await-in-loop
261
-
262
- if ( file.startsWith( "#!/" ) ) {
263
- spawnOptions.shell = true;
264
- }
265
- }
266
-
267
- return spawnOptions;
268
- }
269
- }
270
-
271
- return undefined;
272
- }
273
-
274
220
  /**
275
221
  * Inspects existing dependency @cucumber/cucumber for the pathname of script
276
222
  * implementing the CLI binary of cucumber.
@@ -1,4 +1,4 @@
1
- import { firefox, chromium, webkit } from "playwright";
1
+ import { firefox, chromium, webkit } from "@playwright/test";
2
2
 
3
3
  import { PlaywrightAdapter } from "../../adapter/playwright.js";
4
4
  import { registerPlaywrightSelectors } from "./custom-selectors.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cepharum/contextual-gherkin",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "flexible step definitions for Gherkin",
5
5
  "author": "cepharum GmbH <thomas.urban@cepharum.de>",
6
6
  "homepage": "https://cepharum-foss.gitlab.io/contextual-gherkin/",
@@ -11,7 +11,15 @@ Then( "I debug", { timeout: -1 }, debug );
11
11
  Then( "I pause", { timeout: -1 }, debug );
12
12
 
13
13
  // make sure to disconnect the browser after testing
14
- AfterAll( () => Api.access().browser.disconnect() );
14
+ AfterAll( async() => {
15
+ try {
16
+ await Api.access().browser.disconnect();
17
+ } catch ( cause ) {
18
+ if ( !cause.missingContextualGherkin ) {
19
+ throw cause;
20
+ }
21
+ }
22
+ } );
15
23
 
16
24
  After( () => {
17
25
  Api.access().clearHistories();