GithubHelp home page GithubHelp logo

abao's Introduction

abao's People

Contributors

abartomeubonillo avatar aldonline avatar bitdeli-chef avatar coltonlw avatar cybertk avatar davidrichard2016 avatar fleischers avatar galkin avatar gitter-badger avatar greenkeeperio-bot avatar liweinan0423 avatar plroebuck avatar prayagverma avatar proloser avatar rheda-atlassian avatar suelje 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

abao's Issues

Error from csonschema

I'm trying to run abao on my RAML, the RAML should be ok cause I'm also using other tools on it.
I get an error probably because I have a schema with type array, it's a valid json schema I tested with validators. Unfortunately the stack trace doesn't say exactly where the problem occurred in the RAML file.

$ abao vSTB.raml http://localhost:3333
/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:235
throw error;
^

Error: Type is not defined: array
at _parseCustomizedType (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:27:13)
at _parseString (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:155:16)
at _parseField (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:48:14)
at _parseObj (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:75:25)
at _parseField (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:46:14)
at _parseFromObj (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:220:18)
at Object.parse (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:255:25)
at parseSchema (/usr/local/lib/node_modules/abao/lib/add-tests.coffee:14:25)
at /usr/local/lib/node_modules/abao/lib/add-tests.coffee:82:36
at /usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:122:13
at _each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:46:13)
at Object.async.each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:121:9)
at /usr/local/lib/node_modules/abao/lib/add-tests.coffee:58:20
at /usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:122:13
at _each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:46:13)
at Object.async.each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:121:9)
at addTests (/usr/local/lib/node_modules/abao/lib/add-tests.coffee:40:18)
at /usr/local/lib/node_modules/abao/lib/abao.coffee:47:18
at fn (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:638:34)
at Immediate._onImmediate (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:554:34)
at processImmediate as _immediateCallback

Documentation is not clear

Issue reported by Abe via email.

I am looking at the documentation for abao, and I wonder if you have time to add a little bit more information. Maybe a few examples?

I ask because when abao validates the request body or the response body, it's not clear what 'validating the JSON schema' really means. It would be great to see an example that shows, okay, abao obtains a request body like this ... abao validates a response body like this ...

Also I notice that the Mocha link in the README is broken.

If you write something up, I would be happy to edit it. So you can write it up in rough form, and I will polish it for you.

Question about usage

Hi

I am not sure, if I understand how you want people to use abao. I have specific use case and could you please tell me, if your concept suits that (or may suit after improvements).

I assume test for RAML should:

  • compose request basing on RAML definition file (I can't figure out how to make query params, also example values being used in test)
  • validate response basing on RAML definition file (json schema validation should be used, if defined, seems not working)
  • use predefined/mocked combinations of params

If we go out of RAML (I don't see that in RAML itself) testing great would be to test specific query to expect specific data returned.

Anyhow. Could you tell me, if abao is meant to cover that scenario and (regards issues in brackets) how we can address them?

console.log call from hook file does nothing

I've used the following hook to print out some data before test runs. Where can I see that string? Console doesn't show it. Is there a log file somewhere?

Hook file:

var hooks;
hooks = require('hooks');
hooks.before('GET /machines -> 200', function(test, done) {
console.log('!!!!!!!!!');
return done();
});

Maintaining Session State throughout the test

Maintaining Session State throughout the test

Is there any way in ABAO we can maintain the http session for all the test cases present in the hook file?

I have 100 endpoints, but it works only if first authentication endpoints run and rest of the endpoints works in the same session only.

error when installing abao

Steps done:

  1. git clone
  2. run npm install abao

After executing step 2 - I'm getting the following output:

npm install abao

[email protected] prepublish abao
grunt coffee

grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started
npm ERR! addLocalDirectory Could not pack "abao" to "/Users/christianmule/.npm/abao/0.2.2/package.tgz"
[email protected] ../../node_modules/abao
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected])

No cli output when beforeAll hook timeout

Give beforeAll hook likes this,

{beforeAll, afterAll} = require 'hooks'


beforeAll (done) ->
  console.log 'beforeAll'

afterAll (done) ->
  console.log 'afterAll'

When invoke abao api.raml http://localhost:3333 --hookfiles test/api/hooks/*

Got

Found Hookfiles: test/api/hooks/global_hooks.coffee
beforeAll

Testing requests with required queryParameters

Hello, is there a way, how to test request with required query params? I would add query param in a hook, but there is no such parsed info in test.request...

Thanks for the suggestions!

Hook file is not working

Hi,

I have created hook coffee script which looks like abao is not reading.

My RAML File look like:

#%RAML 0.8
baseUri: https://test.com/ssvui
title: Origin Api
version: 0.1

resourceTypes:
   - collection:
      description: |
        The <<resourcePathName>> collection.
      get:
        description: Get a list of <<resourcePathName>>.
        headers: &commonHeaders
          content-type:
            displayName: Content Type
            description: MIME type of document being served.
            example: "application/json"

          accept:
            displayName: Accept
            description: MIME types that client is willing to accept.
            example: "*/*"
        responses:
          200:
          500:
            body:
              application/json:
                example: |
                  {"message": "Internal server error" }
      post:
        headers: *commonHeaders
        description: |
          TBD
        body:
          application/json:
            example: <<exampleItemForCreate>>
        responses:
          200:
          302:
          500:
            body:
              application/json:
                example: |
                  {"message": "Internal server error" }

/j_spring_security_check:
    description: | 
      Login
    post:
        headers:
          accept:
            displayName: Accept
            description: MIME types that client is willing to accept.
            example: "*/*"
        queryParameters:
          j_username:
            description: QA_Autotest
            example: QA_Autotest
          j_password:
            description: QA_aut0test
            example: QA_aut0test
          response:
            description: light
            example: light
        body:
          application/json:
        responses:
          302:
            body:
              application/json:
                #schema: security
/auth:
    description: |
      Auth
    get:
        headers:
          accept:
            displayName: Accept
            description: MIME types that client is willing to accept.
            example: "*/*"
        responses:
          200:
            body:
              application/json:

/org/15602/activity:
  /{activityid}:
    description: |
      Activity
    get:
       headers:
         accept:
           displayName: Accept
           description: MIME types that client is willing to accept.
           example: "*/*"
       queryParameters:
         activityid:
           description: Activity
           example: 55493526
       responses:
          200:
            body:
              application/json:

Hook file:

{before, after} = require 'hooks'

before 'GET /j_spring_security_check -> 302', (test, done) ->
 test.request.params =
  j_username: 'username'
  j_pasword: 'test'
  response: 'light'
 done()

before 'GET /org/15602/activity/{activityid} -> 200', (test, done) ->
 test.request.params =
  activityid: '123'
 done()

before 'GET /org/15602/activity/{activityid} -> 200', (test, done) ->
 test.request.params =
  activityid: 'XYZ'
 done()

Can anyone help me on this?

Setting url placeholders thru hooks ?

Hi
Promising tool :)
I have url patterns like /user/{userid}, it is unclear on how to set userid thru hooks, since it is not a query parameter like ?a=b
Do you have an example ?

Schema makes ABAO cough up blood

So I have a SIREN-based API that I wanted to verify; I wrote a trivial JSONSchema
to get started which should have worked for anything. The schema and example validate with http://jsonschemalint.com/draft4/#.

Schema:

{
    "id": "http://jsonschema.net/entity-schema#",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Entity",
    "description": "schema for a SIREN hypermedia entity",
    "type": "object",
    "properties": {
        "title":      { "$ref": "#/definitions/title"      },
        "class":      { "$ref": "#/definitions/class"      },
        "properties": { "$ref": "#/definitions/properties" },
        "entities":   { "$ref": "#/definitions/entities"   },
        "actions":    { "$ref": "#/definitions/actions"    },
        "links":      { "$ref": "#/definitions/links"      }
    },
    "definitions": {
        "title": {
            "id": "#title",
            "type": "string"
        },
        "class": {
            "id": "#class",
            "type": "array",
            "items": {
                "type": "string"
            },
            "uniqueItems": true
        },
        "properties": {
            "id": "#properties",
            "type": "object"
        },
        "entities": {
            "id": "#entities",
            "type": "array",
            "items": {
                "type": "object"
            }
        },
        "actions": {
            "id": "#actions",
            "type": "array",
            "items": {
                "type": "object"
            }
        },
        "link": {
            "id": "#link",
            "type": "object",
            "properties": {
                "rel": {
                    "id": "#rel",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                },
                "href": {
                    "id": "#href",
                    "description": "URL",
                    "type": "string"
                },
                "type": {
                    "id": "#type",
                    "description": "mediaType",
                    "type": "string"
                }
            }
        },
        "links": {
            "id": "#links",
            "type": "array",
            "items": {
                "$ref": "#/definitions/link" 
            }
        }
    }
}

Here's an example:

{
  "class": [
    "api"
  ],
  "entities": [
    {
      "href": "http://127.0.0.1:8080/api/heatmaps",
      "type": "application/vnd.siren+json",
      "rel": [
        "collection",
        "self"
      ]
    }
  ],
  "links": [
    {
      "href": "http://127.0.0.1:8080/api",
      "type": "application/vnd.siren+json",
      "rel": [
        "self",
        "top"
      ]
    },
    {
      "href": "http://127.0.0.1:8080/api/help",
      "type": "text/html",
      "rel": [
        "help"
      ]
    },
    {
      "href": "http://127.0.0.1:8080/api/profile",
      "type": "application/raml+yaml",
      "rel": [
        "profile"
      ]
    }
  ]
}

Result:


abao api.raml http://127.0.0.1:8080 --hookfiles=hooks/*_hooks.js

/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:235
          throw error;
                ^
SyntaxError: Syntax error on line 1, column 1: Unexpected token s
  at nodeTransforms.Literal (/usr/local/lib/node_modules/abao/node_modules/csonschema/node_modules/cson-parser/lib/parse.js:106:15)
  at transformNode (/usr/local/lib/node_modules/abao/node_modules/csonschema/node_modules/cson-parser/lib/parse.js:203:12)
  at nodeTransforms.Value (/usr/local/lib/node_modules/abao/node_modules/csonschema/node_modules/cson-parser/lib/parse.js:83:14)
  at transformNode (/usr/local/lib/node_modules/abao/node_modules/csonschema/node_modules/cson-parser/lib/parse.js:203:12)
  at nodeTransforms.Block (/usr/local/lib/node_modules/abao/node_modules/csonschema/node_modules/cson-parser/lib/parse.js:80:14)
  at transformNode (/usr/local/lib/node_modules/abao/node_modules/csonschema/node_modules/cson-parser/lib/parse.js:203:12)
  at Object.parse (/usr/local/lib/node_modules/abao/node_modules/csonschema/node_modules/cson-parser/lib/parse.js:209:12)
  at Object.parse (/usr/local/lib/node_modules/abao/node_modules/csonschema/lib/index.js:247:23)
  at parseSchema (/usr/local/lib/node_modules/abao/lib/add-tests.js:16:25)
  at async.each.addTests.path (/usr/local/lib/node_modules/abao/lib/add-tests.js:83:36)
  at /usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:122:13
  at _each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:46:13)
  at Object.async.each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:121:9)
  at /usr/local/lib/node_modules/abao/lib/add-tests.js:59:20
  at /usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:122:13
  at _each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:46:13)
  at Object.async.each (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:121:9)
  at addTests (/usr/local/lib/node_modules/abao/lib/add-tests.js:41:18)
  at /usr/local/lib/node_modules/abao/lib/abao.js:44:18
  at fn (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:638:34)
  at Object._onImmediate (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:554:34)
  at processImmediate [as _immediateCallback] (timers.js:330:15)

Any ideas?

N.B. Be gentle... it's my first GitHub issue...

abao fails when testing RAML-JAXRS demo application

Testing this application: https://github.com/mulesoft/raml-for-jax-rs/blob/master/raml-to-jaxrs/examples/jersey-example/src/main/resources/raml/sales-enablement-api.raml

curling is fine:

$ curl -H "Authorization: s3cr3t" http://localhost:8181/presentations?title=Some%20title
{"size":1,"presentations":[{"id":"fake-id","title":"Some title"}]}

abao output:

$ abao src/main/resources/raml/sales-enablement-api.raml http://localhost:8181/ -h "Authorization: s3cr3t"

undefined:1
undefined
^
SyntaxError: Unexpected token u
  at Object.parse (native)
  at async.each.addTests.path (/usr/lib/node_modules/abao/lib/add-tests.js:48:38)
  at /usr/lib/node_modules/abao/node_modules/async/lib/async.js:125:13
  at Array.forEach (native)
  at _each (/usr/lib/node_modules/abao/node_modules/async/lib/async.js:46:24)
  at Object.async.each (/usr/lib/node_modules/abao/node_modules/async/lib/async.js:124:9)
  at /usr/lib/node_modules/abao/lib/add-tests.js:36:20
  at /usr/lib/node_modules/abao/node_modules/async/lib/async.js:125:13
  at Array.forEach (native)
  at _each (/usr/lib/node_modules/abao/node_modules/async/lib/async.js:46:24)
  at Object.async.each (/usr/lib/node_modules/abao/node_modules/async/lib/async.js:124:9)
  at addTests (/usr/lib/node_modules/abao/lib/add-tests.js:18:18)
  at /usr/lib/node_modules/abao/lib/abao.js:40:18
  at fn (/usr/lib/node_modules/abao/node_modules/async/lib/async.js:641:34)
  at Object._onImmediate (/usr/lib/node_modules/abao/node_modules/async/lib/async.js:557:34)
  at processImmediate [as _immediateCallback] (timers.js:345:15)

Suspecting -h "Authorization: s3cr3t" is not the right syntax for specifying a header (can't find any example), I removed the authentication from the API and tried again with just:

$ abao src/main/resources/raml/sales-enablement-api.raml http://localhost:8181/

But the issue is the same, I get the same exception as above.

Ability to override endpoints ordering

Currently the parser produces a list of endpoints given the raml.

For example the POST and DELETE are listed before the GET. When I need a scenario like : post first, then get, then delete, it fails because get will be called after delete, because it follows the endpoints order. For this to work I have to split my scenario in multiple files, and call them in the right order. Not very handy.

If we could alter the order with a custom endpoints order it would solve it :) It would allow me to write an ordering specifically for my use case.

Ability to set response timeout

Hi

It is currently impossible to configure the default timeout of 2000ms

     Error: timeout of 2000ms exceeded
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:158:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Would be nice :)

abao fails when run with hooks for example from README

$ abao login.raml http://localhost --hookfiles=*.hook
Found Hookfiles: login.hook

(exports, require, module, __filename, __dirname) { {before, after} = require
^
Skipping hook loading...
Error reading hook files (login.hook)
This probably means one or more of your hookfiles is invalid.
Message: Unexpected token =
Stack: SyntaxError: Unexpected token =
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Object.require.extensions.(anonymous function) (/usr/local/lib/node_modules/abao/node_modules/proxyquire/lib/proxyquire.js:235:43)
at Module.load (/usr/local/lib/node_modules/abao/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at Proxyquire._withoutCache (/usr/local/lib/node_modules/abao/node_modules/proxyquire/lib/proxyquire.js:169:12)
at Proxyquire.load (/usr/local/lib/node_modules/abao/node_modules/proxyquire/lib/proxyquire.js:131:15)
at addHooks (/usr/local/lib/node_modules/abao/lib/add-hooks.js:25:23)
at /usr/local/lib/node_modules/abao/lib/abao.js:42:11
at fn (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:641:34)
at Object._onImmediate (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:557:34)
at processImmediate as _immediateCallback

npm test fails on Windows

Hi.

I cannot run npm test on Windows.
Do you have any tips/help?

>npm test

> [email protected] test C:\abao
> grunt test

Running "coffeecov:compile" (coffeecov) task
>> Annotated 250 lines.

Running "mochaTest:test" (mochaTest) task


  Abao
    #constructor
      with valid config
        √ should created a new instance
    #run
      √ should invoke callback

  addHooks(hooks, pattern, callback)
    with no pattern
      √ should return immediately
    with valid pattern
      √ should return files (1250ms)
      when files are valid js/coffeescript
        1) should load the files
        2) should attach the hooks
      when there is an error reading the hook files
        √ should log an warning
        √ should not attach the hooks

  #addTests
    #run
      when raml contains single get
        √ should run callback
        √ should added 1 test
        √ should set test.name
        √ should setup test.request
        √ should setup test.response
      when raml contains one GET and one POST
        √ should run callback
        √ should added 2 test
        √ should setup test.request of POST
        √ should setup test.response of POST
      when raml contains three-levels endpoints
        √ should run callback
        √ should added 3 test
        √ should set test.name
        √ should set request.param of test 1
        √ should set request.param of test 2
      when raml has resource not defined method
        √ should run callback
        √ should added 1 test
        √ should set test.name
      when raml has invalid request body example
        √ should run callback
        √ should give a warning
        √ should added 1 test

  Hooks
    when adding before hook
      √ should add to hook collection
    when adding after hook
      √ should add to hook collection
    when adding beforeAll hooks
      √ should invoke registered callbacks
    when adding afterAll hooks
      √ should callback if registered
    when check has name
      √ should return true if in before hooks
      √ should return true if in after hooks
      √ should return true if in both before and after hooks
      √ should return false if in neither before nor after hooks
    when running hooks
      with correponding test
        on before hook
          √ should run hook
          √ should pass #test to hook
        on after hook
          √ should run hook
          √ should pass #test to hook
      with incorreponding test
        on before hook
          √ should not run hook
        on after hook
          √ should not run hook
    when running beforeAll/afterAll
      on beforeAll hook
        √ should invoke callback
        √ should run hook
      on afterAll hook
        √ should invoke callback
        √ should run hook

  Test Runner
    #run
      when test is valid
        √ should generate beforeAll hooks
        √ should run mocha
        √ should invoke callback with failures
        √ should generated mocha suite
        √ should generated mocha test
        √ should generated hook of suite
      Interact with #test
        √ should called #test.run
      when test has no respones code
        √ should run mocha
        √ should generated mocha suite
        √ should generated pending mocha test
      when test has no response schema
        √ should run mocha
        √ should generated mocha suite
        √ should not generated pending mocha test
      when test throws AssertionError
        √ should call afterAll hook
      when beforeAllHooks throws Uncaught Error
        √ should call afterAll hook
    #run with options
      list all tests with `names`
        √ should not run mocha
        √ should print tests
      add additional headers with `headers`
        √ should run mocha
        √ should add headers into test
      run test with hooks only indicated by `hooks-only`
        √ should run mocha
        √ should add a pending test

  Test
    #run
      of simple test
        √ should call #request
        √ should not modify @name
        √ should not modify @request
        √ should update @response
      of test contains params
        √ should call #request
        √ should not modify @name
        √ should not modify @request
        √ should update @response
    #url
      when call with path does not contain param
        √ should return origin path
      when call with path contains param
        √ should replace all params
        √ should not touch origin request.path
    #assertResponse
      when against valid response
        √ should should pass all asserts
      when response body is null
        √ should throw AssertionError (90ms)
      when response body is invalid json
        √ should throw AssertionError

  Command line interface
    When raml file not found
      √ should exit with status 1
      3) should print error message to stderr
    Arguments with existing raml and responding server
      when executing the command and the server is responding as specified in the raml
        4) exit status should be 0
        5) should print count of tests will run
        6) should print correct title for response
      when executing the command and raml includes other ramls
        7) exit status should be 0
        8) should print count of tests will run
    when called with arguments
      when using additional reporters with -r
        9) should print using the new reporter
      when adding additional headers with -h
        10) should have an additional header in the request
        11) exit status should be 0
        12) should print count of tests will run
      when printing test cases with -n
        13) exit status should be 0
        14) should print names
        √ should not run tests
      when loading hooks with --hookfiles
        15) should modify the transaction with hooks
        16) should print message to stdout and stderr
      when run with --hooks-only
        17) exit status should be 0
        18) should not run test without hooks
      when run with --timeout
        √ exit status should be 1
        19) should exit before timeout
        20) should not run test without hooks
      when run with --reporters
        21) exit status should be 0
        √ should print reporters same as `mocha --reporters`


  83 passing (9s)
  21 failing

  1) addHooks(hooks, pattern, callback) with valid pattern when files are valid js/coffeescript should load the files:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at C:\abao\test\unit\add-hooks-test.coffee:66:11
    at Context.<anonymous> (C:\abao\test\unit\add-hooks-test.coffee:61:9)


  2) addHooks(hooks, pattern, callback) with valid pattern when files are valid js/coffeescript should attach the hooks:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at C:\abao\test\unit\add-hooks-test.coffee:74:11
    at Context.<anonymous> (C:\abao\test\unit\add-hooks-test.coffee:69:9)


  3) Command line interface When raml file not found should print error message to stderr:
     AssertionError: expected '\'.\' �́A�����R�}���h�܂��͊O���R�}���h�A\r\n������\\�ȃv���O�����܂��̓o�b�` �t�@�C���Ƃ��ĔF�������Ă��܂����B\r\n' to include 'Error: ENOENT, open'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:49:14)


  4) Command line interface Arguments with existing raml and responding server when executing the command and the server is responding as specified in the raml exit status should be 0:
     AssertionError: expected 1 to equal 0
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:75:16)


  5) Command line interface Arguments with existing raml and responding server when executing the command and the server is responding as specified in the raml should print count of tests will
     TypeError: Cannot read property 'length' of undefined
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:78:37)


  6) Command line interface Arguments with existing raml and responding server when executing the command and the server is responding as specified in the raml should print correct title for r

     TypeError: Cannot read property '0' of undefined
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:82:35)


  7) Command line interface Arguments with existing raml and responding server when executing the command and raml includes other ramls exit status should be 0:
     AssertionError: expected 1 to equal 0
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:105:16)


  8) Command line interface Arguments with existing raml and responding server when executing the command and raml includes other ramls should print count of tests will run:
     AssertionError: expected '' to include '1 passing'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:108:16)


  9) Command line interface when called with arguments when using additional reporters with -r should print using the new reporter:
     AssertionError: expected '' to include '1 passing'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:133:16)


  10) Command line interface when called with arguments when adding additional headers with -h should have an additional header in the request:
     TypeError: Cannot read property 'accept' of undefined
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:160:45)


  11) Command line interface when called with arguments when adding additional headers with -h exit status should be 0:
     AssertionError: expected 1 to equal 0
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:163:16)


  12) Command line interface when called with arguments when adding additional headers with -h should print count of tests will run:
     AssertionError: expected '' to include '1 passing'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:166:16)


  13) Command line interface when called with arguments when printing test cases with -n exit status should be 0:
     AssertionError: expected 1 to equal 0
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:176:16)


  14) Command line interface when called with arguments when printing test cases with -n should print names:
     AssertionError: expected '' to include 'GET /machines -> 200'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:179:16)


  15) Command line interface when called with arguments when loading hooks with --hookfiles should modify the transaction with hooks:
     TypeError: Cannot read property 'header' of undefined
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:210:46)


  16) Command line interface when called with arguments when loading hooks with --hookfiles should print message to stdout and stderr:
     AssertionError: expected '' to include 'before-hook-GET-machines'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:214:16)


  17) Command line interface when called with arguments when run with --hooks-only exit status should be 0:
     AssertionError: expected 1 to equal 0
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:239:16)


  18) Command line interface when called with arguments when run with --hooks-only should not run test without hooks:
     AssertionError: expected '' to include '1 pending'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:242:16)


  19) Command line interface when called with arguments when run with --timeout should exit before timeout:
     AssertionError: expected false to be truthy



  20) Command line interface when called with arguments when run with --timeout should not run test without hooks:
     AssertionError: expected '' to include '0 passing'
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:270:16)


  21) Command line interface when called with arguments when run with --reporters exit status should be 0:
     AssertionError: expected 1 to equal 0
    at Context.<anonymous> (C:\abao\test\cli-test.coffee:281:16)




