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

Add low-level print configuration option. #130

Merged
merged 1 commit into from
Apr 13, 2017
Merged

Conversation

johnjbarton
Copy link
Contributor

Defaults to console.log. Set to function process.stdout.write(log + '\n'); to avoid output to
devtools console while still reporting jasmine results to command line.

@johnjbarton
Copy link
Contributor Author

Three tests do not pass, but let me see if you are up for this kind of change before I invest more time to fix them.

@bcaudan
Copy link
Owner

bcaudan commented Apr 8, 2017

It is a great option, go for it!

@johnjbarton
Copy link
Contributor Author

Ready for review.

@codecov
Copy link

codecov bot commented Apr 11, 2017

Codecov Report

Merging #130 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #130   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          14     14           
  Lines         411    413    +2     
  Branches       54     54           
=====================================
+ Hits          411    413    +2
Impacted Files Coverage Δ
src/configuration-parser.ts 100% <100%> (ø) ⬆️
src/spec-reporter.ts 100% <100%> (ø) ⬆️
src/display/logger.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3782b6f...bf404a0. Read the comment docs.

@@ -19,6 +19,8 @@ export class ConfigurationParser {
pending: "* ",
successful: ConfigurationParser.isWindows ? "\u221A " : "✓ ",
},
// tslint:disable-next-line:no-unbound-method
print: console.log,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to reference directly console.log?
By using a wrapper we could spare us the console.log mock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestHelper needs to mock the default print feature so the (non-custom-print) tests can examine the reporter output. ConfigurationParser needs a default print feature. So we need some place where TestHelper and ConfigurationParser can agree to use for the default print feature. They current agree on the global "console.log".

We could use another global, or we could add a static to any class. TestHelper needs to access that wrapper to overwrite it for mocking.

I took a stab, is this what you have in mind?

The other way to go is to have TestHelper overwrite this.reporter.print

Copy link
Owner

@bcaudan bcaudan Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that console.log was already instrumented for non-custom-print tests, so I wondered why do we need to also mock it.

My understanding is that we need to do that because we are referencing directly the console.log function in:

print: console.log

Then, we need to instrument the console.log function before the execution of configuration-parser.ts.

If we use a console.log wrapper for the print function:

print: stuff => console.log(stuff)

Then, we would not have the need to early mock the log function and the previous instrumentation should be enough.

Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, better!

Defaults to console.log. Set to function process.stdout.write(log + '\n'); to avoid output to
devtools console while still reporting jasmine results to command line.
@bcaudan
Copy link
Owner

bcaudan commented Apr 13, 2017

Available in [email protected]

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.

2 participants