@koenvanbelle/cypress-soft-assertions 1.0.8 → 1.0.9
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/dist/index.js +27 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27,6 +27,28 @@ function captureSoftAssertion(error) {
|
|
|
27
27
|
stack
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
function getCurrentCommandName() {
|
|
31
|
+
var _a;
|
|
32
|
+
const state = cy === null || cy === void 0 ? void 0 : cy.state;
|
|
33
|
+
if (typeof state !== 'function') {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
const current = state('current');
|
|
37
|
+
if (!current) {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
if (typeof current.get === 'function') {
|
|
41
|
+
return String(current.get('name') || '');
|
|
42
|
+
}
|
|
43
|
+
return String(current.name || ((_a = current.attributes) === null || _a === void 0 ? void 0 : _a.name) || '');
|
|
44
|
+
}
|
|
45
|
+
function isRetryTimeoutError(error) {
|
|
46
|
+
const message = String((error === null || error === void 0 ? void 0 : error.message) || '');
|
|
47
|
+
return /Timed out retrying after/i.test(message);
|
|
48
|
+
}
|
|
49
|
+
function isRetriableAssertionCommand(commandName) {
|
|
50
|
+
return commandName === 'should' || commandName === 'and';
|
|
51
|
+
}
|
|
30
52
|
/**
|
|
31
53
|
* Intercept Cypress failures and make assertion failures soft in soft_it() tests.
|
|
32
54
|
*/
|
|
@@ -36,6 +58,11 @@ function setupSoftAssertions() {
|
|
|
36
58
|
if (!isInSoftTest) {
|
|
37
59
|
throw error;
|
|
38
60
|
}
|
|
61
|
+
const commandName = getCurrentCommandName();
|
|
62
|
+
if (isRetriableAssertionCommand(commandName) && !isRetryTimeoutError(error)) {
|
|
63
|
+
// Let Cypress continue polling/retrying for retriable assertions.
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
39
66
|
captureSoftAssertion(error);
|
|
40
67
|
return false;
|
|
41
68
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koenvanbelle/cypress-soft-assertions",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "A Cypress plugin that provides soft_it() for soft assertions - all assertions continue on failure and are reported together",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|