-
Notifications
You must be signed in to change notification settings - Fork 442
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
Better Tests #125
Comments
You can see what I mean by the separation of logic here: https://github.com/ThisIsMissEm/cz-conventional-changelog/pull/1/files#diff-168726dbe96b3ce427e7fedce31bb0bcR94 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been working on a new feature for cz-conventional-changelog (related to #118 ), and I've noticed that all of the tests essentially fake out inquirer, which means that logic like
when
in inquirer prompts wasn't respected. An alternative testing strategy would be to assume that the inquirer module works as expected and then work with the stdin/stdout streams to do more integration-style testing.If we assume that git-cz correctly injects an inquirer instance into this module when calling
engine(options).prompter(inquirer, commit)
, then we can actually write tests with:Where
readableStream
andwriteableStream
are as defined in the node.js Streams documentation.The article linked above actually uses the enquirer module, not inquirer, which has a
prompt.keypress
method to send data in during tests.For now, I'm considering this as being far too an extensive piece of work to do in my pull request, but would allow us to better test cz-conventional-changelog by having proper regression tests. I have already done a bunch of work to separate the loading of options from the loading of the module, such that the option handling can be tested without mocking out external modules too much (just
@commitlint/load
)The text was updated successfully, but these errors were encountered: