How to use frisby - 10 common examples

To help you get started, we’ve selected a few frisby examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bkimminich / juice-shop / test / api / fileUploadSpec.js View on Github external
xit('POST file type XML with dev/random attack', () => { // FIXME fails with "socket hang up" error from node-fetch
      const file = path.resolve(__dirname, '../files/xxeDevRandom.xml')
      const form = frisby.formData()
      form.append('file', fs.createReadStream(file))

      return frisby.post(URL + '/file-upload', {
        headers: { 'Content-Type': form.getHeaders()['content-type'] },
        body: form
      })
    })
  }
github bkimminich / juice-shop / test / api / fileUploadSpec.js View on Github external
xit('POST file type XML with Billion Laughs attack is caught by parser', () => { // FIXME fails with "socket hang up" error from node-fetch
      const file = path.resolve(__dirname, '../files/xxeBillionLaughs.xml')
      const form = frisby.formData()
      form.append('file', fs.createReadStream(file))

      return frisby.post(URL + '/file-upload', {
        headers: { 'Content-Type': form.getHeaders()['content-type'] },
        body: form
      })
        .expect('status', 410)
        .expect('bodyContains', 'Detected an entity reference loop')
    })
github joindin / joindin-api / tests / frisby / api_write.js View on Github external
function init(_baseURL) {
    baseURL = _baseURL;
    frisby.globalSetup({ // globalSetup is for ALL requests
        request: {
            headers: { 'Content-type': 'application/json' }
        }
    });
}
github joindin / joindin-api / tests / frisby / api_write_events.js View on Github external
function init(_baseURL) {
  baseURL = _baseURL;
  frisby.globalSetup({ // globalSetup is for ALL requests
    request: {
      headers: { 'Content-type': 'application/json' }
    }
  });
}
github joindin / joindin-api / tests / frisby / api.js View on Github external
function init(_baseURL) {
	baseURL = _baseURL;
	frisby.globalSetup({ // globalSetup is for ALL requests
		request: {
			headers: { 'Content-type': 'application/json' }
		}
	});
}
github remyla / damas-core / server-tests / tests-frisby_spec.js View on Github external
.put(url + 'lock/')
        .expectStatus(400)
    .toss();

    //Fatal error
/*    frisby.create('LOCK - should throw an error (id not found) - Not found')
        .put(url + 'lock/' + idNotFoundinDb)
        .expectStatus(404)
    .toss();
*/
    frisby.create('LOCK - should throw an error (id empty) - Not found')
        .put(url + 'lock/' + idCustom)
        .expectStatus(404)
    .toss();

    frisby.create('LOCK - should lock the asset')
        .put(url + 'lock/' + idFoundInDb)
        .expectStatus(200)
    .toss();

    frisby.create('LOCK - should lock the asset with custom id')
        .put(url + 'lock/' + idCustomEncoded)
        .expectStatus(200)
    .toss();

    frisby.create('LOCK - should throw an error (already locked)')
        .put(url + 'lock/' + idCustomEncoded)
        .expectStatus(409)
    .toss();

    /**
      * Tests for method Unlock
github remyla / damas-core / server-tests / tests-frisby_spec.js View on Github external
frisby.create('GRAPH - should get a record valid')
        .get(url + 'graph' + idFoundInDb)
        .expectStatus(200)
        .expectHeaderContains('Content-Type', tjson)
    .toss();

    frisby.create('GRAPH - should a record valid with custom id')
        .get(url + 'graph' + idCustomEncoded)
        .expectStatus(200)
        .expectHeaderContains('Content-Type', tjson)
    .toss();

    /**
      * Tests for method Lock
      */
    frisby.create('LOCK - should throw an error (id empty) - Bad request')
        .put(url + 'lock/')
        .expectStatus(400)
    .toss();

    //Fatal error
/*    frisby.create('LOCK - should throw an error (id not found) - Not found')
        .put(url + 'lock/' + idNotFoundinDb)
        .expectStatus(404)
    .toss();
*/
    frisby.create('LOCK - should throw an error (id empty) - Not found')
        .put(url + 'lock/' + idCustom)
        .expectStatus(404)
    .toss();

    frisby.create('LOCK - should lock the asset')
github tkeffer / weert-js / spec / server / packet_spec.js View on Github external
it("should retrieve all packets in default order", function (doneFn) {
        frisby.get(packets_url)
              .expect('status', 200)
              .then(function (res) {
                  // Could not get the Frisby test for JSON to work, so use this:
                  expect(JSON.parse(res.body)).toEqual(packets);
              })
              .done(doneFn);
    });
github tkeffer / weert-js / spec / server / packet_spec.js View on Github external
it("should allow insertion of a NULL value", function (doneFn) {
        frisby.post(packets_url, packet_with_null, {json: true})
              .expect('status', 201)
              .then(function (res) {
                  // We've POSTed the packet. Now retrieve it and make sure
                  // the null value is not there.
                  const packet_link = res.headers.get('location');
                  // Retrieve and check the POSTed packet
                  return frisby.get(packet_link)
                               .expect('status', 200)
                               .then(function (res) {
                                   expect(JSON.parse(res.body)).toEqual([form_deep_packet(0)]);
                               });
              })
              .done(doneFn);
    });
github redhataccess / spandx / spec / spandx / spandxSpec.js View on Github external
}
                }
            };

            const reqs = [
                frisby
                    .setup(accept)
                    .get(`http://localhost:1337/foo`)
                    .expect("status", 200)
                    .expect("bodyContains", /FOO/),
                frisby
                    .setup(accept)
                    .get(`http://localhost:1337/foo/bar`)
                    .expect("status", 200)
                    .expect("bodyContains", /FOO/),
                frisby
                    .setup(accept)
                    .get(`http://localhost:1337/foo/bar/baz`)
                    .expect("status", 200)
                    .expect("bodyContains", /FOO/)
            ];

            // wait for all request promises to resolve, then close up shop
            await Promise.all(reqs.map(r => r._fetch));
            server.close(done);
        });
        it("should not rewrite requests for non-html assets", async done => {

frisby

Frisby.js v2.0: REST API Endpoint Testing built on Jasmine

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis