Skip to content

Add ability to mock out process.stdout calls #118

@jeffrafter

Description

@jeffrafter

Currently issueCommand always outputs to stdout here: https://github.com/actions/toolkit/blob/master/packages/core/src/command.ts#L25. This is great but when writing tests for actions it quickly fills up the logs:

> @ test /Users/njero/Code/Examples/example-github-action-typescript
> jest

 PASS  .github/actions/debug-action/__tests__/debug.test.ts
  debug action debug messages
    ✓ outputs a debug message (5ms)

##[debug]👋 Hello! You are an amazing person! 🙌
##[debug]👋 Hello! You are an amazing person! 🙌
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.423s
Ran all test suites.

If the output was wrapped in a call on the Command object itself then it could be mocked in the jest setup. Additionally this might pave the way for alternate logging outputs down the road.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions