Giter Club home page Giter Club logo

assert-request's People

Contributors

plasmapower 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

Watchers

 avatar  avatar  avatar  avatar

Forkers

laggingreflex

assert-request's Issues

Support async assertions

This is supported by supertest

request.get('/foo').assert(res => myPromiseAssertion(res))

Should be a simple change to something like:

'use strict';

const assert = require('assert');

module.exports = {
  assert: function (fn) {
    return this.then(function (res) {
      return Promise.resolve(fn(res))
        .then(value => assert(value))
        .then(() => res);
    });
  }
};

"Did not receive valid JSON" when json: true is passed in

$ cat test_app.js
/* eslint-env node,mocha */
var express = require('express');
var app = express();

app.post('/', function (req, res) {
  res.json({
    'response_type': 'ephemeral',
    'text': 'hi there\nhi\n'
  });
});

var AssertRequest = require('assert-request');
var request = AssertRequest(app.listen());

describe('basic', function () {
  it('json.post', function () {
    return request.post('/', {
      body: { 'key': 'value' },
      json: true
    })
      .type('application/json')
      .status(200)
      .json({
        'response_type': 'ephemeral',
        'text': 'hi there\nhi\n'
      });
  });
});

json: true in request will automatically encode the sending and receiving body.

One possible fix is to check if (typeof res.body === 'object') in mixins/json.js but I'm not sure its the best solution so havn't submitted a PR.

A cookies mixin

A cookies mixin could be very helpful in some cases in simplifying use cases of the header mixin.

Add LICENSE file or a section in README

Please consider to make the license more clear adding a LICENSE file at the root of the repo or mentioning it in a "license" section in the README.

I know that package.json has it, but I think that one of those solutions would make it very visible.

Thanks for the module and release it under MIT

More (working) examples

I really like the idea of this. But I can't get it to work (Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.).
I would really appreciate a whole lot more of examples and may be links to projects that are already using it.

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.