Giter Site home page Giter Site logo

Comments (4)

juniorplenty avatar juniorplenty commented on July 19, 2024

+1

from api-easy.

jeden avatar jeden commented on July 19, 2024

+1

from api-easy.

cronopio avatar cronopio commented on July 19, 2024

The next() method can give you some kind of flow control.
For tasks before run the tests like load, configure an run some server or prepopulate the database you can do something like:

var async = require('async');

function seedDatabase () {
  return {
    "Setting up the tests": {
      "seeding the database": {
        topic: function () {
          async.series([
            function destroy () {
              // With your favorite dabatase client drop the database
            },
            function create () {
              // Create the database with the respective name
            },
            function seed () {
              // Insert the docs necessary for run the tests, dumb data.
              // Here you can use external data from json or whatever.
            }
          ], this.callback);
        },
        "should seed the database": function (err) {
          assert.isNull(err);
        }
      }
    }
  }
}
// Off course the use of async is optional.

You can do a similar thing for others hooks like after, before and just use addBatch method for added to the test suite.

suite.discuss('.....').use('localhost'. 3001)
  .addBatch(seedDatabase())  // NOTE here the use of the function.
  // You can do the same for others hooks
  .addBatch(setupTheApp())
  .addBatch(beforeGet())
  .get('/').expect(....)
  .addBatch(afterGet())
  .next()
  .addBatch(beforePost())
  .post('/').expect(....)
  .addBatch(afterPost())
  .next()
  .addBatch(tearDown())
  .export(module);

I Hope helps.

from api-easy.

mmalecki avatar mmalecki commented on July 19, 2024

@cronopio explained it quite well. Closing.

from api-easy.

Related Issues (20)

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.