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.
@@ -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
- custom-test-results:
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
@@ -0,0 +1,5 @@
1
+ {
2
+ "trailingComma": "es5",
3
+ "semi": true,
4
+ "singleQuote": true
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-plugin-last-failed",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Cypress plugin to rerun last failed tests in cypress run and open mode",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
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
- const reports = [];
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
- const testTitle = testCopy.pop(); // Extract the test title
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
- return reports;
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 };