Warning: Task "mochaTest:test" failed. Use --force to continue.

Aborted due to warnings.


Execution Time (2015-05-16 14:40:48 UTC)
loading grunt-coffeecov   240ms  ███ 1%
coffeecov:compile         860ms  ████████ 5%
loading grunt-mocha-test  359ms  ████ 2%
mochaTest:test              17s  ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 92%
Total 18.5s

npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

Couldn't send url encoded form params

The server receives the url encoded form params as single entry with param "key" populated with whole thing mentioned for "test.request.body" in raml file and param "value" as empty string. Like,

key = {"id": "...", "imageType": "...", "imageBase64Encoded": "..."}, value = ""

Note: I don't have any problem with RAML file.

Hookup file:
hooks.before('POST /v1/foo -> 200', function (test, done) {

test.request.headers = {
    'Authorization': 'Bearer ' + '77aacdc2-49ea-32cd-8772-e90f3f3e1325',
    'Content-Type': 'application/x-www-form-urlencoded'
};
test.request.body = {
    id: '...',
    imageType: 'image/png',
    imageBase64Encoded: '....'
}

}

Features desired

  • test.request.body should be object when Content-Type is application/json
  • Should not display pending test if invoke abao with --hook-only
  • Should give a warning if Content-Type is not application/json
  • Should give a warning if hook is ignored
  • Let hook's done param optional
  • Validate fail if an array field contains no elements
  • gulp-abao
  • grunt-abao
  • abao-example

Duplicate URI

This is what I'm seeing when I try to use abao for the first time. No idea what I'm doing wrong:

abao -f "hooks/*" _browse.raml /browse/items/{browse_type}/filter/{filter_type}/sort/{sort_method}/offset/{offset}/size/{size}
Found Hookfiles: hooks/browse.js


  GET /browse/items/{browse_type}/filter/{filter_type}/sort/{sort_method}/offset/{offset}/size/{size} -> 200
    1) Validate response code only


  0 passing (12ms)
  1 failing

  1) GET /browse/items/{browse_type}/filter/{filter_type}/sort/{sort_method}/offset/{offset}/size/{size} -> 200 Validate response code only:
     Uncaught AssertionError: expected [Error: Invalid URI "/browse/items/browse_type/filter/filter_type/sort/sort_method/offset/offset/size/size/browse/items/undefined/filter/undefined/sort/undefined/offset/undefined/size/undefined"] to equal null
    at Function.assert.isNull (/usr/local/lib/node_modules/chai/lib/chai/interface/assert.js:388:32)
    at Test.assertResponse (/usr/local/lib/node_modules/abao/lib/test.js:86:14)
    at /usr/local/lib/node_modules/abao/lib/test.js:3:59
    at /usr/local/lib/node_modules/abao/lib/test.js:70:11
    at fn (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:638:34)
    at Immediate._onImmediate (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:554:34)

Note that the invalid URI is essentially twice as long as it should be and the second half contains null values

Add ability to define multiple test cases for same endpoint/response

Currently the test runner generates a test case per endpoint/response defined in the raml. It would be great to be able to define multiple test cases in situations where more thorough testing is desired to feed in slightly modified sample inputs via hooks.

There are several ways to approach this, but here's one thought I had to keep it minimalistic for the test author... We could add test instances during hooks file processing just by defining additional before hooks.

For example, if we have...
GET /endpoint -> 200

Then in the hooks file, to achieve multiple test executions we could specify additional hooks:
before GET /endpoint -> 200 ...
before GET /endpoint -> 200 arbitrary workflow 1 ...
before GET /endpoint -> 200 arbitrary workflow 2 ...

And when the hooks file is processed it could detect there are additional tests and add those into mocha.

Output full used URLs

Would it be possible to output http://api.project.com/foo-value/bar-value together with the actual http://api.project.com/{fooParam}/{barParam}? It would be very convenient to see which URLs exactly were used.

abao fails to send URI parameter

My RAML has a GET against a resource with one URI parameter:

/my_resource:
  /{param}:
    description: |
      TBD.
    type:
      collection-item:
        exampleItem: !include my_resource-get-item.sample

The parameter is in the .sample file with an integer value:

{
    "param": 1033
}

When I run abao, it seems that abao is failing to send that parameter with its integer value. My API obviously thinks it's undefined:

  1) GET /my_resource/{param} -> 200 Validate response code and body:
     Uncaught AssertionError: Got unexpected response code:
{"errors":"Record not found: Couldn't find MyResource with param=undefined"}
Error: expected 404 to equal '200'
    at Test.assertResponse (/usr/local/lib/node_modules/abao/lib/test.js:88:14)
    at /usr/local/lib/node_modules/abao/lib/test.js:3:61
    at /usr/local/lib/node_modules/abao/lib/test.js:70:11
    at fn (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:641:34)
    at Object._onImmediate (/usr/local/lib/node_modules/abao/node_modules/async/lib/async.js:557:34)
    at processImmediate [as _immediateCallback] (timers.js:345:15)

The API docs in Anypoint work fine. Sending the same request at the command line with curl works fine too.

Either I am using abao incorrectly, or this is a bug.

Server url from baseUri option

I wonder if it would be possible to make server parameter optional? By default we can get url from baseUri option in RAML file.

error with test

I've setup hook files replicating the 3 examples in the readme:

  • before_hook.coffee - with before and after
  • callback_hook.coffee - one with beforeAll and afterAll
  • test_hook.coffee - one with test

When I run the abao command
abao http://localhost:8081/raml http://localhost:8081/ --hookfiles=*_hook.*

I get the following error:

Error reading hook files (before_hook.coffee,callback_hook.coffee,test_hook.coffee)
This probably means one or more of your hookfiles is invalid.
Message: undefined is not a function
Stack: TypeError: undefined is not a function
at Object. (C:\dev\test_hook.coffee:3:1)
at Object. (C:\dev\test_hook.coffee:1:1)

Am I missing something? I want to be able to validate the request parameters and response contents.
I also tried running "npm test" in the command line of that folder and received a grunt error. Is a grunt file required to run the tests?

include request schema in request object

Any chance we could get the json-schema definition of the request body into the request object for hook functions?

Contextually, I was trying to figure out how to use abao for a quick fuzz-testing hook file. I think with this, and the new beforeEach functionality I saw on master, it'd be pretty simple to throw random data that meets (or violates) the json-schema against the API to see how it reacts (e.g. https://github.com/pateketrueke/json-schema-faker/).

Expose test.request in beforeAll hook

Hi

It would be nice to expose at least test.request instead of just "done" under beforeAll

Use case : setting test.request header of Authorization for all requests instead of repeating it.

thanks

test.response.header is null, tough it is specified in RAML

Hi, first of all, guys, really awesome tool, bring our QA to a new level.

the Problem that we experience is the following:
for the Raml spec:

/users:
  description: Entrypoint to handle users
  post:
    description: Create a user
    body: 
      application/json:
        schema: user
    responses:
       201:
        description: A user was created
        headers:
          location:
            description: "Relative URL of the created user."
            type: string
            required: true
            example: /users/123456
        body: null

the test object that abao creates for that looks like that:

{ assertResponse: [Function],
  name: 'POST /users -> 201',
  skip: false,
  request:
   { server: 'http://localhost',
     path: '/users',
     method: 'POST',
     params: {},
     query: {},
     headers: { 'Content-Type': 'application/json' },
     body: {} },
  response: { status: '201', schema: null, headers: null, body: null } }

as you can see, response.headers is equal to null

abao --version
0.4.0-beta.2

thank's a lot for your help.

Support for 1.0 RAML

Please add support for 1.0 version of raml.

Atleast support for multiple examples at once.

example: A string with a single example for the body.
examples: A mapping of examples, where the key is the name of the example

 examples:
  adminUser:
    description: An `admin` user has the `admin` property set to `true` and has the `allowed-operations` collection populated with the all the actions it can perform
    example: |
      { an example of the JSON here }
  normalUser:
    description: A `normal` user does not have the `admin` property turned on.
    example: |
      { an example of the JSON here }

It will help to validate multiple responses without hooks.

Let's say I would like to check url /client/{id} for 200 and 404. I could add two examples. One would provide correct ID for existing (stubbed) user and second would not.
Abao would validate, that both responses are correct.

More cleaner hook syntax

Current hook syntax is a bit unclear, propose

hook 'GET /path'
.before (test, done) ->
  done()
.after (test, done) ->
  done()

beforeAll hook is not working as expected

I have to run a setup before every test in my hook file to get the session from the setup. I have added my setup in beforeAll, but beforeAll is executing after the before hook.

Here is my hook file:

hooks.beforeAll(function(done){ 
  console.log('In BeforeAll hook - 1');  

  var args = {
  headers:{"Content-Type": "application/xml"} 
  };
  client.post("https://abc.com/ssvui/j_spring_security_check?j_password=QA&j_username=QA&response=light", args, function(data,response) {

   str = response.rawHeaders[9].split(";");
    session = str[0];
    console.log("In BeforeAll Hook - 2 After POST");
    console.log(session);
    });

  client.on('error',function(err){
    console.error('Something went wrong on the client', err);
   });
  done();
});

hooks.before('GET /auth -> 200', function(test, done) {
 console.log("In Before Hook --- GET /auth -- Before Request");
 test.request.headers.cookie = session;
console.log(test.request)
 console.log("In Before Hook --- GET /auth  -- After Request");
   done();

});

Output:

In BeforeAll hook - 1
  GET /auth -> 200
In Before Hook --- GET /auth -- Before Request
{ server: 'https://origin-qa.xplusone.com/ssvui',
  path: '/auth',
  method: 'GET',
  params: {},
  query: {},
  headers: 
   { cookie: undefined,
     'content-type': 'application/json',
     accept: '*/*' },
  body: {} }
In Before Hook --- GET /auth  -- After Request
In BeforeAll Hook - 2 After POST
JSESSIONID=199D68CB89F6E469D527363E194BEBA1

In the above output, beforeAll is executing after before hook. Looks like it is not executing in sequence it supposed to. Hence I am not able to use session from my setup function.

Could you please help me on this.

Install

Hi,
I tried to install abad but I get:

/usr/local/bin/abao -> /usr/local/lib/node_modules/abao/bin/abao
/usr/local/lib
└─┬ [email protected]
├── UNMET PEER DEPENDENCY chai@>= 2.0.0 < 3
└─┬ [email protected]
└── [email protected]

npm WARN EPEERINVALID [email protected] requires a peer of chai@>= 2.0.0 < 3 but none was installed.

I used sudo npm install -g abao on a Mac,
thanks for any help

response bodies are not verified against JSON schemas

At this line we see schema be set to @response.schema. schema is then passed to assert.jsonSchema. From here we see that the schema passed should be an object.

At this line in add-tests.coffee however, we see that test.response.schema is a list.

If you give assert.jsonSchema a list instead of an object, then it will not throw an exception even when the object doesn't match the schema. Here's an example:

coffee> a = {foo: 3}
{ foo: 3 }
coffee> schema = {type: "object", required:["skin"], properties:{skin:{type:"string"}}}
{ type: 'object',
  required: [ 'skin' ],
  properties: { skin: { type: 'string' } } }
coffee> chai.assert.jsonSchema(a, schema)
AssertionError: expected value to match json-schema '{"type":"object","required":["...' -> '{"foo":3}'
      Missing required property: skin
          schema: {"type":"object","required":["skin"],"properties":{"skin":{"...
          rule:   /required/0 -> "skin"
  at Function.assert.jsonSchema (/aux0/brock/pub-api/dev_deps/node_modules/chai2-json-schema/index.js:176:40)
...
coffee> chai.assert.jsonSchema(a, [schema])
undefined

If you look at the test cases for test.coffee, you see that test.response.schema is expected to be an object.

multipart/form-data request not sending content-type header

I'm trying to test a multipart/form-data endpoint but it seems as though the content-type header isn't being sent when I run abao.

Raml snippet:

/stuff:
  put:
    body:
      multipart/form-data:
        formParameters:
          name:
            description: The name of the stuff
            required: true
            type: string
            example: My_Stuff
          image:
            description: A picture of the stuff
            required: true
            type: file
    responses:
      201:
        body:
          application/json:

If I change multipart/form-data to application/json I can see the request getting further (but then fails because the required input isn't passed... as expected)

Thoughts?

Thanks
Kimo

Ability to 'see' headers defined in RAML

We can specify headers in RAML, for example:

resourceTypes:
  - collection-item:
      description: | 
        GET shows an individual <<resourcePathName|!singularize>>
      get:
        description: Get a list of <<resourcePathName>>.
        headers: &commonHeaders
          accept: 
            displayName: Accept
            description: MIME types that client is willing to accept.
            example: "*/*"
          content-type: 
            displayName: Content Type
            description: MIME type of document being served.
            example: "application/x-www-form-urlencoded,application/json"

...then later on:

/lakes/{id}:
    description: |  
      A collection of descriptions of the deepest lakes in the world.
    uriParameters:
      id:
        description: |
          A two-digit integer that serves as the ID of a lake. For example, 01 is the ID for Lake Baikal.
        type: integer
        example: 01
    type:
      collection-item:
        exampleItem: !include lakes-item.sample
    get:
      headers: *commonHeaders

Version 0.2.5 of Abao does not 'see' these headers. We are forced to specify the headers at the command line:

abao api.raml https://lakes-api.example.com -h 'Accept:*/*' -h 'Content-Type:application/x-www-form-urlencoded,application/json' --hookfiles=hook.coffee

Note: There is more than one way to specify headers in RAML. The syntax shown above is just one way.

Please improve Abao by adding the ability to 'see' the headers specified in the RAML, so that we can stop specifying headers at the command line. Thanks!

Crash when resource does not define method in RAML

Given a raml which contains resource /root has not defined method section,

#%RAML 0.8

title: World Music API
baseUri: http://example.api.com/{version}
version: v1

/root:
  /machines:
    get:
      responses:
        200:
          body:
            application/json:
              schema: |
                [
                  type: 'string'
                  name: 'string'
                ]
              example: |
                { "type": "Kulu", "name": "Mike" }

Abao crashed with

/Users/quanlong/projects/abao/node_modules/async/lib/async.js:120
        if (!arr.length) {
                ^
TypeError: Cannot read property 'length' of undefined
  at Object.async.each (/Users/quanlong/projects/abao/node_modules/async/lib/async.js:120:17)
  at /Users/quanlong/projects/abao/lib/add-tests.js:33:20
  at /Users/quanlong/projects/abao/node_modules/async/lib/async.js:125:13
  at Array.forEach (native)
  at _each (/Users/quanlong/projects/abao/node_modules/async/lib/async.js:46:24)
  at Object.async.each (/Users/quanlong/projects/abao/node_modules/async/lib/async.js:124:9)
  at addTests (/Users/quanlong/projects/abao/lib/add-tests.js:18:18)
  at /Users/quanlong/projects/abao/lib/abao.js:40:18
  at fn (/Users/quanlong/projects/abao/node_modules/async/lib/async.js:641:34)
  at Object._onImmediate (/Users/quanlong/projects/abao/node_modules/async/lib/async.js:557:34)
  at processImmediate [as _immediateCallback] (timers.js:345:15)

No clue how to make abao resolve json references

I think Abao is very promising, but I cannot get a JSON reference to be resolved. Do you know what I'm doing wrong?

Error: expected value to match json-schema '{"$schema":"http://json-schema...' -> '[{"id":111,"name":"no name","p...'
missing 1 schema: model

A snippet from my raml file looks like:

#%RAML 0.8
title: blabla
version: v0.1
baseUri: http://localhost:8000/
schemas:
  - model: !include schemas/model.json
traits:
  - format:
      displayName: format
      queryParameters:
        format:
          example: json

/models:
  is: [format]
  get:
    responses:
      200:
        body:
          application/json:
            schema: |
              {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "array",
                "items": {
                  "$ref": "model"
                }
              }

I tried several things for the '$ref' field, but I cannot seem to get it right... Do you have any idea how I should reference my schema? The idea is to specify an array of models.

Error response body is null?

So I can't explain this...

  GET /api/heatmaps/{chm}/datasets/{ds}/data -> 500
before-hook-GET-api-heatmaps-{chm}-datasets-{ds}-data-500 (toobiglabel)
    1) Validate response code and body
after-hook-GET-api-heatmaps-{chm}-datasets-{ds}-data-500 (toobiglabel)
************************************************
test.response: { status: '500',
  schema: 
   { '$schema': 'http://json-schema.org/draft-04/schema',
     id: 'http://jsonschema.net',
     type: 'object',
     required: true,
     properties: { code: [Object], message: [Object] } },
  headers: null,
  body: null }
test.response.body: null
    2) "after all" hook
 2 failing

  1) GET /api/heatmaps/{chm}/datasets/{ds}/data -> 500 Validate response code and body:
     Uncaught AssertionError: Got unexpected response code:
label(s) not found
Error: expected 400 to equal '500'


  2) GET /api/heatmaps/{chm}/datasets/{ds}/data -> 500 "after all" hook:
     TypeError: Cannot read property 'code' of null
    at hooks/test_data_hooks.js:93:28

While I believe the underlying C code may be responsible for the 400 vs. 500 issue,
my issue lies with the second test's lack of a test.response.body after its death...

hooks.before('GET /api/heatmaps/{chm}/datasets/{ds}/data -> 500', function(test, done) {
  test.request.params.chm = 'kda-gbm-affy-analysis-012-newnorm';
  test.request.params.ds  = 'tcga-topg';
  test.request.query['labels'] = Array(4096).join('x');  // :TBD: Why don't larger values this crash it?
  test.request.headers['Accept'] = 'text/tab-separated-values,*/*;q=0';
  console.log('before-hook-GET-api-heatmaps-{chm}-datasets-{ds}-data-500 (toobiglabel)');
  return done();
});

hooks.after('GET /api/heatmaps/{chm}/datasets/{ds}/data -> 500', function(test, done) {
  console.log('after-hook-GET-api-heatmaps-{chm}-datasets-{ds}-data-500 (toobiglabel)');
  // :TBD: Think vendor code is incorrect here...
  console.log('************************************************');
  console.log("test.response:", test.response);
  console.log("test.response.body:", test.response.body);
  assert(test.response.body.code === 'Internal');
  test.response.status = parseInt(test.response.status, 10);
  assert(test.response.status === 500);
  return done();
});

Why doesn't this get the same response body as I get from command line?

$ curl -sS 'http://127.0.0.1:8080/api/heatmaps/kda-gbm-affy-analysis-012-newnorm/datasets/tcga-topg/data?labels=nosuchlabel'
{"code":"BadRequestError","message":"label(s) not found"}

Can't locally install abao

We tried adding abao to our package.json and running npm install from our project root, but we got the failure mentioned in #9. I noticed the readme requires npm install -g. Is there no way to install abao as a local project dependency?

I'm not normally a node developer; is this common practice? Just wondering.

Other than this, abao has been working great. Thanks.

npm test succeeds even though there are test failures

$ git pull
$ npm test

...
GET /machines -> 200
1) Validate response code only

