Skip to content

Commit 7b73ce0

Browse files
authored
feat(reporter): emit info events for suiteStarted/suiteDone (#269)
1 parent 6ae15a9 commit 7b73ce0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/adapter.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ function KarmaReporter (tc, jasmineEnv) {
179179
this.jasmineStarted = function (data) {
180180
// TODO(vojta): Do not send spec names when polling.
181181
tc.info({
182+
event: 'jasmineStarted',
182183
total: data.totalSpecsDefined,
183184
specs: getAllSpecNames(jasmineEnv.topSuite())
184185
})
@@ -198,6 +199,10 @@ function KarmaReporter (tc, jasmineEnv) {
198199

199200
this.suiteStarted = function (result) {
200201
currentSuite = currentSuite.addChild(result.description)
202+
tc.info({
203+
event: 'suiteStarted',
204+
result: result
205+
})
201206
}
202207

203208
this.suiteDone = function (result) {
@@ -212,6 +217,11 @@ function KarmaReporter (tc, jasmineEnv) {
212217
handleGlobalErrors(result)
213218

214219
currentSuite = currentSuite.parent
220+
221+
tc.info({
222+
event: 'suiteDone',
223+
result: result
224+
})
215225
}
216226

217227
this.specStarted = function () {

test/adapter.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ describe('jasmine adapter', function () {
8585
})
8686

8787
it('should report success result', function () {
88+
spyOn(karma, 'info').and.callFake(function (info) {
89+
expect(info.event).toBe('suiteStarted')
90+
expect(info.result).toBeDefined()
91+
})
8892
karma.result.and.callFake(function (result) {
8993
expect(result.id).toBe(spec.id)
9094
expect(result.description).toBe('contains spec with an expectation')
@@ -100,6 +104,20 @@ describe('jasmine adapter', function () {
100104
expect(karma.result).toHaveBeenCalled()
101105
})
102106

107+
it('should report suiteDone result', function () {
108+
const infoSpy = spyOn(karma, 'info')
109+
// The stateful adapter needs a started event.
110+
reporter.suiteStarted(parentSuite.result)
111+
112+
infoSpy.and.callFake(function (info) {
113+
expect(info.event).toBe('suiteDone')
114+
expect(info.result).toBeDefined()
115+
expect(info.result.description).toBe('Parent Suite')
116+
})
117+
118+
reporter.suiteDone(parentSuite.result)
119+
})
120+
103121
it('should report disabled status', function () {
104122
spec.result.status = 'disabled'
105123

0 commit comments

Comments
 (0)