pkgjs / wiby

"Will I break you" - a tool for testing dependents
Apache License 2.0
33 stars 7 forks source link

Add tests for CLI interface #30

Closed rodion-arr closed 4 years ago

rodion-arr commented 4 years ago

- bin script refactored to be able to run cli and get output from tests - calls to actual commands logic are mocked (only commands and options interfaces are under test) - add sinon as mocking lib

Update after suggestions below:

Closes #26

rodion-arr commented 4 years ago

@ljharb The first idea was to invoke bin with 'exec' like it was implemented in 'support' but in this case I don't see possibilities to inject mocks

ljharb commented 4 years ago

What mocks are needed? Could we use something like nock to handle it?

rodion-arr commented 4 years ago

General idea was to check that relevant function was called without really invoking it and do real requests to GitHub API while just checking that all passed to CLI options are correct.

https://github.com/rodion-arr/wiby/commit/091fc1fe5b75c201d066abc861a12c086d23d704#diff-583d616f4b01bf1fa153e71c0cef7de7R26-R29

ljharb commented 4 years ago

it seems like we should be able to mock out the network requests with something like nock or vcr, and then exec the binary directly?

rodion-arr commented 4 years ago

I got the point, I'll rollback the bin changes and try another approach. Thanks for suggestions 🤝

rodion-arr commented 4 years ago

@ljharb, I tried nock and it is not working with child processes (https://github.com/nock/nock/issues/990) Could you please send a link for what you called vcr, so I can try those one? I'm going to play with this package but it seems not very fresh - https://www.npmjs.com/package/node-vcr

ljharb commented 4 years ago

ah, vcr is a rails thing, and i think nock is what i had in mind. however, you can pass nock env vars into NODE_OPTIONS, which the child process's node should respect, including --require?

rodion-arr commented 4 years ago

Thanks, will try

rodion-arr commented 4 years ago

@dominykas could you please rerun tests? It was failed due to rate limits

dominykas commented 3 years ago

:tada: This PR is included in version 0.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: