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

td.reset(thingsBlewUpSoPleaseLogWarnings=true) #162

Open
searls opened this issue Dec 12, 2016 · 7 comments
Open

td.reset(thingsBlewUpSoPleaseLogWarnings=true) #162

searls opened this issue Dec 12, 2016 · 7 comments

Comments

@searls
Copy link
Member

searls commented Dec 12, 2016

Proposal: a new top-level method designed to be run in an afterEach block of the user's tests, and passed a boolean as to whether or not the test failed.

When td.reset(true) is called, td.js will log a warning to the console that contains a summary of the state of all the test doubles known to it since the last reset, including what they were all invoked with.

Like #161, this would be organized stubbying-by-stubbing ("this stubbing was never satisfied (red flag!)", and "this stubbing was satisfied by these three calls: [list]"`

Not all tests allow for this, but many do. And for those that don't, the user could set the var themselves to manually introspect like so: afterEach(() => td.whatWentWrong(process.env.UGH))

I think this could be a solution to all the issues where people want to sprinkle in td.verify() calls for better messages alone like #148 & #138

@searls searls added this to the Much better messages milestone Dec 12, 2016
@Schoonology
Copy link
Contributor

What's the timing of these messages now? On reset? Never?

@searls
Copy link
Member Author

searls commented Dec 12, 2016

There are no messages for stubbings (when would there be?)

@Schoonology
Copy link
Contributor

Schoonology commented Dec 12, 2016

Is this something we can do during reset? Otherwise, I fear whatWentWrong would just become a part of some afterEach boilerplate.

@searls
Copy link
Member Author

searls commented Dec 12, 2016

Sure! This could be a flag you send to reset, so that reset(true) could print the warnings

@searls searls changed the title td.whatWentWrong() td.reset(thingsBlewUpSoPleaseLogWarnings=true) Dec 12, 2016
@Schoonology
Copy link
Contributor

That, or even an option: reset({ printReport: true })

I think reset could be a good place to put these kinds of features in the future. It has little effect on the test practice or test quality.

@searls
Copy link
Member Author

searls commented Dec 12, 2016

Yeah, agree, we probably shouldn't throw a mystery meat boolean at an unrelated-looking method. I think this is the right approach. Is console.log/warn the right mechanism for getting folks that report?

@Schoonology
Copy link
Contributor

Probably. The only issue I can think of would be with unix pipes, but I think that was resolved.

(It used to be that node script-with-console-log.js | whatever would blow up.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
td.js 2.0
Backlog
Development

No branches or pull requests

2 participants