-
Notifications
You must be signed in to change notification settings - Fork 18
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
Standard Events/Hooks #1
Comments
The original ticket mentioned browserstack-runner as a client of this interface. To make that a bit more specific, the goal here should be to reduce all of these into a single file that uses the interface shared by all testing frameworks: https://github.com/browserstack/browserstack-runner/tree/master/lib/_patch Following that pattern, Karma shouldn't have to implement adapters for each framework, like the one for QUnit or the one for Mocha. In both of these examples, a specific set of events with specific properties for each, with the option to add more events and more properties, is needed. The difficult part is to figure out what minimal set of events and properties need to be supported by each framework to claim compatibility. |
Plus I really want Mocha's NyanReporter to work for QUnit. 😉 |
@jzaefferer: Do you think it would make sense to include the Karma, BrowserStack, and SauceLabs folks on this effort? |
Here's some random information and speculation: So as I see it, there are potentially four types of reporters:
In the spirit of DRY, it might be a good idea to provide interface(s) or mixins or some other common set of utilities. For example, console-type reporters will typically have a toggle for color, and shouldn't display colors anyway if Regardless of what these reporters actually do, they all respond to one or more events. A quick scan of the reporters in Mocha shows that the following are listened to (more may be emitted):
What are the next steps here? Perhaps, let's gather the events emitted by QUnit, and other interested parties. I'd like some feedback from the Jasmine team, however, before going too far down the rabbit hole. Having Jasmine on board would be a huge win. |
@boneskull: Is it true that the |
QUnit's core events:
Two important notes about QUnit and how it currently differs from Mocha and Jasmine (AFAIK):
|
Also, if it benefits anyone, here are comments where I did some initial comparisons of reporting events:
|
Jasmine expects an object to be passed into
|
OK, so the first three frameworks (Mocha, QUnit, and Jasmine) all definitely have a common subset of events that overlap. I've filled in the initial details for @js-reporters/intern and @js-reporters/buster from their respective documentation here and here but I could be mistaken about their client-side absence of some event types.
|
UPDATE: For discussion regarding:
|
I can dig up a list of Buster's events and data. I think we have one of the more elaborate schemes for this. Where would you like me to post it? |
@cjohansen: Use your discretion. Post them as a comment here, a gist, a documentation page, etc. Whatever you think will work best to convey the necessary info. |
They're all here: http://docs.busterjs.org/en/latest/modules/buster-test/runner/#events For brevity/context:
Emitted once, as the runner starts running a test suite (a "suite" in Buster, is the full collection of tests to run)
{
contexts: 0,
tests: 0,
errors: 0,
failures: 0,
assertions: 0,
timeouts: 0,
deferred: 0
} Emitted once, when all tests are run
{ name: "Some stuff" } Emitted every time a test context is entered. In Buster, a test context is something that contains tests. It can be test cases, or nested contexts. In Jasmine-terms, every
Emitted every time a test context is completed.
{
context: context,
unsupported: ["label1", "label2"]
} Emitted every time a context fails its requirements (when that happens, neither context:start or context:end are emitted).
Emitted once per test before the setup method(s) for a test is called.
{ name: "test name", deferred: false } Emitted after running the test’s setup(s), but before the test itself runs.
Emitted when a test has been found to be asynchronous (usually means that the test function was called and has returned).
Emitted once per test before the tear down method(s) for a test is called.
{ name: "name of test", error: {name: "AssertionError", message: "", stack: "" } } Emitted when the test throws (or otherwise flags) an AssertionFailure(). Only emitted once per test.
Emitted when the test throws any error that is not an AssertionFailure(). Only emitted once per test.
Emitted if the test passes.
Emitted if the test runner forcefully aborts the test. This happens when the test is asynchronous and does not resolve within the timeout configured by testRunnerOptions.timeout.
Emitted when a test is marked as deferred. The test is not run.
In addition to this, some of our reporters make use of events from the scheduling system, such as |
@JamesMGreene Will get back to you on what data we're passing with |
Here's a suggestion for "a minimum viable set of standardly-named events", based on comments in this issue: A few reasons for these:
|
I feel like the advantages of namespacing these events are greater than these disadvantages; thus: |
@JamesMGreene |
@boneskull: What about |
@JamesMGreene Yes, |
@boneskull: Read through Issue #3 for more discussion of EventEmitter stuff. |
Would it be worthwhile to add a global "uncaughtException"/"unhandledError" event (see #4) as well, or do all frameworks currently handle those by dynamically adding a shell Test to report the failure as a failed "Test"? |
@JamesMGreene In Mocha the uncaughts are tossed by the runner then handed to the reporter as a failure. To make sure I understand what we're talking about, the test code I was using was this: describe('foo', function() {
it('should toss', function(done) {
setTimeout(function() {
throw new Error();
done();
}, 1000);
});
it('should not toss', function() {
require('assert')(true);
});
}); Resulting in:
I haven't seen anyone complain about this behavior, so I don't think it's worth it to differentiate the two. |
@boneskull Not exactly... more like one of the following two scenarios:
|
@boneskull: In other words, outstanding global error scenarios that would need to be caught via |
Intern 3.0 implemented a new interface for custom reporters. The event names from our draft match, but there's plenty additional events. Docs are here: https://theintern.github.io/intern/#custom-reporters |
Discussing |
ok, I'm sitting down rewriting our reporter interface, so I'm wondering if I should use the draft or what. can we like, vote on it? |
@boneskull we don't have a formal voting process, maybe we don't need one. So far there were no objections to the draft event names. Intern 3 is implementing the names already, you could go ahead and do the same. You're also welcome to review the proposal for event data in #12 - your feedback would help get that finished! |
@boneskull any thoughts on the above? Are you going to use the proposed event names? |
Seems fine to me, but I'll cc @mochajs/mocha |
guess you can't do that. |
@boneskull thanks for the inclusion. I'll get back to this tomorrow when I've had time to have a closer look. Kudos on getting back to this, still think the /js-reporters/js-reporters project is awesome! |
We on the QUnit team have been discussing the possibility of working with other JS test frameworks that can be run client-side (e.g. Mocha, Jasmine, Intern, Buster, etc.) to agree upon a standard Reporter interface so that we could hopefully share Reporter plugins between testing frameworks.
This would most likely come in the form of:
an EventEmitter interface (.on(...)
/.off(...)
) OR object with standard "hook" propertiesmaybe a standard-ish way to add a Reporter, e.g.MyLib.addReporter(x)
,MyLib.reporter = x;
, etc.a minimum viable set of standard test status types (e.g. pass, fail, skip, todo, pending, etc.)Would you guys be interested in discussing this further with us?
Cross-reference issues:
The text was updated successfully, but these errors were encountered: