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

WIP migrate from c8/mocha to native node test runner #195

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chris48s
Copy link
Member

This was an interesting experiment: Can I replace c8/mocha with the native node test runner.

Some learnings:

  • Ideally I'd like to exclude the .test.js files from the coverage reports. This can be done with --test-coverage-exclude but this is not available until node 22.
  • I would really like the coverage reports to include action.js, even though it is not under test. Even using --test-coverage-include I was not able to do this.
  • The best available machine-readable coverage output format seems to be --test-reporter junit

Probably not going to immediately migrate but it is good to check in on what this looks like.

Copy link

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/[email protected], npm/[email protected]

View full report↗︎

@@ -89,6 +90,7 @@ describe("PackageJsonNodeVersion", function () {
describe("getAction", function () {
afterEach(function () {
delete process.env["INPUT_INTEGRATION"];
process.exitCode = undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

The reason for doing this is:

setFailed() sets process.exitCode
https://github.com/actions/toolkit/blob/bb2278e5cfbb40afc20890c415e9ffa836631cd5/packages/core/src/core.ts#L220-L224

Unlike Mocha, this causes Node's test runner to consider the test failed, even if it happened inside a assert.throws()

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.

1 participant