Skip to content
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

Fix test for yarn licenses generate-disclaimer output #5385

Merged
merged 3 commits into from
Feb 28, 2018
Merged

Fix test for yarn licenses generate-disclaimer output #5385

merged 3 commits into from
Feb 28, 2018

Conversation

sth
Copy link
Contributor

@sth sth commented Feb 21, 2018

Summary

There is a test that attempts to test that license files are show correctly for yarn licenses generate-disclaimer. The test currently just prints the license files to the console and doesn't verify what was printed. This pull request modifies the test to not show unwanted output during testing and to actually test that the output is correct.

Implementation

The normal method of capturing output isn't sufficient to capture the output of yarn licenses generate-disclaimer, since that command intentionally uses console.log() directly. Because of this a special helper function is used that mocks console.log() and lets the test verify what was written.

Test plan

The licenses.js.snap, which is used to verify the commands output, now contains the license text we expect to be printed. The test passes using this .snap file.

Additional change

I also renamed the "lists all licenses of the dependencies with the --json argument" test in the same file because it doesn't seem to involve any --json argument.

The command writes it's output with console.log(), intentionally.
The tests should capture that output and verify that it's correct.
@arcanis arcanis merged commit d52ce66 into yarnpkg:master Feb 28, 2018
@arcanis
Copy link
Member

arcanis commented Feb 28, 2018

Sounds good 👍

@sth sth deleted the tests-capture-license-output branch February 28, 2018 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants