Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circleci: publish test reports #570

Merged
merged 14 commits into from
Mar 18, 2024
Merged

Conversation

alxndrsn
Copy link
Contributor

No description provided.

@alxndrsn alxndrsn force-pushed the circle-ci-test-reports branch 2 times, most recently from a473ec1 to a55199c Compare September 26, 2022 08:30
@matthew-white
Copy link
Member

matthew-white commented Oct 26, 2022

I haven't looked deeply into this, but the idea of seeing test insights in CircleCI seems potentially useful! It sounds like it could help us identify intermittent test failures and slow tests.

@alxndrsn
Copy link
Contributor Author

alxndrsn commented Nov 18, 2022

I've rebased this onto latest master. Some additional thoughts:


@matthew-white would this be acceptable as-is? Is it worth trying to address points raised above?

@alxndrsn alxndrsn marked this pull request as ready for review November 18, 2022 13:48
@matthew-white
Copy link
Member

the current test output location seems esoteric (~/junit/)

That seems OK to me. 🤷

it's a shame that we don't get the standard text output as well as the JUnit XML output

I do think that that has the potential to make things harder to debug. With the current output, you can scroll up to a failed test to check whether there was any logging or an unhandled promise rejection before the test failure. But with the JUnit output, it looks like you just see the test failure and its associated stack trace. If there's a reasonable way to output both, that seems ideal. It's unfortunate though that Mocha doesn't support that out of the box. 😭

- run: make test-full

- run: mkdir ~/junit
- run: MOCHA_FILE=~/junit/test-results.xml make test-ci
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am interesting in the recent feature of CircleCI "rerunning failed tests", for that we would need this step to be:

      - run: 
          name: Run tests
          command: |
            mkdir test-results
            TEST_FILES=$(circleci tests glob "test/**/*.js")
            echo "$TEST_FILES" | circleci tests run --command="xargs npx mocha --exit --reporter mocha-junit-reporter --reporter-options mochaFile=./test-results/junit.xml"
      - store_test_results:
          path: test-results

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 that could be a good next step

@sadiqkhoja
Copy link
Contributor

sadiqkhoja commented Oct 11, 2023

How about using mocha-multi-reporters with mocha-junit-reporter? I am happy without text output as well

@alxndrsn
Copy link
Contributor Author

alxndrsn commented Mar 18, 2024

How about using mocha-multi-reporters with mocha-junit-reporter? I am happy without text output as well

I've implemented this directly - it turns out it's quite simple:

const mocha = require('mocha');
const MochaJunitReporter = require('mocha-junit-reporter');

module.exports = function CiMochaReporter(runner) {
  new mocha.reporters.Spec(runner);
  new MochaJunitReporter(runner);
};

@alxndrsn
Copy link
Contributor Author

@matthew-white @sadiqkhoja this is ready for review again.

  • test results are now stored in ./junit-reports/
  • normal text output and junit XML output are both included

Example failure at:

Copy link
Contributor

@sadiqkhoja sadiqkhoja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me

@alxndrsn alxndrsn merged commit 68e374e into getodk:master Mar 18, 2024
1 check passed
@alxndrsn alxndrsn deleted the circle-ci-test-reports branch March 18, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants