Comments (4)
Yeah, would definitely be into this. I wanted to keep the CLI pretty minimal just to have "something" so I'm all for improvements. I've used Inquirer in the past, but I'm open to either one (or any other alternative).
The Dockerfile labels are a great start too 👌 if you're interested in a PR for this, go for it ✨
from actions-toolkit.
Awesome, I'll look to PR something soon!
I want to add some CLI tests but am having trouble figuring out an approach moving forward.
In a local branch, I added a tests/cli.test.ts
file:
import execa from 'execa'
describe('CLI', () => {
it('displays help when passed no arguments', () => {
return execa('node', [require.resolve('../bin/actions-toolkit.js')]).catch(error => {
expect(error.code).toBe(1)
expect(error.message).toMatch(/Usage: npx actions-toolkit <name>/)
})
})
})
This test passes, but Jest shows the following warning:
(node:42520) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
I don't know if that's something to worry about and continue to write CLI integration tests like this (mocking out the filesystem, process, etc. as needed on a per test basis), or if it would make more sense to refactor the CLI into a class, and then have the executable create the class and call a method - something roughly like:
// bin/ActionsToolkit.js
module.exports = class ActionsToolkit {
constructor(argv) {
this.args = parseArgs(argv)
}
async run() {
if (!this.args.name) {
this.printHelp()
exit(1)
}
// do more stuff!
}
}
// bin/cli.js
new ActionsToolkit(process.argv[2]).run()
This might be more testable to an extent, but it may not be a true integration test, since we wouldn't fully be testing the argument collection from process.argv
. 🤔
Do you have any suggestions for testing CLIs? Will do some researching, but not sure if you have a specific experience or approach in mind that would help here. 😄
from actions-toolkit.
I'm fine with tests that are a lot less specific and just mock inquirer
a la jest.mock('inquirer')
. I don't have much experience testing CLI tools, so I'm up for some exploration! I did find these two issues asking about Inquirer test paradigms, and the general response was "Just mock it."
This test passes, but Jest shows the following warning:
(node:42520) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
I don't think this is specific to your new test 😞 it's just there for all tests, gotta fix that up.
from actions-toolkit.
I don't think this is specific to your new test 😞 it's just there for all tests, gotta fix that up.
I opened up #56 to tackle that memory leak warning separately. 💟
from actions-toolkit.
Related Issues (20)
- Latest @octokit/rest has a .graphql method so no need to add it HOT 1
- Error regarding missing js-yaml dependency HOT 4
- File readme.md could not be found in your project's workspace HOT 2
- Can we set outputs ? HOT 2
- Integrate Signale logs with GH actions syntax HOT 6
- tolkit
- Specify some input or env that allows a user to override the default GITHUB_REPOSITORY env var HOT 4
- Support use with GitHub Enterprise servers HOT 3
- Stop warning about `HOME` not being present on Windows runners HOT 4
- Add a `secrets` option to the constructor HOT 3
- Not all feather icons are supported by actions HOT 7
- Debug mode HOT 1
- ✖ fatal HttpError: Bad credentials HOT 5
- minimist argument as string with space breaking HOT 13
- Specific events causes error logs HOT 5
- Creating a pull request review HOT 9
- Note about Architectural Context & Added Value HOT 2
- @octokit/graphql types HOT 3
- Ability to leverage graphql previews of the API is not advertised in README
- Logging Issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actions-toolkit.