0 passing (1ms)
1 failing

  1. GET /machines -> 200 Validate response code only:

AssertionError:
at Object.throwsException (/Users/norbertp/abao/node_modules/sinon/lib/sinon/behavior.js:34:30)
at Function.throws (/Users/norbertp/abao/node_modules/sinon/lib/sinon/stub.js:133:62)
at Context. (/Users/norbertp/abao/test/unit/test-runner-test.coffee:253:18)
at Hook.Runnable.run (/Users/norbertp/abao/node_modules/mocha/lib/runnable.js:217:15)
at next (/Users/norbertp/abao/node_modules/mocha/lib/runner.js:258:10)
at Object._onImmediate (/Users/norbertp/abao/node_modules/mocha/lib/runner.js:275:5)
at processImmediate as _immediateCallback

    ✓ should call afterAll hook
  when beforeAllHooks throws Uncaught Error
  1. "before all" hook

0 passing (0ms)
1 failing

  1. "before all" hook:

Error:
at Object.throwsException (/Users/norbertp/abao/node_modules/sinon/lib/sinon/behavior.js:34:30)
at Function.throws (/Users/norbertp/abao/node_modules/sinon/lib/sinon/stub.js:133:62)
at Context. (/Users/norbertp/abao/test/unit/test-runner-test.coffee:277:23)
at Hook.Runnable.run (/Users/norbertp/abao/node_modules/mocha/lib/runnable.js:217:15)
at next (/Users/norbertp/abao/node_modules/mocha/lib/runner.js:258:10)
at Object._onImmediate (/Users/norbertp/abao/node_modules/mocha/lib/runner.js:275:5)
at processImmediate as _immediateCallback

    ✓ should call afterAll hook

....

Done, without errors.

Make use of `request.json`

  • json - sets body but to JSON representation of value and adds Content-type: application/json header. Additionally, parses the response body as JSON.

Failed to run abao with mocha exception

Hi,
I've installed abao with npm install -g abao and I ran it with my raml file. The result for every endpoint is: Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

I've tried running the same command, with the same raml file on a different machine and it worked fine. I don't know where to start analysing this. Do you have any tips/help?

The whole trace:

$ abao index.raml http://apiaily.appdev.io/kraken/v2


  GET /schedule/data/{regionId}/broadcasts.json -> 200
    1) Validate response code only

  GET /schedule/data/{regionId}/broadcasts/{ids}.json -> 200
    2) Validate response code only

  GET /schedule/data/{regionId}/videos.json -> 200
    3) Validate response code only

  GET /schedule/data/{regionId}/videos/{id}.json -> 200
    4) Validate response code only

  GET /schedule/data/{regionId}/channels.json -> 200
    5) Validate response code only

  GET /schedule/data/{regionId}/channels/{id}.json -> 200
    6) Validate response code only

  GET /schedule/networks/{regionId}/services.json -> 200
    7) Validate response code only

  GET /schedule/networks/{regionId}/services/{id}.json -> 200
    8) Validate response code only

  GET /schedule/meta/errors.json -> 200
    9) Validate response code only


  0 passing (18s)
  9 failing

  1) GET /schedule/data/{regionId}/broadcasts.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)      
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)                                                         


  2) GET /schedule/data/{regionId}/broadcasts/{ids}.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)      
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)                                                         


  3) GET /schedule/data/{regionId}/videos.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)


  4) GET /schedule/data/{regionId}/videos/{id}.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)


  5) GET /schedule/data/{regionId}/channels.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)


  6) GET /schedule/data/{regionId}/channels/{id}.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)


  7) GET /schedule/networks/{regionId}/services.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)


  8) GET /schedule/networks/{regionId}/services/{id}.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)


  9) GET /schedule/meta/errors.json -> 200 Validate response code only:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
    at [object Object].<anonymous> (/usr/local/lib/node_modules/abao/node_modules/mocha/lib/runnable.js:170:19)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
$ npm ls -g
/usr/local/lib
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │   ├── [email protected]
│ │ │   └── [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │   ├─┬ [email protected]
│ │   │ ├── [email protected]
│ │   │ ├── [email protected]
│ │   │ └── [email protected]
│ │   └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │   ├── [email protected]
│ │ │   └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │   ├── [email protected]
│ │ │   ├── [email protected]
│ │ │   ├── [email protected]
│ │ │   └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ └── [email protected]

URL Wildcards for hook matching

I have a long api endpoint: /browse/items/{browse_type}/filter/{filter_type}/sort/{sort_method}/offset/{offset}/size/{size}: and I can query it by doing abao browse.raml /browse but in my hooks just using /browse will not match this endoint, instead I must specify the full endpoint lenght.

It would be nice if I could do either /browse/* or if the hooks used substring matches to figure out when they should be applied.

Example:

hooks.before('GET /browse/* -> 200', function(test, done) {
  test.request.query = { ... };
  done();
});

Clear Cookies

Hi,

Is there any way in Abao we can clear cookies before making request?

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.