Comments (15)
Great proposal. I see two things here.
- We need the reporters array to be a collection of reporters, where all of the reporters are not enabled by default. Or in other words, they are disabled by default.
- Next, we can activate one or more reporters with the
--reporters
flag. - Finally, we need at least one default enabled reporter. Otherwise, it becomes tiring to always pass the
--reporter
flag.
I was looking at Mocha, and they have the spec
reporter enabled by default. However, the spec reporter is bundled within mocha, so they always have it available.
Have you looked at Vitest or Jest, how they approach this? I have some ideas in mind, but let's see if there is an established pattern
from runner.
Yes, so Vitest proposes a bit the same thing as my last suggestion. Except that all the reporters are built-in and directly integrated in it. No additional packages to install :
https://vitest.dev/config/#reporters
Jest proposes this :
https://jestjs.io/fr/docs/configuration#reporters-arraymodulename--modulename-options
I am personally not a fan of Jest's tuple syntax, and I find Vitest's approach much more clear and concise.
However, the problem with Vitest's approach is that it is impossible to change reporter options. We could imagine a reporterOptions
property, but this would not be typesafe :
configure({
reporter: 'dot',
reporterOptions: {
dotOption: true
}
})
from runner.
How about making reporters
an object with following properties.
reporters: {
list: [],
default: 'spec',
},
The default
property can be type safe based upon what's in their in the list.
from runner.
The problem with this solution is that you can't activate several reporters at the same time unless you use the --reporters
flag. But I ask again: do we really need to activate several reporters at the same time?
Or maybe we can just make it an array :
reporters: {
list: [],
default: ['spec','another'],
},
from runner.
Actually yes, having multiple reporters can be handy. Let's imagine that the user wants to have a json reporter that saves the result of the tests in a file but doesn't display anything in the console, but also to have the spec reporter. This is a bit of a stretch, but it could make sense
from runner.
Yeah, we can allow the default one to be an array and rename the property to be defaults
.
So basically, you have a hardcoded set of defaults in the config. However, you can overwrite them using the --reporters
flag
from runner.
Okay, that sounds nice. The only thing that bothers me a little is that it results in a breaking change. But at this point, I don't think we have much choice if we want to offer an API that's not too ugly
If it sounds okay for you, I'm willing to implement it this weekend
from runner.
Let me just recap:
- We forget about the non breaking change attempt on the ReporterContract knowing that we have another breaking change, so not much interest except being error prone.
This means that the contract of the reporter becomes the following :
type ReporterContract =
| { name: string; handler: ReporterHandler }
| ReporterHandler
- Then, as you said, we keep that API for the
configure
function :
reporters: {
list: [
specReporter(),
anotherReporter()
],
defaults: ['spec','another'],
},
As simple as that !
from runner.
Actually, no, sorry. It is perfectly possible to make the thing non-breaking.
- We keep my suggestion about the ReporterContract.
- And finally, we do the same thing for the
reporters
configuration property. Basically: ifreporters
is an array, like in the current API, then we just enable all reporters. If it's an object, then we use the new system.
from runner.
Right now we do not have many 3rd party reporters. So, we can break the ReporterContract and ship them as major server. People won't have to change a line in their config.
For the config reporters
property, yes, it can be backwards compatible.
from runner.
Yeah, I was mostly thinking of people that would potentially write an inline reporter. Or who would have just kept their reporter private. Very unlikely to be the case honestly, but possible.
from runner.
Yeah, but I think 0.1% chance of that. Also, we will mark it as a major release. Its just I do not want others to change their config too after the upgrade.
from runner.
Okay great. Thanks a lot for the feedback dude. I'll get right on it quickly!
from runner.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from runner.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from runner.
Related Issues (20)
- [Bug]: "Only file and data URLs are supported by the default ESM loader" when running in Windows environment. HOT 2
- Allow failing slowly in a test case HOT 1
- Adonis tests are failing when we setup application on different PC or location or after re-installing the dependencies. HOT 10
- Assertion method `expected` and `actual` parameter orders should be predictable HOT 3
- Should setup group-hook inject stuff into test context HOT 1
- Test results in failed when testing explicitly thrown function
- Test runner breaks when `group` handler is `async` HOT 4
- Test runner breaks when error is thrown
- Need HTML Test report HOT 3
- Add help commands to "processCliArgs" HOT 1
- Trying to upload non-existing file hangs test suite HOT 6
- Open APIs to get the current test/group and file name from a plugin HOT 9
- Property 'expect' does not exist on type TextContext HOT 2
- Bug with assertAgainstApiSpec on Adonisjs HOT 8
- Config `importer` function returns wrong path when using ESM loader HOT 4
- Unable to run migrations in github workflow when automating test runner HOT 1
- Typescript non-relative path class imports HOT 4
- group.each.setup don't seem to be called from configureSuite
- Migrations should be run silently. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from runner.