DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. Is it Time to Toss frisby.js?

Is it Time to Toss frisby.js?

Zone Leader John Vester provides analysis on his usage of frisby.js for REST API testing and why his team is focusing on using Newman now.

John Vester user avatar by
John Vester
CORE ·
Feb. 26, 16 · Analysis
Like (2)
Save
Tweet
Share
12.79K Views

Join the DZone community and get the full member experience.

Join For Free

Image titleNot too long ago, my company decided to use frisby.js for our REST API testing. The frisby.js framework is built on node.js and Jasmine and is intended to make testing API end-points "easy, fast, and fun" (according to the frisby.js web-site). Recently, the development and quality assurance (QA) staff got together to ask if it is time to toss frisby.js from our toolset.

Challenges We've Seen

While the web-site promises an easy, fast, and fun experience, our reality doesn't seem to use those adjectives.

The first challenge we faced is with the level of documentation provided. At a high level, the documentation provides some basic knowledge of how to use the framework. When attempting to locate more detailed examples, I found myself struggling, without even a strong presence on Stack Overflow to rely on. A secondary issue is the syntax which is different enough to provide a modest challenge to learn. A tertiary issue centered around our struggles with trying to debug frisby.js tests.

Another challenge I ran into was the need to nest a lot of child REST calls when testing a page in our application. In one example, I wanted to hit the API for the drop-downs menus with the same choices that are presented by the application. I am not a fan of hard-coding this type of information into the test. However, in order to do this, each API called had to be nested inside the prior call. See the example below:

frisby.create('API Test')
    .addHeader("Content-Type", "application/json")
    .addHeader("Accept", "application/json")
    .post(url + '/login', {
        username: username,
        password: password
    }, {
        json: true
    })
    .expectStatus(200)
    .afterJSON(function (res) {
        frisby.create('Getting Contract')
            .get(url + 'contracts/' + contractId)
            .expectStatus(200)
            .afterJSON(function (res) {
                contract = res;
                frisby.create('Getting State')
                    .get(url + 'states/' + stateId)
                    .expectStatus(200)
                    .afterJSON(function (res) {
                        state = res;
                        frisby.create('Getting Business Title')
                            .get(url + 'names/business_titles/' + businessTitleId)
                            .expectStatus(200)
                            .afterJSON(function (res) {
                                businessTitle = res;
                                frisby.create('Getting Other Stuf')
                                    .get(url + 'addresses/other_stuff/' + otherStuffId)
                                    .expectStatus(200)
                                    .afterJSON(function (oStuff) {
                                        otherStuff = oStuff;
                                        frisby.create('Getting Name Suffix')
                                            .get(url + 'names/suffixes/' + nameSuffixId)
                                            .expectStatus(200)
                                            .afterJSON(function (res) {
                                                nameSuffix = res;
                                                frisby.create('Finally performing API test here')
                                                    .post(url + '/contracts/something', {
                                                        'contract': {
                                                            'id': contract.id,
                                                            'rowVersion': contract.rowVersion
                                                        },
                                                        'firstName': 'FirstName',
                                                        'lastName': 'LastName',
                                                        'businessTitle': businessTitle,
                                                        'otherStuff': otherStuff,
                                                        'state': state,
                                                        'nameSuffix': nameSuffix,
                                                        'licenseState': state,
                                                        ...
                                                    }, {
                                                        json: true
                                                    })
                                                    .expectStatus(200)
                                                    .expectHeaderContains('content-type', 'application/json')
                                                    .expectJSONTypes(expectedJSONTypes)
                                                    .expectJSON({
                                                        'firstName': 'FirstName',
                                                        'lastName': 'LastName',
                                                        ...
                                                    })
                                            }).toss();
                                    }).toss();
                            }).toss();
                    }).toss();
            }).toss();
    }).toss();

I could not find a way around this (see first challenge above), but I wasn't a fan of starting my test logic at column 50.

The last challenge I ran into, which is not solely an issue with frisby.js, is the inability to roll-back transactions created as part of the tests. So, if my test performs a POST/PUT, after the test finishes, there is a new record in the database. Conversely, frameworks like JUnit do not commit records to the database. In our case, we implemented a "small database" concept, where we initialize a database to use for testing, then purge it after the test finishes. Calling a DELETE method wasn't always an option since our application does not have a requirement for delete functionality.

Where We Are Heading

Image title

Our QA Architect, after hearing our frustrations and performing some analysis, has recommended that we consider using Newman. For those who are not aware, Newman is a command-line companion tool for Postman. In our case, nearly every developer and QA member has been using Postman as a tool with our REST APIs. Newman has the ability to integrate collections within Postman and run the tests any time code is saved in our IDE (if desired).

So far, the change has been a positive experience. However, there are a significant amount of frisby.js tests to convert, which should put Newman through its paces to validate our decision.

Conclusion

In our case, we decided to toss frisby.js from our suite of test tools and focus on using Newman. Using frisby.js wasn't the easy, fast, and fun experience we were hoping to enjoy. I am certainly not saying our choice and direction is the one route everyone should take. In fact, I am sure there are others who could make a recommendation to leave Newman for frisby.js and cite similar issues with our current REST API testing framework. Instead, I wanted to provide a summary of our experiences with frisby.js and provide a summary of our current direction.

Have a really great day!

Database Testing

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Hackerman [Comic]
  • Key Considerations When Implementing Virtual Kubernetes Clusters
  • Writing a Modern HTTP(S) Tunnel in Rust
  • Ultimate Guide to FaceIO

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: