Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Don't use the root property to determine suite root. #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ var createMochaReporterConstructor = function (tc, pathname) {
}

var pointer = test.parent
while (!pointer.root) {
while (pointer.parent) {
result.suite.unshift(pointer.title)
pointer = pointer.parent
}
Expand Down
18 changes: 18 additions & 0 deletions test/src/adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ describe('adapter mocha', function () {
expect(tc.result.called).to.eq(true)
})

it('should not rely on the root property to determine root', function () {
sandbox.stub(tc, 'result', function (result) {
expect(result.suite).to.deep.eq([''])
})

var mockMochaResult = {
duration: 0,
parent: {title: '', parent: {title: 'desc1', root: true}, root: true},
state: 'passed',
title: 'should do something'
}

runner.emit('test', mockMochaResult)
runner.emit('test end', mockMochaResult)

expect(tc.result.called).to.eq(true)
})

it('should report skipped result', function () {
sandbox.stub(tc, 'result', function (result) {
expect(result.skipped).to.eq(true)
Expand Down