@qavajs/cypress 2.8.2 → 2.9.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/CHANGELOG.md +5 -0
- package/README.md +6 -6
- package/defineQavajs.d.ts +27 -0
- package/index.d.ts +11 -0
- package/package.json +18 -3
- package/po.d.ts +53 -0
- package/tsconfig.json +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,11 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
10
10
|
:pencil: - chore
|
|
11
11
|
:microscope: - experimental
|
|
12
12
|
|
|
13
|
+
## [2.9.0]
|
|
14
|
+
- :pencil: added TypeScript declaration files (`index.d.ts`, `po.d.ts`, `defineQavajs.d.ts`)
|
|
15
|
+
- :pencil: added `tsconfig.json`
|
|
16
|
+
- :pencil: added `types` and `exports` fields to `package.json`
|
|
17
|
+
|
|
13
18
|
## [2.8.2]
|
|
14
19
|
- :rocket: added `clickable` condition (checks element is visible and not disabled)
|
|
15
20
|
- :beetle: fixed `validateAllOf` exiting after first successful match instead of validating all values
|
package/README.md
CHANGED
|
@@ -56,9 +56,9 @@ class Header {
|
|
|
56
56
|
|
|
57
57
|
export default class App {
|
|
58
58
|
// Simple CSS/XPath selector
|
|
59
|
-
SearchInput
|
|
59
|
+
SearchInput = locator('#search');
|
|
60
60
|
SearchButton = locator('#searchBtn');
|
|
61
|
-
Results
|
|
61
|
+
Results = locator('.result-item');
|
|
62
62
|
|
|
63
63
|
// Parameterized selector
|
|
64
64
|
ResultByIndex = locator.template(idx => `.result-item:nth-child(${idx})`);
|
|
@@ -79,11 +79,11 @@ The memory class stores values accessible in steps via the `$key` syntax.
|
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
81
|
export default class Memory {
|
|
82
|
-
baseUrl
|
|
83
|
-
testUser
|
|
82
|
+
baseUrl = 'https://example.com';
|
|
83
|
+
testUser = 'user@example.com';
|
|
84
84
|
// Functions are called on access
|
|
85
|
-
timestamp
|
|
86
|
-
uppercase
|
|
85
|
+
timestamp = () => Date.now();
|
|
86
|
+
uppercase = (str: string) => str.toUpperCase();
|
|
87
87
|
}
|
|
88
88
|
```
|
|
89
89
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Options passed to {@link defineQavajs} to wire up the qavajs runtime. */
|
|
2
|
+
export interface QavajsOptions {
|
|
3
|
+
/** Root page-object instance or class used to resolve element aliases. */
|
|
4
|
+
pageObject: object;
|
|
5
|
+
/** Memory instance used for expression interpolation and value storage. */
|
|
6
|
+
memory: object;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Initialise the qavajs runtime by attaching the page-object and memory
|
|
11
|
+
* instances to the Cypress `window` object so step definitions can access them.
|
|
12
|
+
* Call this once in your Cypress support file before any tests run.
|
|
13
|
+
*
|
|
14
|
+
* @param options - Page-object and memory configuration.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import defineQavajs from '@qavajs/cypress/defineQavajs';
|
|
19
|
+
* import App from './page_object';
|
|
20
|
+
* import Memory from './memory';
|
|
21
|
+
*
|
|
22
|
+
* defineQavajs({ pageObject: new App(), memory: new Memory() });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function defineQavajs(options: QavajsOptions): void;
|
|
26
|
+
|
|
27
|
+
export default defineQavajs;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effect import that registers all qavajs Cucumber step definitions
|
|
3
|
+
* (actions, validations, memory, HTTP, mouse, storage, etc.) with the
|
|
4
|
+
* `@qavajs/cypress-runner-adapter` runtime.
|
|
5
|
+
*
|
|
6
|
+
* Import this once in your Cypress support file:
|
|
7
|
+
* ```ts
|
|
8
|
+
* import '@qavajs/cypress';
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qavajs/cypress",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "qavajs for cypress runner",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"default": "./index.js"
|
|
11
|
+
},
|
|
12
|
+
"./po": {
|
|
13
|
+
"types": "./po.d.ts",
|
|
14
|
+
"default": "./po.js"
|
|
15
|
+
},
|
|
16
|
+
"./defineQavajs": {
|
|
17
|
+
"types": "./defineQavajs.d.ts",
|
|
18
|
+
"default": "./defineQavajs.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
6
21
|
"scripts": {
|
|
7
22
|
"debug": "cypress open --config-file test-e2e/cypress.config.js",
|
|
8
23
|
"debug:it": "MODE=it cypress open --config-file test-e2e/cypress.config.js",
|
|
@@ -32,8 +47,8 @@
|
|
|
32
47
|
"node": ">=18"
|
|
33
48
|
},
|
|
34
49
|
"devDependencies": {
|
|
35
|
-
"@qavajs/cypress-runner-adapter": "^1.
|
|
50
|
+
"@qavajs/cypress-runner-adapter": "^1.11.0",
|
|
36
51
|
"@qavajs/memory": "^1.11.0",
|
|
37
|
-
"cypress": "^15.
|
|
52
|
+
"cypress": "^15.15.0"
|
|
38
53
|
}
|
|
39
54
|
}
|
package/po.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Determines how a selector is resolved against the DOM. */
|
|
2
|
+
export type SelectorType = 'simple' | 'template' | 'native';
|
|
3
|
+
|
|
4
|
+
/** Represents a page-object element definition. */
|
|
5
|
+
export declare class Selector {
|
|
6
|
+
/** selector string */
|
|
7
|
+
selector: string | null;
|
|
8
|
+
/** Resolution strategy used when traversing the element chain. */
|
|
9
|
+
type: SelectorType;
|
|
10
|
+
/** Optional component class whose properties describe child elements. */
|
|
11
|
+
component?: new () => object;
|
|
12
|
+
|
|
13
|
+
constructor(selector: string | null, type?: SelectorType);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Attach a component class to this selector so its properties can be
|
|
17
|
+
* used as child element aliases.
|
|
18
|
+
* @param component - Component class whose instance defines child aliases.
|
|
19
|
+
*/
|
|
20
|
+
as(component: new () => object): this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface LocatorFn {
|
|
24
|
+
/**
|
|
25
|
+
* Create a simple selector entry.
|
|
26
|
+
* @param selector - Selector string.
|
|
27
|
+
*/
|
|
28
|
+
(selector: string): Selector;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create a template selector whose final value is produced by calling
|
|
32
|
+
* `Alias (argument)` at query time, allowing dynamic substitution.
|
|
33
|
+
* @param selector - Function that receives the runtime argument and returns the selector string.
|
|
34
|
+
*/
|
|
35
|
+
template(selector: (argument: string) => string): Selector;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a native selector resolved via a custom Cypress command chain.
|
|
39
|
+
* The function receives context at query time and must return a Chainable.
|
|
40
|
+
* @param selector - Function that builds and returns a Cypress Chainable.
|
|
41
|
+
*/
|
|
42
|
+
native(selector: (ctx: { parent: Cypress.Chainable; cy: Cypress.cy; argument: string }) => Cypress.Chainable): Selector;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Create a component-only node with no selector of its own.
|
|
46
|
+
* Useful when the root of a sub-tree is already in scope.
|
|
47
|
+
* @param component - Component class whose instance defines child aliases.
|
|
48
|
+
*/
|
|
49
|
+
as(component: new () => object): Selector;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Factory for building page-object element definitions. */
|
|
53
|
+
export declare const locator: LocatorFn;
|