Select Page
Agile Testing

Introducing SerenityJS

Being a leading QA Company, we write blogs on all prominent software testing topics and tools using our real-world experience. So stay sharp by subscribing to our Newsletter.

Introducing SerenityJS - Blog
Listen to this blog

As an agile testing services company, sharing Agile testing practice is the key to success. Before starting this article, we would like to thank Jan Molak who introduced SerenityJS to us.

Let’s start with the definition:

Serenity/JS is a next generation acceptance testing JavaScript library.

Features of SerenityJS:

  • Screenplay pattern which helps you shift the focus of automated acceptance tests from low-level interactions with the system to thinking about who the users of your system are, what is that they want to achieve by their interaction with your system and how exactly they’re going to do it.
  • Comprehensive reporting capabilities
  • SOLID design principles.
  • It supports CucumberJS, Mocha Protractor, and Chai.
  •  
    We were surprised when we read about ScreenPlay pattern. Maybe we are late. However, this is the concept answered our question.

    The question is:

    How can a business person understand and verify the logic which is implemented inside a step definition?

    How the ScreenPlay pattern addresses the problem? The Screenplay Pattern is a user-centred model which allows you to write automated tests with the defined user roles and persona.

    It is impossible for you to understand ScreenPlay pattern without knowing what user roles and Persona is.

    User roles:
    A user role is a collection of defining attributes that characterize a population of users and their intended interactions with the system. Consider we are building an e-learning application. Before writing user stories, we need to brainstorm to identify, consolidate and condense user roles.

    Defined user roles for an e-learning application:

  • Instructor
  • Student
  • Admin
  • Persona:
    A persona is an imaginary representation of a user role. Creating a persona requires more than just adding a name to a user role. A persona should be described sufficiently that everyone on the team feels like they know the persona.

    Persona Example:

    Introducing SerenityJS

    Anna works as an instructor, and she creates students, assigns assignments to her students, and views reports of students. Anna is good at teaching basics of computer.

    Reference: User Stories Applied

    We hope you are clear with User roles and Persona. Let’s see how these are represented in Gherkin and Step Definition using Serenity/JS.

    Feature: Add new items to the todo list
    
      As James (the just-in-time kinda guy)
      I want to capture the most important things I need to do
      So that I don’t leave so many things until the last minute
    
      Scenario: Adding the first todo item
    
        Given that James has an empty todo list
         When he adds Buy some milk to his list
         Then his to-do list should contain Buy some milk  

    In the above feature, James is the persona.

    let james = Actor.named('James');  

    Create an actor in step definition

    this.When(/^he adds (.*?) to his list$/, (name: string) => {
        return james.attemptsTo(
            AddATodoItem.called(itemName)
        );
    });  

    James attempts to add todo item. Now anyone can understand your step definition. You can find more details in the following link Serenity/JS and do not miss to watch the introductory video of Serenity/JS.

    Comments(0)

    Submit a Comment

    Your email address will not be published. Required fields are marked *

    Talk to our Experts

    Amazing clients who
    trust us


    poloatto
    ABB
    polaris
    ooredo
    stryker
    mobility