cypress-plugin-last-failed 2.0.3 โ 2.0.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/.github/workflows/main.yml +25 -2
- package/.prettierrc +5 -0
- package/package.json +1 -1
- package/src/index.js +20 -5
|
@@ -7,7 +7,7 @@ on:
|
|
|
7
7
|
workflow_dispatch:
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
|
-
default-test-results:
|
|
10
|
+
default-dir-test-results:
|
|
11
11
|
runs-on: ubuntu-22.04
|
|
12
12
|
steps:
|
|
13
13
|
- name: Checkout ๐ฆ
|
|
@@ -26,7 +26,30 @@ jobs:
|
|
|
26
26
|
# environment variable used for CI/CD tests in this repo
|
|
27
27
|
command: npx cypress-plugin-last-failed run --env shouldPass=true
|
|
28
28
|
working-directory: ${{ github.workspace }}
|
|
29
|
-
|
|
29
|
+
burn-test-results:
|
|
30
|
+
runs-on: ubuntu-22.04
|
|
31
|
+
steps:
|
|
32
|
+
- name: Checkout ๐ฆ
|
|
33
|
+
uses: actions/checkout@v4
|
|
34
|
+
- name: Cypress run - run burn=10 ๐ฅ
|
|
35
|
+
uses: cypress-io/github-action@v6
|
|
36
|
+
with:
|
|
37
|
+
# using cy-grep plugin burn test feature
|
|
38
|
+
command: npx cypress run --env burn=10
|
|
39
|
+
working-directory: ${{ github.workspace }}
|
|
40
|
+
continue-on-error: true
|
|
41
|
+
- name: Output the file contents ๐
|
|
42
|
+
if: always()
|
|
43
|
+
run: |
|
|
44
|
+
cat ./test-results/last-run.json
|
|
45
|
+
- name: Run failed tests from default directory ๐งช
|
|
46
|
+
if: always()
|
|
47
|
+
uses: cypress-io/github-action@v6
|
|
48
|
+
with:
|
|
49
|
+
# environment variable used for CI/CD tests in this repo
|
|
50
|
+
command: npx cypress-plugin-last-failed run --env shouldPass=true
|
|
51
|
+
working-directory: ${{ github.workspace }}
|
|
52
|
+
custom-dir-test-results:
|
|
30
53
|
runs-on: ubuntu-22.04
|
|
31
54
|
steps:
|
|
32
55
|
- name: Checkout ๐ฆ
|
package/.prettierrc
ADDED
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const collectFailingTests = (on, config) => {
|
|
|
26
26
|
|
|
27
27
|
const spec = run.spec.relative;
|
|
28
28
|
|
|
29
|
-
failedTests = failedTests.concat(generateReports(tests, spec));
|
|
29
|
+
failedTests = failedTests.concat(generateReports(tests, spec, config));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -48,12 +48,16 @@ const collectFailingTests = (on, config) => {
|
|
|
48
48
|
return collectFailingTests;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const generateReports = (tests, spec) => {
|
|
52
|
-
|
|
51
|
+
const generateReports = (tests, spec, config) => {
|
|
52
|
+
let reports = [];
|
|
53
53
|
for (const test of tests) {
|
|
54
54
|
const testCopy = [...test]; // Create a copy of the array to avoid mutation
|
|
55
|
-
|
|
55
|
+
let testTitle = testCopy.pop(); // Extract the test title
|
|
56
56
|
if (testTitle) {
|
|
57
|
+
// If --env burn=X is set from cy-grep, remove the ": burning X of X"
|
|
58
|
+
testTitle = config.env.burn
|
|
59
|
+
? testTitle.replace(/: burning .* of .*/, '')
|
|
60
|
+
: testTitle;
|
|
57
61
|
const report = {
|
|
58
62
|
spec: spec,
|
|
59
63
|
parent: testCopy, // Parent titles
|
|
@@ -62,7 +66,18 @@ const generateReports = (tests, spec) => {
|
|
|
62
66
|
reports.push(report);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
|
-
|
|
69
|
+
// If --env burn=X is set from cy-grep, remove the duplicate test objects
|
|
70
|
+
if (config.env.burn) {
|
|
71
|
+
const seen = new Set();
|
|
72
|
+
const filteredReports = reports.filter((el) => {
|
|
73
|
+
const duplicate = seen.has(el.test);
|
|
74
|
+
seen.add(el.test);
|
|
75
|
+
return !duplicate;
|
|
76
|
+
});
|
|
77
|
+
return filteredReports;
|
|
78
|
+
} else {
|
|
79
|
+
return reports;
|
|
80
|
+
}
|
|
66
81
|
};
|
|
67
82
|
|
|
68
83
|
module.exports = { collectFailingTests, failedTestToggle };
|