cypress-fail-on-console-error 3.1.0 → 3.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/README.md CHANGED
@@ -10,7 +10,7 @@ npm install cypress-fail-on-console-error --save-dev
10
10
 
11
11
  ### Usage
12
12
 
13
- `cypress/support/index.js`
13
+ `cypress/support/e2e.js`
14
14
 
15
15
  ```js
16
16
  import failOnConsoleError from 'cypress-fail-on-console-error';
@@ -20,15 +20,14 @@ failOnConsoleError();
20
20
 
21
21
  ### Config (optional)
22
22
 
23
- | Parameter | Default | Description |
24
- | --------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
- | `excludeMessages` | `undefined` | Exclude console messages from throwing `AssertionError` <br /> When `console.error()` contains an error object from `new Error()`, then the whole stacktrace can be matched <br /> Regular expression parameters are acceptable. String parameters will be interpreted as regular expression. Be sure to [escape the string regular expression](https://javascript.info/regexp-escaping) for special characters. |
26
- | `includeConsoleTypes` | `[consoleType.ERROR]` | Include console types for observation |
27
- | `cypressLog` | `false` | Include debug logs for `errorMessage_excludeMessage_match` and `errorMessage_excluded` to cypress runner |
23
+ | Parameter | Default | <div style="width:300px">Description</div> |
24
+ |--- |--- |--- |
25
+ | `excludeMessages` | `undefined` | Exclude console messages from throwing `AssertionError`. Regular expression parameters are acceptable. String parameters will be interpreted as regular expression. [String.match()](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/match) will be used for evaluation. Be sure to [escape the string regular expression](https://javascript.info/regexp-escaping) for special characters. When console message property `stacktrace` exists, then the whole stacktrace can be matched. |
26
+ | `includeConsoleTypes` | `[consoleType.ERROR]` | Define console types for observation
27
+ | `cypressLog` | `false` | Enable debug logs for errorMessage_excludeMessage_match and errorMessage_excluded to cypress runner
28
28
 
29
29
  <br/>
30
30
 
31
- <!-- prettier-ignore -->
32
31
  ```js
33
32
  import failOnConsoleError, { consoleType } from 'cypress-fail-on-console-error';
34
33
 
@@ -47,6 +46,7 @@ failOnConsoleError(config);
47
46
  // excludeMessages[0] matches example console message 'this is a foo message'
48
47
  // excludeMessages[1] matches example console message 'some bar-regex message'
49
48
  // includeConsoleTypes observe console types ERROR, WARN and INFO
49
+ //debug information will be printed to the cypress runner
50
50
  ```
51
51
 
52
52
  Using Javascript, consoleType Enum can be parsed as number values
@@ -60,3 +60,11 @@ failOnConsoleError({
60
60
  // 1 = WARN
61
61
  // 2 = ERROR
62
62
  ```
63
+
64
+ ### Debugging
65
+ When Cypress log is activated, debug information about the matching and exclude process are available from the cypress runner. As a plus, the generated error message string can be verified.
66
+ ![image info](./docs/cypressLogTrue.png)
67
+
68
+ ### Contributing
69
+ 1. Create an project issue with proper description and expected behaviour
70
+ 2. Provide a PR with implementation and tests. Command `npm run verify` have to pass locally
package/dist/index.js CHANGED
@@ -28,6 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.consoleType = exports.cypressLogger = exports.callToString = exports.isErrorMessageExcluded = exports.findIncludedCall = exports.getIncludedCall = exports.createSpies = exports.createConfig = exports.validateConfig = void 0;
30
30
  var chai = __importStar(require("chai"));
31
+ var chai_1 = require("chai");
32
+ var os_1 = require("os");
31
33
  var sinon = __importStar(require("sinon"));
32
34
  var sinon_chai_1 = __importDefault(require("sinon-chai"));
33
35
  var type_detect_1 = __importDefault(require("type-detect"));
@@ -47,7 +49,7 @@ function failOnConsoleError(config) {
47
49
  return;
48
50
  var errorMessage = (0, exports.getIncludedCall)(spies, config);
49
51
  if (errorMessage) {
50
- chai.expect(errorMessage, 'console match found').to.be.undefined;
52
+ throw new chai_1.AssertionError("cypress-fail-on-console-error: ".concat(os_1.EOL, " ").concat(errorMessage));
51
53
  }
52
54
  });
53
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-fail-on-console-error",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "fail cypress test on console error",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,8 +44,8 @@
44
44
  "@types/mocha": "9.1.1",
45
45
  "@types/sinon": "10.0.12",
46
46
  "@types/sinon-chai": "3.2.8",
47
- "@types/type-detect": "^4.0.1",
48
- "cypress": "10.3.0",
47
+ "@types/type-detect": "4.0.1",
48
+ "cypress": "10.3.1",
49
49
  "mocha": "10.0.0",
50
50
  "prettier": "2.7.1",
51
51
  "prettier-plugin-organize-imports": "3.0.0",