-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mocha): support for custom tags
custom tags, such as @issues:JIRA-1,JIRA-2 or @regression-pack, included in test names are now recognised in Serenity BDD reports
- Loading branch information
Showing
7 changed files
with
141 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
integration/mocha/examples/custom_tags/custom_tags_in_title.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe('My feature @feature', () => { | ||
|
||
describe('A scenario @scenario @issues:JIRA-1', () => { | ||
|
||
it('passes @positive @issues:JIRA-2,JIRA-3', () => { | ||
// no-op, passing | ||
}); | ||
|
||
it.skip('manual test @manual'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools'; | ||
import { Timestamp } from '@serenity-js/core'; | ||
import { | ||
SceneFinished, | ||
SceneFinishes, | ||
SceneStarts, | ||
SceneTagged, | ||
TestRunFinished, | ||
TestRunFinishes, | ||
TestRunnerDetected, | ||
TestRunStarts | ||
} from '@serenity-js/core/lib/events'; | ||
import { | ||
ArbitraryTag, | ||
CapabilityTag, | ||
CorrelationId, | ||
ExecutionSuccessful, | ||
FeatureTag, | ||
ImplementationPending, | ||
IssueTag, | ||
ManualTag, | ||
Name | ||
} from '@serenity-js/core/lib/model'; | ||
import { describe, it } from 'mocha'; | ||
|
||
import { mocha } from '../src/mocha'; | ||
|
||
describe('@serenity-js/mocha', function () { | ||
|
||
it('emits custom tags if present on describe or test title so that Serenity BDD can aggregate them correctly', () => mocha( 'examples/custom_tags/custom_tags_in_title.spec.js') | ||
.then(ifExitCodeIsOtherThan(0, logOutput)) | ||
.then(result => { | ||
expect(result.exitCode).to.equal(0); | ||
|
||
let currentSceneId: CorrelationId; | ||
|
||
PickEvent.from(result.events) | ||
.next(TestRunStarts, event => expect(event.timestamp).to.be.instanceof(Timestamp)) | ||
.next(SceneStarts, event => { | ||
expect(event.details.name).to.equal(new Name('A scenario passes')); | ||
currentSceneId = event.sceneId; | ||
}) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('Custom tags'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('My feature'))) | ||
.next(TestRunnerDetected, event => expect(event.name).to.equal(new Name('Mocha'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new ArbitraryTag('feature'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new ArbitraryTag('scenario'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new IssueTag('JIRA-1'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new ArbitraryTag('positive'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new IssueTag('JIRA-2'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new IssueTag('JIRA-3'))) | ||
|
||
// triggered by requiring actorCalled | ||
.next(SceneFinishes, event => { | ||
expect(event.sceneId).to.equal(currentSceneId); | ||
}) | ||
.next(SceneFinished, event => { | ||
expect(event.sceneId).to.equal(currentSceneId); | ||
expect(event.outcome).to.equal(new ExecutionSuccessful()); | ||
}) | ||
.next(SceneStarts, event => { | ||
expect(event.details.name).to.equal(new Name('A scenario manual test')); | ||
currentSceneId = event.sceneId; | ||
}) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('Custom tags'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('My feature'))) | ||
.next(TestRunnerDetected, event => expect(event.name).to.equal(new Name('Mocha'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new ArbitraryTag('feature'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new ArbitraryTag('scenario'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new IssueTag('JIRA-1'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new ManualTag('Manual'))) | ||
|
||
.next(SceneFinished, event => { | ||
expect(event.sceneId).to.equal(currentSceneId); | ||
expect(event.outcome).to.be.instanceof(ImplementationPending); | ||
}) | ||
.next(TestRunFinishes, event => expect(event.timestamp).to.be.instanceof(Timestamp)) | ||
.next(TestRunFinished, event => expect(event.timestamp).to.be.instanceof(Timestamp)) | ||
; | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters