@qavajs/cypress 2.1.0 → 2.2.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 CHANGED
@@ -10,6 +10,23 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
10
10
  :pencil: - chore
11
11
  :microscope: - experimental
12
12
 
13
+ ## [2.2.0]
14
+ - :rocket: added `to satisfy` validation to verify user-defined expectation provided as predicate
15
+ ```Gherkin
16
+ Then I expect '$value' to satisfy '$either(1, 2)'
17
+ ```
18
+ where `$either` is a function
19
+ ```typescript
20
+ function either(...expected) {
21
+ return function (actual) {
22
+ return expected.includes(actual)
23
+ }
24
+ }
25
+ ```
26
+
27
+ ## [2.1.1]
28
+ - :beetle: replaced .as to Cypress.log in page object logging
29
+
13
30
  ## [2.1.0]
14
31
  - :rocket: added page object logging
15
32
 
@@ -88,5 +88,6 @@ export function element(path) {
88
88
  }
89
89
  method = 'find';
90
90
  }
91
- return current.as(path)
91
+ Cypress.log({ displayName: path });
92
+ return current
92
93
  }
package/lib/types.js CHANGED
@@ -34,7 +34,7 @@ defineParameterType({
34
34
 
35
35
  defineParameterType({
36
36
  name: 'validation',
37
- regexp: /((?:is |do |does |to )?(not |to not )?(?:to )?(?:be )?(equal|strictly equal|deeply equal|have member|match|contain|above|below|greater than|less than|have type)(?:s|es)?)/,
37
+ regexp: /((?:is |do |does |to )?(not |to not )?(?:to )?(?:be )?(softly )?(equal|strictly equal|deeply equal|have member|match|contain|above|below|greater than|less than|have type|have property|match schema|include members|satisfy|case insensitive equal)(?:s|es| to)?)/,
38
38
  useForSnippets: false,
39
39
  transformer: getValidation
40
40
  });
@@ -10,6 +10,30 @@ chai.Assertion.addMethod('notStrictEqual', function (ER) {
10
10
  );
11
11
  });
12
12
 
13
+ chai.Assertion.addMethod('caseInsensitiveEqual', function (ER) {
14
+ const obj = this._obj;
15
+
16
+ this.assert(
17
+ obj.toLowerCase() === ER.toLowerCase(),
18
+ 'expected #{this} to equal #{exp}',
19
+ 'expected #{this} to not equal #{exp}',
20
+ ER,
21
+ obj
22
+ );
23
+ });
24
+
25
+ chai.Assertion.addMethod('satisfy', function (predicate) {
26
+ const actual = this._obj;
27
+
28
+ this.assert(
29
+ predicate(actual),
30
+ 'expected #{this} to satisfy #{exp}',
31
+ 'expected #{this} to not satisfy #{exp}',
32
+ predicate.toString(),
33
+ actual
34
+ );
35
+ });
36
+
13
37
  export const validations = {
14
38
  EQUAL: 'equal',
15
39
  DEEPLY_EQUAL: 'deeply equal',
@@ -23,7 +47,9 @@ export const validations = {
23
47
  LESS: 'less than',
24
48
  HAVE_TYPE: 'have type',
25
49
  INCLUDE_MEMBERS: 'include member',
26
- HAVE_PROPERTY: 'have property'
50
+ HAVE_PROPERTY: 'have property',
51
+ CASE_INSENSITIVE_EQUAL: 'case insensitive equal',
52
+ SATISFY: 'satisfy'
27
53
  };
28
54
 
29
55
  const isClause = '(?:is |do |does |to )?';
@@ -50,6 +76,8 @@ const validationFns = {
50
76
  [validations.HAVE_TYPE]: (expectClause, ER) => expectClause.a(ER),
51
77
  [validations.INCLUDE_MEMBERS]: (expectClause, ER) => expectClause.include.members(ER),
52
78
  [validations.HAVE_PROPERTY]: (expectClause, ER) => expectClause.have.property(ER),
79
+ [validations.CASE_INSENSITIVE_EQUAL]: (expectClause, ER) => expectClause.caseInsensitiveEqual(ER),
80
+ [validations.SATISFY]: (expectClause, ER) => expectClause.satisfy(ER),
53
81
  };
54
82
 
55
83
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/cypress",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "qavajs for cypress runner",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,8 +14,8 @@
14
14
  "author": "Alexandr Galichenko",
15
15
  "license": "MIT",
16
16
  "devDependencies": {
17
- "@qavajs/cypress-runner-adapter": "^1.0.1",
17
+ "@qavajs/cypress-runner-adapter": "^1.1.0",
18
18
  "@qavajs/memory": "^1.10.2",
19
- "cypress": "^14.5.2"
19
+ "cypress": "^15.0.0"
20
20
  }
21
21
  }