cypress-fail-on-console-error 2.1.1 → 2.1.4
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 +1 -1
- package/dist/index.js +20 -17
- package/package.json +21 -18
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# cypress-fail-on-console-error
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This Plugin observes console.error() function from [window object](https://developer.mozilla.org/de/docs/Web/API/Window). It will automatically fail the executed cypress test as soon as the error function is executed once.
|
|
4
4
|
|
|
5
5
|
### Installation
|
|
6
6
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -32,21 +36,21 @@ chai.use(sinon_chai_1.default);
|
|
|
32
36
|
function failOnConsoleError(config) {
|
|
33
37
|
if (config === void 0) { config = {}; }
|
|
34
38
|
var spies;
|
|
35
|
-
exports.validateConfig(config);
|
|
36
|
-
config = exports.createConfig(config);
|
|
39
|
+
(0, exports.validateConfig)(config);
|
|
40
|
+
config = (0, exports.createConfig)(config);
|
|
37
41
|
Cypress.on('window:before:load', function (win) {
|
|
38
|
-
spies = exports.createSpies(config, win.console);
|
|
42
|
+
spies = (0, exports.createSpies)(config, win.console);
|
|
39
43
|
});
|
|
40
44
|
Cypress.on('command:enqueued', function () {
|
|
41
45
|
if (spies) {
|
|
42
|
-
spies = exports.resetSpies(spies);
|
|
46
|
+
spies = (0, exports.resetSpies)(spies);
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
49
|
Cypress.on('command:end', function () {
|
|
46
|
-
if (!spies || !exports.someSpyCalled(spies)) {
|
|
50
|
+
if (!spies || !(0, exports.someSpyCalled)(spies)) {
|
|
47
51
|
return;
|
|
48
52
|
}
|
|
49
|
-
var spy = exports.getIncludedSpy(spies, config);
|
|
53
|
+
var spy = (0, exports.getIncludedSpy)(spies, config);
|
|
50
54
|
if (spy) {
|
|
51
55
|
chai.expect(spy).to.have.callCount(0);
|
|
52
56
|
}
|
|
@@ -64,18 +68,19 @@ var validateConfig = function (config) {
|
|
|
64
68
|
if (config.includeConsoleTypes) {
|
|
65
69
|
chai.expect(config.includeConsoleTypes).not.to.be.empty;
|
|
66
70
|
config.includeConsoleTypes.forEach(function (_includeConsoleType) {
|
|
67
|
-
chai.expect(ConsoleType_1.someConsoleType(_includeConsoleType), "includeConsoleTypes '"
|
|
71
|
+
return chai.expect((0, ConsoleType_1.someConsoleType)(_includeConsoleType), "includeConsoleTypes '".concat(_includeConsoleType, "' is an unknown ConsoleType")).to.be.true;
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
};
|
|
71
75
|
exports.validateConfig = validateConfig;
|
|
72
76
|
var createConfig = function (config) {
|
|
73
77
|
var _a;
|
|
74
|
-
return {
|
|
78
|
+
return ({
|
|
75
79
|
excludeMessages: config.excludeMessages,
|
|
76
|
-
includeConsoleTypes: ((_a = config.includeConsoleTypes) === null || _a === void 0 ? void 0 : _a.length)
|
|
80
|
+
includeConsoleTypes: ((_a = config.includeConsoleTypes) === null || _a === void 0 ? void 0 : _a.length)
|
|
81
|
+
? config.includeConsoleTypes
|
|
77
82
|
: [ConsoleType_1.ConsoleType.ERROR],
|
|
78
|
-
};
|
|
83
|
+
});
|
|
79
84
|
};
|
|
80
85
|
exports.createConfig = createConfig;
|
|
81
86
|
var createSpies = function (config, console) {
|
|
@@ -93,12 +98,10 @@ var resetSpies = function (spies) {
|
|
|
93
98
|
return spies;
|
|
94
99
|
};
|
|
95
100
|
exports.resetSpies = resetSpies;
|
|
96
|
-
var someSpyCalled = function (spies) {
|
|
97
|
-
return Array.from(spies.values()).some(function (value) { return value.called; });
|
|
98
|
-
};
|
|
101
|
+
var someSpyCalled = function (spies) { return Array.from(spies.values()).some(function (value) { return value.called; }); };
|
|
99
102
|
exports.someSpyCalled = someSpyCalled;
|
|
100
103
|
var getIncludedSpy = function (spies, config) {
|
|
101
|
-
return Array.from(spies.values()).find(function (spy) { return spy.called && exports.someIncludedCall(spy, config); });
|
|
104
|
+
return Array.from(spies.values()).find(function (spy) { return spy.called && (0, exports.someIncludedCall)(spy, config); });
|
|
102
105
|
};
|
|
103
106
|
exports.getIncludedSpy = getIncludedSpy;
|
|
104
107
|
var someIncludedCall = function (spy, config) {
|
|
@@ -106,7 +109,7 @@ var someIncludedCall = function (spy, config) {
|
|
|
106
109
|
return true;
|
|
107
110
|
}
|
|
108
111
|
return spy.args.some(function (call) {
|
|
109
|
-
return !exports.isExcludedMessage(config.excludeMessages, exports.callToString(call));
|
|
112
|
+
return !(0, exports.isExcludedMessage)(config.excludeMessages, (0, exports.callToString)(call));
|
|
110
113
|
});
|
|
111
114
|
};
|
|
112
115
|
exports.someIncludedCall = someIncludedCall;
|
|
@@ -124,7 +127,7 @@ var callToString = function (calls) {
|
|
|
124
127
|
var _currentValue = typeof currentValue === 'string'
|
|
125
128
|
? currentValue
|
|
126
129
|
: (currentValue === null || currentValue === void 0 ? void 0 : currentValue.message) || JSON.stringify(currentValue);
|
|
127
|
-
return previousValue
|
|
130
|
+
return "".concat(previousValue, " ").concat(_currentValue);
|
|
128
131
|
}, '')
|
|
129
132
|
.trim();
|
|
130
133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-fail-on-console-error",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "fail cypress test on console error",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "rm -rf dist/ && tsc",
|
|
12
12
|
"prettier": "prettier --write '**/*'",
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "npm run test:ut && npm run test:it",
|
|
14
|
+
"test:ut": "ts-mocha test/unitTest.ts",
|
|
15
|
+
"test:ut:debug": "ts-mocha --inspect-brk test/unitTest.ts",
|
|
16
|
+
"test:it": "ts-mocha test/integrationTest.ts --timeout 60000",
|
|
17
|
+
"test:it:debug": "cypress open",
|
|
14
18
|
"verify": "npm run build && npm run prettier && npm run test",
|
|
15
|
-
"
|
|
16
|
-
"debug:it": "cypress open"
|
|
19
|
+
"ci:prettier": "prettier --check '**/*'"
|
|
17
20
|
},
|
|
18
21
|
"repository": {
|
|
19
22
|
"type": "git",
|
|
@@ -31,21 +34,21 @@
|
|
|
31
34
|
},
|
|
32
35
|
"homepage": "https://github.com/nils-hoyer/cypress-fail-on-console-error#readme",
|
|
33
36
|
"dependencies": {
|
|
34
|
-
"chai": "^4.3.
|
|
35
|
-
"sinon": "^
|
|
36
|
-
"sinon-chai": "^3.
|
|
37
|
+
"chai": "^4.3.4",
|
|
38
|
+
"sinon": "^14.0.0",
|
|
39
|
+
"sinon-chai": "^3.7.0"
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
39
|
-
"@types/chai": "
|
|
40
|
-
"@types/expect": "
|
|
41
|
-
"@types/mocha": "
|
|
42
|
-
"@types/sinon": "
|
|
43
|
-
"@types/sinon-chai": "
|
|
44
|
-
"cypress": "
|
|
45
|
-
"mocha": "
|
|
46
|
-
"prettier": "
|
|
47
|
-
"prettier-plugin-organize-imports": "
|
|
48
|
-
"ts-mocha": "
|
|
49
|
-
"typescript": "
|
|
42
|
+
"@types/chai": "4.3.1",
|
|
43
|
+
"@types/expect": "24.3.0",
|
|
44
|
+
"@types/mocha": "9.1.1",
|
|
45
|
+
"@types/sinon": "10.0.11",
|
|
46
|
+
"@types/sinon-chai": "3.2.8",
|
|
47
|
+
"cypress": "9.7.0",
|
|
48
|
+
"mocha": "10.0.0",
|
|
49
|
+
"prettier": "2.6.2",
|
|
50
|
+
"prettier-plugin-organize-imports": "2.3.4",
|
|
51
|
+
"ts-mocha": "10.0.0",
|
|
52
|
+
"typescript": "4.7.2"
|
|
50
53
|
}
|
|
51
54
|
}
|