Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reporter): emit info events for suiteStarted/suiteDone #269

Merged
merged 1 commit into from May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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