Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Latest commit

 

History

History
56 lines (40 loc) · 1.98 KB

examples_data_generation.md

File metadata and controls

56 lines (40 loc) · 1.98 KB
title
Examples - Test Data Generation

Examples - Test Data Generation

Overview

With the help of the incredible open-source Faker library Faker.js - we can generate test data for use in Flood Chrome test very easily and on-the-fly. The Faker library allows us to generate a wide variety of syntax-correct data such as randome names, numbers, strings, emails etc.

To start using Faker within your Flood Chrome script you will need to import the specific Faker library -for example for basic random data - we would use the following 'random' library:

    import { random } from 'faker'

Generating Random Numbers

The simplest way to generate a random number using Faker is to declare the 'random' Faker object at the top of your Flood Chrome script and then use the following in your Flood Chrome script step to generate a 5 digit random number between 0 and 99999:

        //Generate a random phone number
        var randNumber = random.number(99999).toString()

Generating Person Names

You are able to generate random first and surnames very easily:

    //put this import statement at the top of your script
    import { name } from 'faker'
        //Generate different types of names and related data
        var randFirstname = name.firstName()
        var randSurname = name.lastName()
        var randJobTitle = name.jobTitle()
        var randPrefix = name.prefix()

Generating Email Addresses

You are able to generate email addresses and other web related test data using the following:

    //put this import statement at the top of your script
    import { internet } from 'faker'
        //Generate different types of names and related data
        var randEmail = internet.email() ////returns "[email protected]"
        var randEmailProvider = internet.email("joe","smith","protonmail.com") //returns "[email protected]"