javascriptfrisby.jsgetgauge

Testing API using frisby.js/jest with Gauge


I'm trying to get gauge-js to work with Frisby. We run Functional tests on our APIs as a black-box tests using Frisby. Recently upgrade Frisby to version 2.0.8 which now use Jest. All worked good. Now I want to add Gauge-js on top to add human-readable test-specs/scenarios/steps.

I'm testing on Windows 8.1 machine:
- Frisby
- Gauge 0.9.4
- gauge-js 2.0.3

To make it work I add Frisby as a dependency to gauge-js. Now it partially works. It actually execute test step, but failed with

 ReferenceError: expect is not defined
    at incrementAssertionCount (C:\Users\<USER>\AppData\Roaming\gauge\plugins\js\2.0.3\node_modules\frisby\src\frisby\expects.js:14:20)
    at FrisbySpec.status (C:\Users\<USER>\AppData\Roaming\gauge\plugins\js\2.0.3\node_modules\frisby\src\frisby\expects.js:23:5)
    at FrisbySpec._addExpect.e (C:\Users\<USER>\AppData\Roaming\gauge\plugins\js\2.0.3\node_modules\frisby\src\frisby\spec.js:396:23)
    at FrisbySpec._runExpects (C:\Users\<USER>\AppData\Roaming\gauge\plugins\js\2.0.3\node_modules\frisby\src\frisby\spec.js:288:24)
    at _fetch.fetch.then.then (C:\Users\<USER>\AppData\Roaming\gauge\plugins\js\2.0.3\node_modules\frisby\src\frisby\spec.js:142:14)
    at process._tickCallback (internal/process/next_tick.js:109:7)

Here is the actual test step:

/* globals gauge*/

"use strict";

var frisby = require('frisby');

// --------------------------
// Gauge step implementations
// --------------------------

step("Get responds with <state>.", function (state, doneFn) {

  frisby
    .timeout(1500)
    .get('http://localhost:8001/some/get/resource', {
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Basic QWERTYASDFEDEFTGHYFVCCFRJgyuku'
      }
   })

    // .expect('status', 200)
    // .expect('header', 'Content-Type', 'application/json; charset=utf-8')
    // .expect('json', state)
    .done(doneFn).catch(error => {
      console.log(error);
    });
});

When commented out lines uncommented the error occur.

I think the problem is actually with how it's load dependencies, but my js knowledge is a bit fragmented and rusty. Any help would be appreciated.


Solution

  • I found better solution to the original problem. When I start implementing what @duyker suggested. I noticed (finally) that Frisby code has intention to ignore dependency on Jasmine if it's not there, but has a bug. So I submit a fix for it. And it was accepted.

    Now problem solved and Frisby can work without Jasmine or Jest.