s9tpepper / karma-cucumberjs

A Cucumber.js Karma test runner adapter.
MIT License
54 stars 21 forks source link

Adding settings-comments for allowPending #1

Closed ReactiveRaven closed 4 years ago

ReactiveRaven commented 11 years ago

This may be entirely against your philosophy for the project, but I added a method to add overrides to allow for treating pending steps as non-failures in Karma.

Starting a comment on an otherwise empty line with "#karma-cucumberjs" would be treated as a space-delimited array of settings. Currently only 'allowPending' is implemented. The comment can be indented. There could be multiple comments per file.

eg, allowing pending steps from an entire feature:

#karma-cucumberjs allowPending
Feature: Some Feature
  Scenario: Some scenario
    Given a pending step
  Scenario: Another scenario
    Given a pending step
....
2 steps (2 pending)
Executed 2 of 2 (skipped 2) SUCCESS

eg, allowing pending steps only on a specific scenario:

Feature: Some Feature
  Scenario: Some scenario
    #karma-cucumberjs allowPending
    Given a pending step
  Scenario: Another scenario
    Given a pending step
....
2 steps (2 pending)
Executed 2 of 2 (1 FAILED) (skipped 1)

It does this by adding a function parseSettingsFromFeature to the cucumber_runner which is called while loading feature files, passing the settings found into karma_listener's constructor, and adding the function shouldAcceptPending and updating the checkStepSuccess function in karma_listener.

The plugin is really useful already, I just decided to have a hack for fun, so please do close the pull request if you don't think this will be useful for you. Thanks :)