-
Notifications
You must be signed in to change notification settings - Fork 307
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
Reporters review #1023
Comments
We did some work in #1014 with trying to normalize filename/directory information. We learned that while the Istanbul reporters have @jason0x43 and I also discussed moving toward a factory-based creation of reporters and treating them as a bag of event handlers. Many of the current classes aren't extensible in any meaningful way and really only serve as a wrapper themselves. Extension could be explicitly defined with functions passed to the factory. Regarding normalizing |
Some potential tasks we have so far:
|
From a user-interface perspective, Intern could be made easier to use by move away from exposing the built in reporters as distinct entities. Instead, users should see Intern as generating various types of output. For example, by default it outputs to the console, and there should be various options to control this output. It can also output a Junit report, or an HTML coverage report, or various other things. To enable reporting functionality, the user should just need to include a config option for it. We might move to something like this: // intern.json
{
"output": {
"hidePassed": true,
"hideCoverage": true,
"htmlCoverage": {},
"junit": {
"path": "test-reports"
}
}
} In the snippet above, a single "output" property controls Intern's output. The default output can be managed through top-level properties such as "hidePassed". Other report types can be enabled by providing some config for them. From the command line, report control could work similarly. A command line providing the same config as above might look like:
Maybe the |
ReviewIntern currently has the following reporters:
Users must explicitly select reporters using the Reporters are currently class-based, all inheriting from Reporter, and many from Coverage. At their core, though, reporters are just event listeners. TasksCombine Simple, Runner, and PrettyThere's no need for three separate Node console reporters. Create a single reporter for Node output with options to change its behavior. At a high level, use the Runner reporter's basic format, but with multi-session support similar to the Pretty reporters. Make reasonable use of colors and font family (bold and italic), but allow these to be easily disabled. Convert reporters to simple event handlersWe're not getting any real benefit from the class hierarchy. Scrap it and reimplement the reporters as event listeners with some shared utility functions. Reporters would be created with factory functions, potentially something like this: // lib/reporters/node
export function createReporter(executor: Executor, options: NodeOutputOptions): Handle {
const listeners = [];
listeners.append(executor.on('testStart', test => {
// ...
}));
listeners.append(executor.on('suiteEnd', suite => {
// ...
}));
return {
destroy() {
// remove listeners
}
};
} Simplify reporter configurationThis one's more about the concept than significantly changing the code... Replace the By default, Intern will output to the console in whatever environment it's running in (and possibly to the DOM for remote webdriver sessions). If the user wants to set an option on Intern's output, they can set it on the Custom reporters will simply be plugins, and will use the standard plugin configuration system. Combine the coverage reportersSince we're hiding the internal reporter structure from users, we could simplify the coverage reporters. Most of them are just deferring everything to the coverage base class, and through that to Istanbul. Just combine them all into a single module and let the Node executor create what's needed. For example, if Intern was configured with {
"output": {
"htmlcoverage": {},
"lcov": { "filename": "coverage-report.lcov" }
}
} Intern could just create multiple instances of a coverage reporter (notional syntax): // executors/Node
import { createReporter as createCoverageReporter } from 'lib/reporters/coverage';
// ...
for (const name in supportedReporters) {
if (name in this.config.output) {
createCoverageReporter(this, name, this.config.output[name]);
}
} |
This is a great approach to modernizing reporters. A couple things:
|
Custom reporters will still just be plugins, and plugins are loaded very early in the testing process. I was actually going to try to move them back even further so they'd have a chance to affect the resolved configuration (or break up configuration resolution around plugin loading).
The import { registerPlugin } from 'intern';
import { doAsyncStuff } from 'async-stuff';
registerPlugin('my-reporter', async () => {
await doAsyncStuff();
intern.on('testStart', test => {
console.log(`started ${test.id}`);
});
}); We could definitely make
Every event listener is async, so a reporter can just return a Promise from a late event like However... Intern isn't currently waiting for all the event handlers to finish, so while the process would remain open during cleanup actions, Intern wouldn't be paying attention any longer. One of the the planned general API updates is to integrate the event handlers into the execution process. |
Closing this as discovered. Outcomes:
|
The goal of this issue is to review Intern's existing reporters (what's there and how they work) and suggest which ones we could drop and what additional ones we might need, as well as how they might be better implemented.
For example, there isn't current a consistent way to configure reporters from the main config; you can provide a reporter description with options to reporters, but each reporter may take different options.
Some questions to answer:
The text was updated successfully, but these errors were encountered: