Accept non-process arguments in functions for easier testing
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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