-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 'test verify' hook #287
Conversation
… after each test has run
What's the use-case |
Mocking / stubbing frameworks often have things like "make sure this function gets called". Obviously, they can't determine whether this has not happened until the test is complete. I originally put this sort of thing (a call to mockframework.verifyAll()) in an "after test" hook, but an exception thrown from there does not seem to fail the test properly. Also, that requires you to write mockframework.verifyAll() as an afterEach in at least every file, while ideally this would be something the framework hooks up for you (thus the runner hook). |
This issue has been inactive for over 1 month so I'm closing it. If you think it's still an issue re-open. - tjbot |
I still think it's an issue. Apparently I don't have permission to re-open this. Is that a bug, or am I really not allowed to reopen it? |
I like the idea of being able to fail the previous test within the afterEach hook, but if possible (should be) it would be nice to avoid the extra hook, even if it's just something lame like: afterEach(function(){
if (somethingFailed) this.test.fail(msg)
}) |
looks reasonable, I'll pull it down in a bit and have a look |
In version 1.2.1, support was added to fail test in the after each hook: > * Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore (or we don't understand how). In teaspoon this behaviour seems to be patched (running it with the exact same mocha.js 2.2.4 file, teaspoon and karma have different behaviour), although I couldn't quickly pinpoint the code that does that. This patch adds this behaviour back to the code base, but also seems to break certain behaviour (3 tests are failing with this pull request). But I don't understand what those test failures exactly mean. Also I found it quite difficult to add test coverage of this behaviour. Since there aren't any tests calling `runTests`. Help in figuring out what we've done wrong or how we could fix this pull request, would be appreciated. Not supporting this behaviour anymore due to added complexity in the code, would also be fine, but adding some documentation about dropping this functionality would be nice.
In version 1.2.1, support was added to fail test in the after each hook: > * Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore (or we don't understand how). In teaspoon this behaviour seems to be patched (running it with the exact same mocha.js 2.2.4 file, teaspoon and karma have different behaviour), although I couldn't quickly pinpoint the code that does that. This patch adds this behaviour back to the code base, but also seems to break certain behaviour (3 tests are failing with this pull request). But I don't understand what those test failures exactly mean. Also I found it quite difficult to add test coverage of this behaviour. Since there aren't any tests calling `runTests`. Help in figuring out what we've done wrong or how we could fix this pull request, would be appreciated. Not supporting this behaviour anymore due to added complexity in the code, would also be fine, but adding some documentation about dropping this functionality would be nice.
In version 1.2.1, support was added to fail test in the after each hook: > * Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore (or we don't understand how). In teaspoon this behaviour seems to be patched (running it with the exact same mocha.js 2.2.4 file, teaspoon and karma have different behaviour), although I couldn't quickly pinpoint the code that does that. This patch adds this behaviour back to the code base, but also seems to break certain behaviour (3 tests are failing with this pull request). But I don't understand what those test failures exactly mean. Also I found it quite difficult to add test coverage of this behaviour. Since there aren't any tests calling `runTests`. Help in figuring out what we've done wrong or how we could fix this pull request, would be appreciated. Not supporting this behaviour anymore due to added complexity in the code, would also be fine, but adding some documentation about dropping this functionality would be nice.
In version 1.2.1, support was added to fail test in the after each hook: > * Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore (or we don't understand how). In teaspoon this behaviour seems to be patched (running it with the exact same mocha.js 2.2.4 file, teaspoon and karma have different behaviour), although I couldn't quickly pinpoint the code that does that. This patch adds this behaviour back to the code base, but also seems to break certain behaviour (3 tests are failing with this pull request). But I don't understand what those test failures exactly mean. Also I found it quite difficult to add test coverage of this behaviour. Since there aren't any tests calling `runTests`. Help in figuring out what we've done wrong or how we could fix this pull request, would be appreciated. Not supporting this behaviour anymore due to added complexity in the code, would also be fine, but adding some documentation about dropping this functionality would be nice.
In version 1.2.1, support was added to fail test in the after each hook: >* Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore. That behaviour has been changed in: ebc6aee without any documentation change. If this was a conscious decision adding some documentation about dropping this functionality would then be nice. The old behaviour is documented in: https://github.com/mochajs/mocha/wiki/Conditionally-failing-tests-in-afterEach()-hooks .
In version 1.2.1, support was added to fail test in the after each hook: >* Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore. That behaviour has been changed in: ebc6aee without any documentation change. If this was a conscious decision adding some documentation about dropping this functionality would then be nice. The old behaviour is documented in: https://github.com/mochajs/mocha/wiki/Conditionally-failing-tests-in-afterEach()-hooks .
In version 1.2.1, support was added to fail test in the after each hook: >* Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore. That behaviour has been changed in: ebc6aee without any documentation change. If this was a conscious decision adding some documentation about dropping this functionality would then be nice. The old behaviour is documented in: https://github.com/mochajs/mocha/wiki/Conditionally-failing-tests-in-afterEach()-hooks .
In version 1.2.1, support was added to fail test in the after each hook: >* Added `this.test.error(err)` support to after each hooks. Closes mochajs#287 While migrating from teaspoon-mocha to karma-mocha, we discovered that in the current mocha version this isn't supported anymore. That behaviour has been changed in: ebc6aee without any documentation change. If this was a conscious decision adding some documentation about dropping this functionality would then be nice. The old behaviour is documented in: https://github.com/mochajs/mocha/wiki/Conditionally-failing-tests-in-afterEach()-hooks .
for use by frameworks to always perform verification / teardown after a test has run (but before it is declared successful or failed).