Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPORTANT] Upcoming Frisby v2.0 #316

Closed
vlucas opened this issue May 18, 2016 · 30 comments
Closed

[IMPORTANT] Upcoming Frisby v2.0 #316

vlucas opened this issue May 18, 2016 · 30 comments

Comments

@vlucas
Copy link
Owner

vlucas commented May 18, 2016

I have started on a new version of Frisby.js that will be released as v2.0 in the "v2" branch of the Frisby.js project on GitHub. Final timeline is unknown at this point, but it has very good progress, and I am already using it in some of my own personal projects with great success.

The main goal is to re-focus on what Frisby does best, give you more control over the Jasmine test structure, and to never nest Jasmine test contexts so issues like the custom matcher functions not working never happen - i.e. issues #93 #94 #307, etc.

Changes in v2.0

With v2.0, Frisby tests will now sit inside your own Jasmine test, and Frisby will only make HTTP requests and run assertions on the response. This gives you a lot more control over the test itself, and gives you the ability to use Jasmine's other methods for flow control, like beforeAll, beforeEach, etc.

Example:

var frisby = require('frisby');

it('should get user Joe Schmoe', function(doneFn) {
  frisby.get(testHost + '/users/1')
    .expect('status', 200)
    .expect('jsonContains', {
      id: 1,
      email: 'joe.schmoe@example.com'
    })
    .done(doneFn);
});

I will have a lot more details later with a full rundown of all the features, but with all the stagnant issues piling up, I just wanted to give everyone a heads up on what's going on with this project.

Using v2 Now

If you want to use Frisby.js v2 now, you can install it by targeting the GitHub v2 branch:

  "devDependencies": {
    "frisby": "git://github.com/vlucas/frisby.git#v2",
    "jasmine-node": "^1.14.5"
  },

If you want to help build the next version of Frisby, pull requests are welcome.

What happens to v0.85?

Unfortunately, the core issues often reported here are not fixable with the current API since Frisby wraps and generates the entire Jasmine test for you. This is very limiting in a lot of ways, and nested Jasmine tests is the largest of these very limiting and unfixable issues. Additionally, the release of Jasmine 2.0 has put the release process on hold since a lot of things have changed, and the main dependency of jasmine-node has still not released an official stable version for Jasmine 2.0.

Therefore, given the poor API design, the current unfixable issues related to that, and the fact that Frisby.js is over 4 years old in its current form and stuck on Jasmine v1.0, the current release will probably be the last in the v0.x series, and the current v0.x code will be abandoned and replaced with the v2.x branch.

@dnperfors
Copy link

A quick question: basically v2 will have less connection with Jasmine, so would it be possible to use Frisby with QUnit or another testing framework as well?

@vlucas
Copy link
Owner Author

vlucas commented May 25, 2016

Yes, that is the idea. The current provided expectations use Node.js's built-in assert library, which throws exceptions on failures instead of expecting Jasmine methods like expect to be available, so this should indeed be possible.

@sharadJay
Copy link

@vlucas are there any changes with after and afterjson hooks ? I am not able to use them with my tests.

@vlucas
Copy link
Owner Author

vlucas commented May 26, 2016

Currently after and afterJSON will be replaced with then, which will serve the same purpose, and function like promises.

@dnperfors
Copy link

@vlucas I am starting with some experiments with frisby v2 using several test engines, so I tried to write a failing test. But even using Jasmine I don't see the test failing. Am I missing something?

'use strict';

const frisby = require('frisby');

const testHost = 'http://httpbin.org';

describe('Frisby', function() {
    it('Test expectStatus works as... well, expected', function(doneFn) {
        frisby.fetch(testHost + '/ip')
            .expect('status', 400)
            .done(doneFn);
    });
});

@vlucas
Copy link
Owner Author

vlucas commented May 31, 2016

@dnperfors Yes - there are some issues with Jasmine and async tests in v2. It will fail properly if you run it with jasmine-node, however. I am still working on it with the official Jasmine CLI runner :).

@sharadJay
Copy link

@vlucas My response returns array of offers, with earlier version I was able to use path like this for expectJSONType

