actions / actions/toolkit

Accept non-process arguments in functions for easier testing

Open
#1,904 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the enhancement
Maybe I missed something completely, but it'd be great for functions like core.getInput or core.setOutput to take a NodeJS.ProcessEnv object as an optional argument, defaulting to process.env, to make testing JS actions easier and cleaner.

Code Snippet
If your action code is something like

import * as core from "@actions/core";

const myInput = core.getInput("my_input_var"); 

it could be something like

import * as core from "@actions/core";

const myInput = core.getInput("my_input_var", undefined /* options */, {
  INPUT_MY_INPUT_VAR: "some-value",
});

Additional information
Again, if that's already possible, sorry for the extra toil!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @actions/core implementations for getInput and setOutput and their surrounding tests, then trace how process.env is accessed. Done means the relevant APIs accept an optional environment object while preserving existing defaults, with tests covering injected values.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.