strongloop-archive / loopback-testing

DEPRECATED Utilities for testing LoopBack apps
Other
8 stars 20 forks source link

Proposal: API change #1

Open bajtos opened 10 years ago

bajtos commented 10 years ago

I am proposing two changes:

  1. Make this module a collection of utilities, i.e. move the current implementation out of /index.js into lib/ folder, change the way how the module is used:

    var lt = require('loopback-testing').TestCaseHelper;
    lt.describe(/* ... */)
    
    // this way I can add my new code as
    var TestDataBuilder = require('loopback-testing').TestDataBuilder;
  2. Add a function that will merge install describe/it/etc. as globals, possibly extending symbols already defined by Mocha.

    require('loopback-testing').mocha('bdd');
    // now I can write
    //   describe.whenCalledRemotely
    //   given.model('Product', /*.. */)

    Later we can implement support for other interfaces than bdd and possibly other test frameworks like TAP.

@ritch what's you opinion? What was the reason why you decided to not amend mocha's global symbols, as we discussed in the other pull request?

Perhaps the second point should be implemented by a standalone module depending on loopback-testing, e.g. loopback-mocha?

ritch commented 10 years ago

I couldn't consistently modify the globals. Either mocha is resetting them for each test or my implantation was some how flawed. I'd rather do it that way, but not certain it is possible.

On Dec 11, 2013, at 7:04 AM, Miroslav Bajtoš notifications@github.com wrote:

I am proposing two changes:

Make this module a collection of utilities, i.e. move the current implementation out of /index.js into lib/ folder, change the way how the module is used:

var lt = require('loopback-testing').TestCaseHelper; lt.describe(/* ... */)

// this way I can add my new code as var TestDataBuilder = require('loopback-testing').TestDataBuilder; Add a function that will merge install describe/it/etc. as globals, possibly extending symbols already defined by Mocha.

require('loopback-testing').mocha('bdd'); // now I can write // describe.whenCalledRemotely // given.model('Product', /.. /) Later we can implement support for other interfaces than bdd and possibly other test frameworks like TAP.

@ritch what's you opinion? What was the reason why you decided to not amend mocha's global symbols, as we discussed in the other pull request?

Perhaps the second point should be implemented by a standalone module depending on loopback-testing, e.g. loopback-mocha?

— Reply to this email directly or view it on GitHub.

bajtos commented 10 years ago

The first item was implemented by #2.