Skip to content

Commit

Permalink
wdio-allure-reporter: Bug fix where tests get unknown status and has …
Browse files Browse the repository at this point in the history
…no execution information
  • Loading branch information
ccharnkij committed Feb 18, 2020
1 parent c966686 commit 47d14b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/wdio-allure-reporter/src/index.js
Expand Up @@ -227,7 +227,7 @@ class AllureReporter extends WDIOReporter {
}

// add beforeEach / afterEach hook as step to test
if (this.options.disableMochaHooks && isMochaEachHooks(hook.title)) {
if (isMochaEachHooks(hook.title)) {
if (this.allure.getCurrentTest()) {
this.allure.startStep(hook.title)
}
Expand All @@ -245,12 +245,12 @@ class AllureReporter extends WDIOReporter {

onHookEnd(hook) {
// ignore global hooks
if (!hook.parent || !this.allure.getCurrentSuite() || (this.options.disableMochaHooks && !isMochaAllHooks(hook.title) && !this.allure.getCurrentTest())) {
if (!hook.parent || !this.allure.getCurrentSuite() || (!isMochaAllHooks(hook.title) && !this.allure.getCurrentTest())) {
return false
}

// set beforeEach / afterEach hook (step) status
if (this.options.disableMochaHooks && isMochaEachHooks(hook.title)) {
if (isMochaEachHooks(hook.title)) {
if (hook.error) {
this.allure.endStep(stepStatuses.FAILED)
} else {
Expand Down
10 changes: 5 additions & 5 deletions packages/wdio-allure-reporter/tests/allureFeatures.test.js
Expand Up @@ -525,20 +525,20 @@ describe('hooks handling default', () => {
endStep = jest.fn(result => result)
})

it('should capture mocha each hooks', () => {
it('should not capture mocha each hooks', () => {
reporter.allure = allureInstance()
reporter.onHookStart({ title: '"before each" hook', parent: 'foo' })

expect(startStep).toHaveBeenCalledTimes(0)
expect(startCase).toHaveBeenCalledTimes(1)
expect(startStep).toHaveBeenCalledTimes(1)
expect(startCase).toHaveBeenCalledTimes(0)
})

it('should not ignore mocha each hooks if no test', () => {
it('should ignore mocha each hooks if no test', () => {
reporter.allure = allureInstance({ test: null })
reporter.onHookStart({ title: '"after each" hook', parent: 'foo' })

expect(startStep).toHaveBeenCalledTimes(0)
expect(startCase).toHaveBeenCalledTimes(1)
expect(startCase).toHaveBeenCalledTimes(0)
})

it('should keep passed hooks if there are no steps (before/after)', () => {
Expand Down

0 comments on commit 47d14b3

Please sign in to comment.