Giter Club home page Giter Club logo

data-driven's People

Contributors

ajcrews avatar danbehar avatar gcs-github avatar mjtodd avatar mortonfox avatar robertknight avatar zachlysobey 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

data-driven's Issues

Promise support

A question, really.

We've started using promises for a lot of our tests in order to get a cleaner, more readable structure.
We're using mocha-as-promised (previously just used co), which gives us tests which look like this:

it('some stuff', function * () {
  const value = yield someService.somePromise()
  expect(value).to.equal(5)
})

I can't seem to get data-driven to wrap this, as much as I'd like to. How difficult would it be (or is it already possible) to use data-driven along with generator functions?

Happy to do a PR if it's something that you think could be accomplished.

mocha pending functions don't work

When using data-driven, the mocha functions like it.only() and it.skip() don't work.

it.skip("Add an offer", function(data, done){
  ^  
  TypeError: Object function (title, f) {

    for (var key in testData) {
      title = title.replace('{'+key+'}',testData[key])
    }  

    var testFn = f.length < 2 ?  
      function() {
        f(testData)
      } :  
      function(done) {
        f(testData,done)
      }  

  mochaIt(title, testFn)
  } has no method 'skip' 

Support for promises

Mocha allows returning promises for async data handling.

Are there any plans to add support for this?

See the following for a test case where the test will fail as expected using mocha, but will pass using data driven.

var data_driven = require('data-driven')

var makeRejectPromise = function() {
    return new Promise(function (fulfill, reject){
     reject();
   });
};

describe('Array', function() {
  describe('#indexOf()', function(){
        data_driven([{value: 0},{value: 5},{value: -2}], function() {
            it('should return -1 when the value is not present when searching for {value}', function(ctx){
                return makeRejectPromise();
            })
        })
    })
})

describe('Array', function() {
  describe('#indexOf()', function () {
    it('should return -1 when the value is not present', function () {
      return makeRejectPromise();
    });
  });
});

See https://github.com/mochajs/mocha/blob/2.3.0/mocha.js#L4225 for where the mocha code looks at the result to evaluate the promise.

Dynamic scenario data doesn't work

If I want to build data dynamically, such as a series of db insertions where i later grab the database id, or the result of a promise, it isn't possible with this library.

It seems that because data has to be defined outside the 'it' clause, it is solidified before any before methods can modify the data.

Before/After not working

First, thanks for writing this module. I would hope to use it if this issue can be resolved.

It looks like, if you need to use "before" to set up your test data, the data_driven method executes before "before" such that the test data is empty for the wrapped tests. I'm not an expert on how mocha executes so I'm not sure if this is something you can address or not.

Please let me know. If I get time I will try and address it and submit a pull request.

Support browser environments

Hello,

In the source, the dataDriven function is exported using the CommonJS way.

But I need to use either requireJS or a script tag. As Mocha support browser environments, what do you think of that enhancement?

Florent

Describe strings within data_driven hook not updated

The keywords within the describe() string are not replaced with the test data {width} and {height}

data_driven(viewportSizes, function () {

            describe('Browser Viewport for width {width} and height {height}', function () {

                before(function (ctx) {
                    browser.setViewportSize({width: ctx.width, height: ctx.height});
                });

Get test data before test-driven method call

Hi,

Thank you for this cool lib!

One question. I need to get my test data array in a async before function. How can I do it with this library?

var data_driven = require('data-driven')
var assert = require('assert');

describe('Array', function() {
  describe('#indexOf()', function(){
    this.devices = [];
    var self = this;

    before(function(done) {
      getAllConnectedDevices(function(devices) {
        self.devices = devices;
        done();
      });
    })

    data_driven(self.devices, function() {
        it('should return -1 when the value is not present when searching for {os}', function(ctx, done){
            console.log('asasd');
            assert.equal(-1, [1,2,3].indexOf(ctx.value));
            done();
        })
    })
  })
})

self.devices is always empty like it is above.

Thanks!

Regards,
Riaan

problem with installing using yarn

tried to install

sudo yarn add data-driven
yarn add v0.23.4
[1/4] Resolving packages...
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">= 6.9.0".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

checked my node.js version

node --version
v7.8.0

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.