Skip to content

Commit

Permalink
publish results
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Oct 17, 2024
1 parent 01cbf46 commit 2a8b8e3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
- name: build
run: yarn ci:build

- uses: dorny/test-reporter@v1
if: ${{ (success() || failure()) && github.repository == 'mistic100/Photo-Sphere-Viewer' }}
with:
name: tests-results
path: reports/*.json
reporter: mocha-json

e2e:
if: ${{ !startsWith(github.ref_name, 'dependabot') }}

Expand All @@ -44,9 +51,9 @@ jobs:
- uses: dorny/test-reporter@v1
if: ${{ (success() || failure()) && github.repository == 'mistic100/Photo-Sphere-Viewer' }}
with:
name: test-results
path: cypress/reports/junit/*.xml
reporter: java-junit
name: e2e-results
path: reports/*.json
reporter: mocha-json

# build-doc:
# runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ docs/.vitepress/.temp
!docs/.typedoc
dist
/public
cypress/reports
/reports
cypress/screenshots
5 changes: 5 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const path = require('path');

module.exports = {
reporter: path.join(__dirname, 'build/mocha-reporter.js'),
};
23 changes: 23 additions & 0 deletions build/mocha-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const BaseReporter = require('mocha/lib/reporters/base');
const SpecReporter = require('mocha/lib/reporters/spec');
// Cypress breaks the reporter ?
// https://github.com/cypress-io/cypress/issues/27636
const JsonReporter = require('../node_modules/mocha/lib/reporters/json.js');
const path = require('path');

module.exports = class MultiReporter extends BaseReporter {
constructor(runner, options) {
super(runner, options);

// mocha uses "reporterOption", cypress uses "reporterOptions"
const title = options.reporterOption?.title ?? options.reporterOptions?.title ?? 'report';

new SpecReporter(runner, {});

new JsonReporter(runner, {
reporterOption: {
output: path.join(__dirname, '../reports', `${title}.json`),
},
});
}
};
4 changes: 2 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default defineConfig({
scrollBehavior: false,
screenshotOnRunFailure: false,
},
reporter: 'mocha-junit-reporter',
reporter: 'build/mocha-reporter.js',
reporterOptions: {
mochaFile: 'cypress/reports/junit/report.xml',
title: 'e2e',
},
});
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "tsup",
"watch": "tsup --watch",
"lint": "tsc --noEmit && eslint . --fix && stylelint \"src/**/*.scss\" --fix",
"test": "mocha -r ts-node/register \"src/**/*.spec.ts\"",
"test": "mocha -r ts-node/register \"src/**/*.spec.ts\" -O title=core",
"publish-dist": "cd dist && npm publish --tag=$NPM_TAG --access=public",
"npm-link": "cd dist && npm link"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"scripts": {
"lint": "tsc --noEmit && eslint . --fix && stylelint \"*.scss\" --fix",
"test": "mocha -r ts-node/register \"**/*.spec.ts\""
"test": "mocha -r ts-node/register \"**/*.spec.ts\" -O title=shared"
}
}

0 comments on commit 2a8b8e3

Please sign in to comment.