Firsby for Unit test Firebase REST API

Firebase required to iniciate in order to run test cases.

Firsby is a api testing fromwork ,which can work with jasmine.


 npm install jasmine-node -g

Install frisby.js

http://frisbyjs.com/

Create spec file witih spec folder

Import depeldancy
var request = require("request");
var server = require("./../src/test.js");   // server file
var frisby = require('frisby');


Header value for every request

frisby.globalSetup({
request: {
headers: {'AccessToken':process.env.test_token}. // taken from the .env
}
});

Dependent Request


frisby.create(' Login')
  .post(process.env.npm_config_host+'/api/login',{.  //take the host when running test command
        "profile-type": "test",
        "mess-token":""
})
.after(function(err, res, body) {

  frisby.create('Dome')
    .post(process.env.npm_config_host+'/api/user',{
          "profile-type": "test",
            "user": {
            "hight": 50.78825,
            "width": -50.4324
        },
      )
    .expectHeaderContains('Content-Type', 'json')
      .expectJSONTypes( {
        success: Boolean,
        payload:{user: Object}
    })
  .toss();

})
.toss();


In the test command of the .package.json

"test": "./node_modules/.bin/jasmine-node server/spec"

In order to run the test 

npm test --host='http://localhost:8081' --type=test



Comments

Popular posts from this blog

ENOENT: no such file or directory, rename : node_modules/async

react-quill Integrate quill-image-resize-module