1 | ### NO FLUSH ###
|
2 |
|
3 | ### not in use ###
|
4 |
|
5 | #
|
6 | # global test event proxy
|
7 | # -----------------------
|
8 | #
|
9 |
|
10 | {EventEmitter} = require 'events'
|
11 | module.exports = emitter = new EventEmitter
|
12 |
|
13 | #
|
14 | # create tester
|
15 | # -------------
|
16 | #
|
17 |
|
18 | Mocha = require 'mocha'
|
19 |
|
20 | module.exports.create = (opts) ->
|
21 |
|
22 | mocha = new Mocha reporter: (runner) ->
|
23 |
|
24 | ###
|
25 |
|
26 | from: mocha/lib/runner.js
|
27 |
|
28 | Events:
|
29 |
|
30 | - `start` execution started
|
31 | - `end` execution complete
|
32 | - `suite` (suite) test suite execution started
|
33 | - `suite end` (suite) all tests (and sub-suites) have finished
|
34 | - `test` (test) test execution started
|
35 | - `test end` (test) test completed
|
36 | - `hook` (hook) hook execution started
|
37 | - `hook end` (hook) hook complete
|
38 | - `pass` (test) test passed
|
39 | - `fail` (test, err) test failed
|
40 | - `pending` (test) test pending
|
41 |
|
42 | ###
|
43 |
|
44 | for event in ['start','end','suite','suite end','test','test end',
|
45 | 'hook','hook end','pass','fail','pending']
|
46 |
|
47 | do (event) -> runner.on event, (data...) ->
|
48 |
|
49 | ## THIS IN THE TEST RUNNER
|
50 |
|
51 | emitter.emit 'spec_event',
|
52 |
|
53 | source: 'mocha'
|
54 | event: event
|
55 | data: data
|
56 |
|
57 |
|
58 | #
|
59 | # Mocha.reporters[ opts.reporter || 'Dot']
|
60 | #
|
61 | # * having diffulties including another reporter
|
62 | # * much is lost if i can't do that
|
63 | #
|
64 |
|
65 | return api =
|
66 |
|
67 | run: (files, callback) ->
|
68 |
|
69 | mocha.addFile file for file in files
|
70 | mocha.run callback
|