.expectJSONTypes('offers.*', {

but now on using with frisby 2.0 I get error

   Message:
     Expected 'TypeError: Expected 'offers.*' to be Array (got 'object' from JSON response)

Can you help with this ?

@vlucas
Copy link
Owner Author

vlucas commented Jul 14, 2016

Can you make a reproducible test using frisby.fromJSON({ ... }) (with the JSON response) instead of your HTTP call so I can see what's going on?

@sharadJay
Copy link

sharadJay commented Jul 15, 2016

This is test code

var frisby = require('frisby');
var Joi = frisby.Joi;


describe("a suite", function () {
    it('should match JSON with nested structure and single path', function (doneFn) {
        frisby.fromJSON({
            "offers": [{"name": "offer1"}, {"name": "offer2"}]
        })
            .expect('jsonTypes', 'offers.*', {
                "name": Joi.string()
            })
            .done(doneFn);
    })
})
;

Stacktrace

a suite - 18 ms
    should match JSON with nested structure and single path - 17 ms

Failures:

  1) a suite should match JSON with nested structure and single path
   Message:
     Expected 'TypeError: Expected 'offers.*' to be Array (got 'object' from JSON response)
    at acceptance-tests/functional-tests/node_modules/frisby/src/frisby/utils.js:23:15

@vlucas
Copy link
Owner Author

vlucas commented Jul 15, 2016

This has been fixed - sorry for the issues here. I also added a use method that can be used to modify frisby settings per test in a more modular way.

@sharadJay
Copy link

@vlucas Yes thank you this works. I see that assertions in expectJson are not reported if they pass, although if checks fail this is reported in number of failed assertions.

@sharadJay
Copy link

Also I see that timeout function is missing which was there in previous version, can we add it ?

@sharadJay
Copy link

@vlucas I am not able to post data by removing json:true as mentioned in #233 It was working in previous version. Can you look at it ?

@ghost
Copy link

ghost commented Jul 21, 2016

@vlucas I try to get V2 by using command

npm install git://github.com/vlucas/frisby.git#v2

I got error ENOENT.

image

May be the syntax is not good ?

@vlucas
Copy link
Owner Author

vlucas commented Jul 22, 2016

Looks like a local permissions issue. The top line says "checkPermissions: Missing write access to ". I was just able to install Frisby v2 locally, so it works.

@kibertoad
Copy link

Are there any ETAs for the RC version at least?

@vlucas
Copy link
Owner Author

vlucas commented Jul 25, 2016

There is no ETA for v2, but I hope to put an initial beta or RC release out in early August.

The current v2 code already has nearly the same amount of features as v1, but there are a few more things to do. The v2 code is also already more stable and better functioning than v1 as well, if you want to get an early start. I have multiple code bases already using Frisby v2 (so I can dogfood it), and the API won't be changing much because I don't want to redo all the tests ;)

@kibertoad
Copy link

Thank you! Will an RC be released on NPM?

@vlucas
Copy link
Owner Author

vlucas commented Jul 25, 2016

Yes - It will be released on NPM when the time comes.

@saurabh1gupta
Copy link

Question on v2: Will v1 still be supported? As we always have test cases implemented in v1 which we would like to run continuously without any changes (or minimal change) ?

@rybama
Copy link

rybama commented Sep 26, 2016

@vlucas Would be great if you could be more transparent in what is going on in Frisby v2.0. What would help:

  • add issues to the github what is being done, what needs to be done before considering this version usable etc. Also this might help other people to participate in the effort.

@thim81
Copy link

thim81 commented Nov 25, 2016

@vlucas Could you perhaps tag the current v2.0 branch as an "alpha"?
That way we can use it in a more controlled manner in packages.json and also allows to provide feedback per alpha tag release?

@vasergen
Copy link

Hi, what the status of this version 2?

@mike123vn
Copy link

mike123vn commented May 5, 2017

it died already

@vlucas
Copy link
Owner Author

vlucas commented May 5, 2017

v2 is not dead... just stalled. I will look at tagging the branch as "alpha" so people can at least play around with it a bit more easily.

@vlucas
Copy link
Owner Author

vlucas commented May 21, 2017

I just tagged an alpha release:

npm install frisby@2.0.0-alpha.1

UPDATE: Use npm install frisby@next to grab the latest alpha version.

Please play with it and file an issue here if you find anything broken or unexpected.

@vlucas
Copy link
Owner Author

vlucas commented Jul 26, 2017

v2 is here, and has been moved to the master branch. Closing this ticket now.

@lenosky
Copy link

lenosky commented Sep 13, 2018

Hi!
I'm posting some data and need to get the response, @vlucas could you please point me at how can I do that with the v2?

@vlucas
Copy link
Owner Author

vlucas commented Oct 1, 2018

The docs are at: https://www.frisbyjs.com/http.html

Repository owner locked as resolved and limited conversation to collaborators Oct 1, 2018
@H1Gdev
Copy link
Collaborator

H1Gdev commented Oct 5, 2018

@vlucas

I write what I noticed.

  • Frisby.js Overview

const Joi = frisby.Joi; // Frisby exports Joi for convenience on type assersions
is typo.

const Joi = frisby.Joi; // Frisby exports Joi for convenience on type assertions

  • HTTP Request Methods

add params.

  • frisby.get(url, [params])

  • frisby.del(url, [params])

  • frisby.fetch(url, [params], [options])

  • Nested Frisby.js Tests

``` is displayed at the end.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests