Git Product home page Git Product logo

yadda's People

Contributors

akikhtenko avatar albanminassian avatar bogus34 avatar brianjmiller avatar chrisns avatar christian-bromann avatar cressie176 avatar dependabot[bot] avatar exon avatar gblosser42 avatar hans-d avatar jcsrb avatar johntron avatar lloydwatkin avatar marketionist avatar meisterluk avatar mgijsbertihodenpijl avatar mortonfox avatar n1k0 avatar pmpuro avatar prokls avatar prust avatar punkchameleon avatar radioactivemouse avatar raulmb avatar remkoboschker avatar robfletcher avatar simoami avatar smarigowda avatar snowyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yadda's Issues

Allow for comments in Feature files

Pref javascript en coffeescript style, both single and multi-line

# Allow some description why a scenario is still @pending
// Or some extra info why a scenario is relevant, or ...
###
 Blocks would allow for longer descriptive texts
###
/*
 As would this one,
*/
# One could even include FIXME: provide reference to external specification

Yadda doesn't work with Casper Development Branch

rk4n commented on f0eadb4

Guys, probably you can help me.
Host: Ubuntu 13.10.
CasperJS installed using http://docs.casperjs.org/en/latest/installation.html#installing-from-git .

I'm getting an error:
/home/user/node_modules/yadda/examples/casper$ casperjs test.js
TypeError: 'undefined' is not an object (evaluating > 'require.cache['/home/user/node_modules/yadda/examples/casper/google-library.js']')
/home/user/node_modules/yadda/examples/casper/google-library.js:38

But google-library.js contains only 37 lines.

Sorry you're having problems. I just tried yadda on Ubuntu 12.04 with casper latest stable and it runs OK. When I switch to latest from git I get

CasperError: can't find module async
/home/parallels/..../casperjs/bin/bootstrap.js:227 in patchRequire

My guess is they've changed the way require works, and the example has stopped working. I'll drop the casper guys a note and see if they can shed any light.

pending tabulation

Hello

Ok

Fonctionnalité: xxxxx

@En attente
    Scénario: task 

        Quand j'appelle l'adresse avec le token d'identification

BAD

Fonctionnalité: xxxxx

    @En attente
    Scénario: task 

        Quand j'appelle l'adresse avec le token d'identification

If i use space or tabulation for tags, yadda return

node_modules\yadda\lib\parsers\FeatureParser.js:72
            throw new Error('Error parsing line ' + (index  + 1) + ', "' + lin
                  ^
Error: Error parsing line 11, " @En attente".
Text is unexpected at this time

Is'it a bug ?
Ami44

Cannot run provided example

Hi,

I'm trying to execute provided example, but getting next error :

Error: Undefined Step: [Given 100 green bottles are standing on the wall]
at clear_winner (/home/igal/POC/Mocha/node_modules/yadda/lib/Competition.js:29:49)
at interpret_step (/home/igal/POC/Mocha/node_modules/yadda/lib/Interpreter.js:52:33)
at iterator (/home/igal/POC/Mocha/node_modules/yadda/lib/Interpreter.js:44:19)
at iterate (/home/igal/POC/Mocha/node_modules/yadda/lib/Array.js:69:13)
at Array.each_async (/home/igal/POC/Mocha/node_modules/yadda/lib/Array.js:75:9)
at Array.each_async (/home/igal/POC/Mocha/node_modules/yadda/lib/fn.js:24:23)
at interpret (/home/igal/POC/Mocha/node_modules/yadda/lib/Interpreter.js:39:21)
at yadda (/home/igal/POC/Mocha/node_modules/yadda/lib/Yadda.js:35:26)
at yadda (/home/igal/POC/Mocha/node_modules/yadda/lib/Yadda.js:34:84)
at /home/igal/POC/Mocha/bottles-test.js:10:11
at Context. (/home/igal/POC/Mocha/node_modules/yadda/lib/plugins/MochaPlugin.js:29:17)
at Test.Runnable.run (/usr/lib/node_modules/mocha/lib/runnable.js:194:15)
at Runner.runTest (/usr/lib/node_modules/mocha/lib/runner.js:358:10)
at /usr/lib/node_modules/mocha/lib/runner.js:404:12
at next (/usr/lib/node_modules/mocha/lib/runner.js:284:14)
at /usr/lib/node_modules/mocha/lib/runner.js:293:7
at next (/usr/lib/node_modules/mocha/lib/runner.js:237:23)
at Object._onImmediate (/usr/lib/node_modules/mocha/lib/runner.js:261:5)
at processImmediate as _immediateCallback

Any Idea why does it happen ?

thanks

Licence

Line 190 of LICENSE.txt file is not specified:

Copyright [yyyy] [name of copyright owner]

The other files do not recall the same license Apache License Version 2.0, January 2004` but another:

Copyright 2010 Acuminous Ltd / Energized Work Ltd

Is the Apache license applies to all files?
Ami44

Verify Yadda Supports Example Tables

Yadda should support data driven testing through example tables, e.g.

item   | price | tax | qty | total
apple  | 0.50  | N/A | 3   | 1.50
yogurt | 1.00  | 10% | 2   | 2.20

My preferred way to implement this would be with clever use of steps rather than through new code, e.g.

Given multiple line items:

   item   | price | tax | qty | total
   apple  | 0.50  | N/A | 3   | 1.50
   yogurt | 1.00  | 10% | 2   | 2.20

Then each line item's total should be it's (price + tax) * quantity
.given('multiple line items', function(item, price, tax, quantity, total, done) {
   lineItemExamples.push(new LineItem(item, price, tax, quantity, total));
   done();
}

.then('each line item\'s total should be it\'s (price + tax) * quantity', function(done) {
   _.each(lineItemExamples, function(example) {
      assert.equal(lineItemService.get(example.item).total, example.total);
   }
   done();
})

I think this should work, but I've not tried it

Full Gherkin support

Hi,
We use Gherkin to write scenarios throughout our organization. We are moving to Javascript and this tools seems promising. I tried using Yadda. So far it supports only Feature, Scenario, Give, When, Then and And keywords. It would be extremely useful if you provide full Gherkin support (like Background, Scenario Outline, Examples etc.). Are there are any plans?

enhancement pattern lib/FileSearch.js

When i write my features files, i often add readme.[md|rst] documentation.

but I must not forget to code var all_features = new Yadda.FileSearch('../features', /.*\.feature/).list();

Could var patterns = patterns || /.*/; become var patterns = patterns || /.*\.feature/; by default.

Thanks
Ami44

Add support for GivenFeature

In real world, automation tests may have other features as dependencies. For instance, in order to test a shopping cart, I might need to first create a product catalog. To avoid duplication of steps, it would be helpful to reference other tests directly:

# A precondition to entire story
GivenFeature: path/to/precondition1.feature

Scenario:  A scenario in which the user can run additional features as pre-requisites

    # preconditions to scenario    
    GivenFeature: path/to/precondition2.feature, 
    Given ... // normal scenario steps

I can see this being a game changer for the already great Yadda.

Ref: http://jbehave.org/reference/stable/given-stories.html

Annotations in feature files

I wanted to propose an idea and get your thoughts on it.

Annotations in feature files
Use case: When using Yadda with Selenium WebDriver, we may like to specify some annotations at the top of the file to state which browsers the particular feature file applies to. e.g. @browsers=Chrome,Firefox

Alternatively, maybe we could use the TextParser to parse out 'Given' steps and decide which browser is applicable to run such a step (assuming a given of: Given I am on a Firefox browser). - But this approach doesn't feel as clean.

The goal for us is to filter out tests designed to run on a particular browser and put them into 'buckets', that way, different machines can run different tests depending on what browsers are supposed to run.

What are your thoughts on this?

Error: A feature must contain one or more scenarios

Hi,

I'm having lots of trouble formatting my features - I've followed the examples and can't see why there is an issue. Here's my example feature.

Feature: As a tech architect I want to list all my resources so that I can see what is live

Scenario: List types

    Given I navigate to the homepage
    Then I should see the resource

That's it. I get
> FAIL Error: A feature must contain one or more scenarios

I have the blank line I noticed in another reported issue. I have had these files working successfully with the mocha plugin, so I suspect this is is the FeatureParser issue. I assume I should be running them like this...

> casperjs test  features/step_definitions/resource_overview_test.js

Also, it seems to dump a load of failed scenarios around bottles and google that makes unpicking the trace quite tricky at first - can I turn these off please?

Many thanks

Sharing modifiable objects throughout multiple step definitions

Creating a new yadda instance (var yadda = new Yadda(library, context)) allows you to pass some sort of object which each step def can access via the this keyword. Is there any technique you can think of utilising which would allow a change to the state object to be applied to all other step defs?

library.given("I do something", function(next) {
    this.foo; //bar
    this.foo = 'hello';
    next();
});

The issue here is: in a new step def, this.foo will still be equal to bar when we actually wanted it to be equal to hello.

Report which steps are being executed

It can be hard to debug what's going on during a failing test. It would help if I could see the steps that Yadda was executing. My preferred way to implement this is to fire an event on the following conditions...

Yadda: start, success, error
Interpreter: start, success, error
Macro: start, success, error

Async

Is it possible to use this to perform async testing? If so can you provide an example where each step needs to perform an async action?

Problem with jasmine example in yadda

Hi!
When I try to setup Jasmine example
D:\yadda-master\examples\jasmine\spec>jasmine-node bottles-spec.js

I see this error:
Exception loading: D:\yadda-master\examples\jasmine\spec\bottles-spec.js
[TypeError: Cannot call method 'init' of undefined]

Could you explain, please, what I did wrong?

@Pending not working?

Hi! It seems that even though @pending has been documented as a way to mark a scenario as pending, for us it doesn't seem to have any effect. Is this a bug or am I maybe doing something wrong?

Feature: US-123
@Pending
Scenario: Implement something

    Given user is on the result page
    Then the page title should be ...
    Then the header title should be ...

Improve Mocha DSL mapping.

from the source code (MochaPlugin.js) it looks like you're mapping features to Mocha as follows:
Feature -> describe
Scenario -> it
Step (Unmapped)

This mapping causes a few problems:

  1. the Mocha reports now don't show the individual steps.
  2. Failures in a given step don't provide a clue which step failed, because steps are not mapped.

Many other implementation I've seen before and one I created myself map steps to it, to preserve Mocha's reporting.

Suggested mapping is:

Feature -> describe with 'Feature: ' prepended to feature summary text
Scenario -> describe with 'Scenario: ' prepended to scenario summary text
Step -> it with 'Given/When/Then ' prepended to step summary text

Prepending with the Guerkin keywords makes reports look consistent with feature definitions. So, instead of seeing:

  Mocha Asynchronous Example
    ✓ A bottle falls from the wall 
    - Bottles are reset

  1 passing (17ms)
  1 pending

you'll see:

  Feature: Mocha Asynchronous Example
    Scenario: A bottle falls from the wall
      ✓ Given 100 green bottles are standing on the wall
      ✓ When 1 green bottle accidentally falls
      ✓ Then there are 99 green bottles standing on the wall
    - Scenario: Bottles are reset

  5 passing (17ms)
  1 pending

and so with the proposed mapping, the following:

Feature: Example feature
  As a very lazy programmer
  I want to write some feature file
  So that I can quickly make my mocha

  Scenario: Reading the tests
    Given I am in the test directory
    When I read the index.js file
    Then I should see "new Parser" somewhere

is expected to resolve to:

describe("Feature: Example feature", function() {
  describe("As a very lazy programmer I want to write some feature file So that I can quickly make my mocha", function() {
    describe("Scenario: Reading the tests", function() {
      it("Given I am in the test directory", function() {
      });
      it("When I read the index.js file", function() {
      });
      it("Then I should see 'new Parser' somewhere", function() {
      });
    });
  });
});

Here's a few more references that use the same mapping:
https://github.com/mklabs/mocha-gherkin
https://github.com/searls/jasmine-given

Convert step parameters to a defined type

I should be possible to define a type (or converter) for a parameter. This will help avoid a common bug where strings should really be integers, but also help simply the code within the steps.

One approach would be to enhance the dictionary object, but it's proving quite difficult. I think I'm going to need to refactor how the steps are parsed and break them down into a tree of terms, values, patterns and expressions.

Add feature explanation

Feature: Descriptive feature files
  In order to communicate the added value of a feature and adhere to the cucumber style
  As a feature document writer
  I want to add some descriptive text to the feature heading without having to use comments

@example
Scenario: Feature file with descriptive text
  Given this feature file
  When run through the feature parser
  It should skip the  lines between the Feature line and the first line that has an annotation or scenario start
  And it should not fail with a 'missing scenario' error

Better explanation of context

see also https://github.com/acuminous/yadda#contexts-shared-state

Its a bit vague description, but as I understand it the context will be passed into the function's this object

// in the bottles-test.js
var context = {
  foo: 'bar'
  bar: function(number) { return new Wall(number) }

var yadda = new Yadda.yadda(library, context);

// 

var library = new Library()
    .given("$NUM green bottles are standing on the wall", function(number, next) {
       this.foo.should.equal('bar')
       wall this.bar(number) // would give me a new wall
       next();
    }) 

correct?

Reuse scenarios

For setting up a common structure. Cucumber uses a Background that is run at the start of each scenario.

Would like to see named backgrounds, that I can specify in a scenario: Given background A, and perhaps also backgrounds referring another background (circular references may throw errors).

Updated Mocha documentation

You mention that in the latest version there are breaking changes, but there is no documentation I can find around this. I know there are examples to look at in the repo, however they dont seem to work for me, I keep getting:

Error: TypeError: Cannot call method 'push' of undefined
    at Suite.<anonymous> (C:\Code\Archive\Guff\node\express\test\node_modules\yadda\lib\plugins\MochaPlugin.js:28:23)
(See full trace by running task with --trace)

When following the examples, so are the examples up to date and if not could the documentation reflect this? If however they are up to date examples any ideas whats causing the issue above?

The code being used is:

var yadda = require("yadda").Yadda;
require("yadda").plugins.mocha();

var functions = require("./functions/example-functions");
var yaddaContainer = new yadda(functions);
yaddaContainer.mocha("Bottle Tests", "./tests/acceptance/features/example-test.feature");

I assume its the require("yadda").plugins.mocha() but dont know specifically what will be causing it.

Execute multiple features from a single test

Yadda should provide a mechanism to execute multiple scenarios from a single test.
I propose changing the mocha library feature method accept

  • A file path (as it does currently)
  • An array of filepaths
  • A FeatureFileFinder object, which will provide an array of file paths

The FeatureFileFinder would look in some known locations place (e.g. anything below ./feature ./features, ./spec, ./specification) etc, for files matching a given pattern (e.g. *.feature, *.spec, *.specification)

If a user has a different naming convention Yadda should provide base classes for creating custom FeatureFileFinders

Error: Scenario requires one or more steps

Scenario: Simple Scenario
    Given A
    When B
    Then C

Generate Error: Scenario requires one or more steps.
Why require an empty line between Scenario and steps , users can forget.

"+" in a step definition causes Undefined Step error

It looks like using a step with a "+" in the step definition is causing an Undefined Step error.

For example, writing the feature file:
When I navigate to a music track page
Then I see a Google+ content panel

with the step definition:
library.then("Google+ links to content for sharing", function(next){
next()
});

causes the following error:
Uncaught Error: Undefined Step: [Then I see Google+ content for sharing]

Changing the wording from "Google+" to "Google Plus" fixes the issue, so it seems that the setup and logic elsewhere is correct.

Listing undefined steps

Feature: missing steps
  In order to help me getting started implementing the library
  As a user of yadda
  I want to have a quick summary of missing steps and the minimal code for implementation like cucumer

Scenario: 1 or more steps are not imlemented
 Given a scenario
 And some steps of the scenario have no matching definition in the used library
 When running the test via mocha
 Then I should get a quick overview of the missing steps 
 And per missing step a suggestion like '.given("$NUM green bottles are standing on the wall", function(number, next) { next(); /* Is there also a pending variant? */ })'
 And no stack trace, as it has no meaning to see it failed in 'clear winner' 

Something wrong with my Dictionary Selector?

Hey,

Sorry to raise a new issue so quickly, but im a bit confused as to why my selector is always bringing back "undefined".

Here is the code:

var dictionary = new Dictionary()
        .define('VERSION', /(\d.\d.\d.\d)|(\d.\d.\d)|(\d.\d)|(\d)/);

    var library = new Library(dictionary)

    .given("data at version $VERSION", function(version, next) {
            console.log("VERSION: " + version);
        data = dataFactory.GetDataForVersion(version);
        next();
    })

The regex seems right, and I was verifying it on rubular first

image

So are there any quirks around how I should be selecting variable content?

Error: Scenario requires one or more steps

Hi,

I get this error:
[Error: Scenario requires one or more steps]
when I have do not leave a line inbetween Scenario and Given statements.

For example, I get the above error when I have scenario like this:
Scenario: Google Search
Given I am on the Google home page

Whereas, it works when I have it like this with a line space between Scenario and Given:
Scenario: Google Search

Given I am on the Google home page

Can you please help?

Using Scénario in french feature file make parser fail

The following french feature file make parser fail:

Fonctionnalité: la page Linuxfr.org

  Scénario: Ouverture de la page

    étant donné un navigateur
    quand on ouvre l'url http://linuxfr.org
    alors la page d'accueil de Linuxfr s'ouvre

../../node_modules/mocha/bin/mocha --reporter spec page_test_fr.js

/home/poum/node_modules/yadda/lib/parsers/FeatureParser.js:127
        if (!feature) throw new Error('A feature must contain one or more scen
                            ^
Error: A feature must contain one or more scenarios
...

But this feature file is ok:

Fonctionnalité: la page Linuxfr.org

  Scenario: Ouverture de la page

    étant donné un navigateur
    quand on ouvre l'url http://linuxfr.org
    alors la page d'accueil de Linuxfr s'ouvre

Only "Scénario" is modified in "Scenario".

Same error with 'scénario', same success with 'scenario' ...

accented characters

There is a problem with accented characters such as é, à, ç ...

If we add é in examples examples/mocha-sync/features/bottles.feature and examples/mocha-sync/bottles-library.js
(write wallé instead of wall ) then mocha fail

  Mocha Synchronous Example
    ? A bottle falls from the wall 
    1) No bottles are left
    - Bottles are reset
    2) 100 bottles are standing on a wall
    3) 99 bottles are standing on a wall
    4) 10 bottles are standing on a wall


  ? 4 of 6 tests failed:

  1) Mocha Synchronous Example No bottles are left:
     Error: Scenario cannot be interpreted
Given 1 green bottles are standing on the wall <-- Undefined Step
when 1 green bottle accidentally falls
then there are 0 green bottles standing on the wall

Allow multiple pending translation

Hello

Is it possible to allow multiple translation for keyword Pending in localisation.
A bit like this: pending: '(: [Ee]n attendant|[Ee]n cours|[Tt]odo)'

Thank
Ami44

Provide an api for starting and stepping through yadda tests

Yadda control flow is currently imperical - the Yadda class, runs the interpreter, which iterates over the steps and runs them. Yadda would be improved if control flow was triggered from events such as

yadda.start, yadda.stop, yadda.next, yadda.reset
interpreter.start, interprter.next, interpreter.step
etc.

The default implementation would automatically fire these events as steps and scenarios were completed, so no change would be apparent, but we could also substitute the default driver with alternative implementations enabling remote control from a UI similar to selenium's

yadda & mocha & express

I search an example with yadda + mocha + expressjs.

Is yadda users could share an example ?

Ami44

pending library steps

Feature: pending steps
  In order to have a working library
  As a feature library developer
  I want to mark some steps as pending

Scenario: Making the test runnable with all steps pending
 Given a feature file with scenarios and steps
 and no time to develop the complete library required for it
 and I create the step definitions in the library
 and use next().pending or something like it as step definition
 When I run the tests using eg mocha (or framework that supports pending tests)
 Then the feature must be runnable
 and not produce errors
 and not produce failing tests
 but scenarios should be marked as pending

Scenario: Making the test runnable with some steps pending
 Given a feature file with scenarios and steps
 and no time to develop the complete library required for it
 and I create the step definitions in the library
 and use next().pending or something like it as step definition for some steps
 and next() for the other steps without any failing assertions
 When I run the tests using eg mocha (or framework that supports pending tests)
 Then the feature must be runnable
 and not produce errors
 and not produce failing tests
 but scenarios having one or more steps marked pending should be marked as pending 
 and scenarios having no steps marked pending should be normally run and not marked pending

Can't write file from within library step

Hello. Been trying to write a json object out to file within a step so I can check the content is correct. Interestingly, I am unable to use fs.writeFile within the library file, as it is undefined.
i.e.

.then("I should see the resource $TYPES",function(type, next){
    casper.then(function(){
        var content = JSON.parse(this.getPageContent());

        fs.writeFile('/tmp/t.json',content,function(err){
        })  //fails (undefined)

        //and

        console.log(fs.writeFile) //undefined

        expect(content).to.have.property("Reservations");
     })
})

Do you have any idea what is causing the writeFile to be unbound (and others) i.e. readFile fails too..

Thanks

newbie multiples *-library.js

With exemple https://github.com/acuminous/yadda/tree/master/examples/mocha-async.

I duplicate bottles.feature to tests.feature and duplicate bottles-library.js to tests-library.js

How adapt test.js to associate each *.feature to *-library.js

I not found multiples features examples
Thank
Ami44

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.