ben-page / node-test

A simple, asynchronous test runner for Node.js.
https://www.npmjs.com/package/node-test
MIT License
4 stars 1 forks source link

Custom reporter and events #19

Closed ghost closed 8 years ago

ghost commented 8 years ago

I noticed there are no events to be triggered before all tests are running, and no event to be triggered at the end of all tests and suites?

Example something like this?


start //  starts before anything else

suite-start
     test-start
   test-end
suite-end

end // ends at the end when everything is done

With this two new events it will be easier to create custom reporters. Now your reporter code is only inside test-end and rest of the events never used. So what is the purpose with test start?

If you look at Mocha and other reporters, you will also notice they have a pass and, failed event too. And the reporter data is gathered one by one when the events triggered so they avoiding using an iteration loop as you do in test-end.

I think there would be much easier for users if start and end events at least was added.

ghost commented 8 years ago

I was reading your readme, and saw this: https://github.com/ben-page/node-test#event-end but this one isn't triggered after everything else as far as I know. If you trigger that event and add this

console.log('Foo')

you will see that Foo runs multiple times, and after each suite. Not when all suites are completed.

ghost commented 8 years ago

This event: https://github.com/ben-page/node-test#event-start

Isn't working as expected either I guess? With the Foo example

console.log('Foo')

I had expected Foo to be triggered only once before all suites and tests?

This is my output now on top of the reporter with multiple suites

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo

Foo
ghost commented 8 years ago

I figured out what's going on. So ignore this! Closing.