-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Adding tests not settled detection support in tests #314
Conversation
@@ -228,6 +232,28 @@ export function setupEmberOnerrorValidation() { | |||
}); | |||
} | |||
|
|||
export function setupAsyncTimerLeakDetection() { | |||
QUnit.testDone(({ module, name }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making these callbacks separate (but private) exported functions will allow you to invoke them manually from within a single test and assert that the expected error is thrown....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. That will address my nagging guilt at the thought of pushing code with no tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, its the guilt that drives me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split things up. Added tests.
} from '@ember/test-helpers'; | ||
import { detectPendingTimers, reportPendingTimers } from './async-timer-leak-detection'; | ||
|
||
const TESTS_WITH_LEAKY_ASYNC = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should move this into the util file, no need to track it here and pass it around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Not sure why I didn't see this....
@@ -228,6 +233,18 @@ export function setupEmberOnerrorValidation() { | |||
}); | |||
} | |||
|
|||
export function setupAsyncTimerLeakDetection() { | |||
QUnit.testDone(({ module, name }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this whole function the thing that is extracted? So that the resulting code would be:
QUnit.testDone(importedThingGoesHere);
QUnit.done(otherImportedThingGoesHere);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main changes look good to me!
I'd like to suggest a couple of alternative names for the flag and method names though:
- setupLeakingTestsDetection
- setupAsyncLeakDetection
- setupLeakDetection
Any of those strike you as "better" or "worse"?
So I know that settled doesn't necessarily immediately scream what it does, it is consistent from That said, if I were to change it, I'd probably opt for:
That helps convey that we're setting up async leak detection for tests. What do you think? |
@rwjblue and I arrived at |
@rwjblue any more changes required here? |
This PR adds support for detecting if a test is not settled in tests. It tests for the settledness of timers via
isSettled
inember-test-helpers
.A test is considered settled if it: