diff --git a/lib/reporter.js b/lib/reporter.js index 860fc5b..2ba8b89 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -121,10 +121,10 @@ class AllureReporter extends events.EventEmitter { testPending (test) { const allure = this.getAllure(test.cid) - if (allure.getCurrentTest()) { + if (allure.getCurrentTest() && allure.getCurrentTest().status !== 'pending') { allure.endCase('pending') } else { - this.getAllure(test.cid).pendingCase(test.title) + allure.pendingCase(test.title) } } diff --git a/test/fixtures/specs/several-pendings.js b/test/fixtures/specs/several-pendings.js new file mode 100644 index 0000000..976e013 --- /dev/null +++ b/test/fixtures/specs/several-pendings.js @@ -0,0 +1,17 @@ +const expect = require('chai').expect + +describe('A pending Suite', () => { + it.skip('1. this is a skipped test without any code', function () { + }) + + it.skip('2. this is another skipped test without any code', function () { + }) + + it('3. this is an enabled test that has a successfull assert', function () { + expect('foo', 'foo should equal foo').to.contain('foo') + }) + + it('4. this is an enabled test that has a failed assert', function () { + expect('foo', 'foo should equal foo').to.contain('foo2') + }) +}) diff --git a/test/specs/test-case-pending.js b/test/specs/test-case-pending.js new file mode 100644 index 0000000..55acaec --- /dev/null +++ b/test/specs/test-case-pending.js @@ -0,0 +1,33 @@ +import { expect } from 'chai' +import { clean, runMocha } from '../helper' + +describe('test cases', () => { + beforeEach(clean) + + it('should detect pending test cases', () => { + return runMocha(['pending']).then((results) => { + expect(results).to.have.lengthOf(1) + const result = results[0] + + expect(result('ns2\\:test-suite > name').text()).to.be.equal('A pending Suite') + expect(result('test-case > name').eq(0).text()).to.be.equal('pending test') + expect(result('test-case').eq(0).attr('status')).to.be.equal('pending') + + expect(result('test-case').eq(1).attr('start')).to.be.equal(result('test-case').eq(1).attr('stop')) + }) + }) + + it('should detect two pending test cases', () => { + return runMocha(['several-pendings']).then((results) => { + expect(results).to.have.lengthOf(1) + const result = results[0] + + expect(result('test-case > name').eq(0).text()).to.be.equal('1. this is a skipped test without any code') + expect(result('test-case').eq(0).attr('status')).to.be.equal('pending') + expect(result('test-case > name').eq(1).text()).to.be.equal('2. this is another skipped test without any code') + expect(result('test-case').eq(1).attr('status')).to.be.equal('pending') + expect(result('test-case').eq(2).attr('status')).to.be.equal('passed') + expect(result('test-case').eq(3).attr('status')).to.be.equal('failed') + }) + }) +}) diff --git a/test/specs/test-case.js b/test/specs/test-case.js index d6fb257..ceaf83f 100644 --- a/test/specs/test-case.js +++ b/test/specs/test-case.js @@ -40,19 +40,6 @@ describe('test cases', () => { }) }) - it('should detect pending test cases', () => { - return runMocha(['pending']).then((results) => { - expect(results).to.have.lengthOf(1) - const result = results[0] - - expect(result('ns2\\:test-suite > name').text()).to.be.equal('A pending Suite') - expect(result('test-case > name').eq(0).text()).to.be.equal('pending test') - expect(result('test-case').eq(0).attr('status')).to.be.equal('pending') - - expect(result('test-case').eq(1).attr('start')).to.be.equal(result('test-case').eq(1).attr('stop')) - }) - }) - it('should detect analytics labels in test case', () => { return runMocha(['passing']).then((results) => { expect(results).to.have.lengthOf(1)