Skip to content

Commit

Permalink
feat(reporter): emit info events for suiteStarted/suiteDone (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjbarton committed May 28, 2020
1 parent 6ae15a9 commit 7b73ce0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/adapter.js
Expand Up @@ -179,6 +179,7 @@ function KarmaReporter (tc, jasmineEnv) {
this.jasmineStarted = function (data) {
// TODO(vojta): Do not send spec names when polling.
tc.info({
event: 'jasmineStarted',
total: data.totalSpecsDefined,
specs: getAllSpecNames(jasmineEnv.topSuite())
})
Expand All @@ -198,6 +199,10 @@ function KarmaReporter (tc, jasmineEnv) {

this.suiteStarted = function (result) {
currentSuite = currentSuite.addChild(result.description)
tc.info({
event: 'suiteStarted',
result: result
})
}

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

currentSuite = currentSuite.parent

tc.info({
event: 'suiteDone',
result: result
})
}

this.specStarted = function () {
Expand Down
18 changes: 18 additions & 0 deletions test/adapter.spec.js
Expand Up @@ -85,6 +85,10 @@ describe('jasmine adapter', function () {
})

it('should report success result', function () {
spyOn(karma, 'info').and.callFake(function (info) {
expect(info.event).toBe('suiteStarted')
expect(info.result).toBeDefined()
})
karma.result.and.callFake(function (result) {
expect(result.id).toBe(spec.id)
expect(result.description).toBe('contains spec with an expectation')
Expand All @@ -100,6 +104,20 @@ describe('jasmine adapter', function () {
expect(karma.result).toHaveBeenCalled()
})

it('should report suiteDone result', function () {
const infoSpy = spyOn(karma, 'info')
// The stateful adapter needs a started event.
reporter.suiteStarted(parentSuite.result)

infoSpy.and.callFake(function (info) {
expect(info.event).toBe('suiteDone')
expect(info.result).toBeDefined()
expect(info.result.description).toBe('Parent Suite')
})

reporter.suiteDone(parentSuite.result)
})

it('should report disabled status', function () {
spec.result.status = 'disabled'

Expand Down

0 comments on commit 7b73ce0

Please sign in to comment.