diff --git a/.github/workflows/example-component-test.yml b/.github/workflows/example-component-test.yml index 38bc848b8..6d4f3539d 100644 --- a/.github/workflows/example-component-test.yml +++ b/.github/workflows/example-component-test.yml @@ -7,7 +7,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Cypress run - uses: cypress-io/github-action@4 + uses: cypress-io/github-action@v4 with: working-directory: examples/v10/component-tests component: true diff --git a/dist/index.js b/dist/index.js index db52ee455..0a3eae661 100644 --- a/dist/index.js +++ b/dist/index.js @@ -75355,9 +75355,46 @@ const runTests = async () => { process.chdir(workingDirectory) return cypress .run(cypressOptions) + .then(generateSummary) .then(onTestsFinished, onTestsError) } +const generateSummary = async (testResults) => { + const headers = [ + { data: 'Result', header: true }, + { data: 'Passed :white_check_mark:', header: true }, + { data: 'Failed :x:', header: true }, + { data: 'Pending :hand:', header: true }, + { data: 'Skipped :leftwards_arrow_with_hook:', header: true }, + { data: 'Duration :clock8:', header: true } + ] + + const status = + testResults.totalFailed === 0 + ? 'Passing :white_check_mark:' + : 'Failing :red_circle:' + + const summaryRows = [ + status, + `${testResults.totalPassed}`, + `${testResults.totalFailed}`, + `${testResults.totalPending}`, + `${testResults.totalSkipped}`, + `${testResults.totalDuration / 1000}s` || '' + ] + + await core.summary + .addHeading('Cypress Results', 2) + .addTable([headers, summaryRows]) + .addLink( + testResults.runUrl ? 'View Run in Dashboard' : '', + testResults.runUrl || '' + ) + .write() + + return testResults +} + const installMaybe = () => { const installParameter = getInputBool('install', true) if (!installParameter) { diff --git a/index.js b/index.js index b3575b9c5..8ab5c9e71 100644 --- a/index.js +++ b/index.js @@ -745,9 +745,46 @@ const runTests = async () => { process.chdir(workingDirectory) return cypress .run(cypressOptions) + .then(generateSummary) .then(onTestsFinished, onTestsError) } +const generateSummary = async (testResults) => { + const headers = [ + { data: 'Result', header: true }, + { data: 'Passed :white_check_mark:', header: true }, + { data: 'Failed :x:', header: true }, + { data: 'Pending :hand:', header: true }, + { data: 'Skipped :leftwards_arrow_with_hook:', header: true }, + { data: 'Duration :clock8:', header: true } + ] + + const status = + testResults.totalFailed === 0 + ? 'Passing :white_check_mark:' + : 'Failing :red_circle:' + + const summaryRows = [ + status, + `${testResults.totalPassed}`, + `${testResults.totalFailed}`, + `${testResults.totalPending}`, + `${testResults.totalSkipped}`, + `${testResults.totalDuration / 1000}s` || '' + ] + + await core.summary + .addHeading('Cypress Results', 2) + .addTable([headers, summaryRows]) + .addLink( + testResults.runUrl ? 'View Run in Dashboard' : '', + testResults.runUrl || '' + ) + .write() + + return testResults +} + const installMaybe = () => { const installParameter = getInputBool('install', true) if (!installParameter) {