diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3806bed..3584628a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,11 +25,11 @@ jobs: run: yarn ci:build - name: test summary - uses: dorny/test-reporter@1a288b62f8b75c0f433cbfdbc2e4800fbae50bd7 + uses: phoenix-actions/test-reporting@v15 if: ${{ (success() || failure()) && github.repository == 'mistic100/Photo-Sphere-Viewer' }} with: name: build - use-actions-summary: true + output-to: step-summary path: 'packages/*/reports/mocha.json' reporter: mocha-json @@ -55,16 +55,18 @@ jobs: if: ${{ (success() || failure()) && github.repository == 'mistic100/Photo-Sphere-Viewer' }} with: name: e2e-report-${{ github.ref_name }}-${{ env.SHORT_SHA }} - path: cypress/reports/html + path: | + cypress/reports/html + !cypress/reports/html/.jsons - name: test summary - uses: dorny/test-reporter@1a288b62f8b75c0f433cbfdbc2e4800fbae50bd7 + uses: phoenix-actions/test-reporting@v15 if: ${{ (success() || failure()) && github.repository == 'mistic100/Photo-Sphere-Viewer' }} with: name: e2e - use-actions-summary: true - path: cypress/reports/e2e.json - reporter: mocha-json + output-to: step-summary + path: 'cypress/reports/html/.jsons/*.json' + reporter: mochawesome-json build-doc: runs-on: ubuntu-latest diff --git a/build/mocha-reporter.js b/build/mocha-reporter.js index 8ecb23be..621a1742 100644 --- a/build/mocha-reporter.js +++ b/build/mocha-reporter.js @@ -1,7 +1,5 @@ const BaseReporter = require('mocha/lib/reporters/base'); const SpecReporter = require('mocha/lib/reporters/spec'); -const path = require('path'); -const fs = require('fs'); module.exports = class MultiReporter extends BaseReporter { constructor(runner, options) { @@ -11,11 +9,9 @@ module.exports = class MultiReporter extends BaseReporter { if (options.reporterOptions?.cypress) { const MochawesomeReporter = require('cypress-mochawesome-reporter/lib/reporter'); - this.mochawesome = new MochawesomeReporter(runner, {}); - - new CypressJsonReporter(runner, { - reporterOption: { - output: 'cypress/reports/e2e.json', + this.mochawesome = new MochawesomeReporter(runner, { + reporterOptions: { + reportFilename: '[name]', }, }); } else { @@ -36,87 +32,3 @@ module.exports = class MultiReporter extends BaseReporter { } } }; - -// custom json reporter for cypress (for some reason, calling JsonReporter does not work) -// - write the results to a json file -// - fill the "file" property of each test -function CypressJsonReporter(runner, options) { - BaseReporter.call(this, runner, options); - - const tests = []; - const pending = []; - const failures = []; - const passes = []; - - runner.on('test end', function (test) { - tests.push(test); - }); - - runner.on('pass', function (test) { - passes.push(test); - }); - - runner.on('fail', function (test) { - failures.push(test); - }); - - runner.on('pending', function (test) { - pending.push(test); - }); - - runner.once('end', () => { - const obj = { - stats: this.stats, - tests: tests.map(clean), - pending: pending.map(clean), - failures: failures.map(clean), - passes: passes.map(clean), - }; - const json = JSON.stringify(obj, null, 2); - const output = options.reporterOption.output; - fs.mkdirSync(path.dirname(output), { recursive: true }); - fs.writeFileSync(output, json); - }); - - function clean(test) { - let err = test.err || {}; - if (err instanceof Error) { - err = errorJSON(err); - } - - return { - title: test.title, - fullTitle: test.fullTitle(), - file: test.invocationDetails.absoluteFile, - duration: test.duration, - currentRetry: test.currentRetry(), - speed: test.speed, - err: cleanCycles(err), - }; - } - - function cleanCycles(obj) { - let cache = []; - return JSON.parse( - JSON.stringify(obj, (key, value) => { - if (typeof value === 'object' && value !== null) { - if (cache.indexOf(value) !== -1) { - // Instead of going in a circle, we'll print [object Object] - return '' + value; - } - cache.push(value); - } - - return value; - }) - ); - } - - function errorJSON(err) { - let res = {}; - Object.getOwnPropertyNames(err).forEach((key) => { - res[key] = err[key]; - }, err); - return res; - } -} diff --git a/cypress.config.ts b/cypress.config.ts index cb9d1b0f..96bd2339 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -53,5 +53,8 @@ export default defineConfig({ reporter: 'build/mocha-reporter.js', reporterOptions: { cypress: true, + // cypress-mochawesome-reporter + removeJsonsFolderAfterMerge: false, + cdn: true, }, }); diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 04d7d508..0002ec42 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -3,7 +3,7 @@ import 'cypress-real-events'; import { addCompareSnapshotCommand } from 'cypress-visual-regression/dist/command'; addCompareSnapshotCommand({ - errorThreshold: 0.01, + errorThreshold: 0.1, failSilently: !Cypress.config('isInteractive'), });