npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mock-factory-ts

v1.1.0

Published

mock-factory-ts is a TypeScript library designed to generate unique random values for use in automated tests. It provides functions for creating random people, generating random numbers and strings, and selecting random items from collections. This librar

Downloads

6

Readme

mock-factory-ts

mock-factory-ts is a TypeScript library designed to generate unique random values for use in automated tests. It provides functions for creating random people, generating random numbers and strings, and selecting random items from collections. This library is particularly useful for testing scenarios where you need consistent but varied test data.
Names used in the library are inspired by characters from the HBO series 'The Game of Thrones', providing a rich variety of test data.

Installation

You can install mock-factory-ts using npm: npm install mock-factory-ts

Usage

Here’s how to use the functions and types provided by mock-factory-ts:

Exported Methods

generateRandomPerson(): Generates a random Person object.

import { generateRandomPerson } from 'mock-factory-ts';

const person = generateRandomPerson();
console.log(person);

getPersonByFirstName(firstName: string): Retrieves a Person object with the specified first name. firstName must be one of the GOT names.

getPersonByFirstAndLastName(firstName: string, lastName: string): Retrieves a Person object with the specified first and last name. firstName and lastName must be a GOT name.

randomNumber(max: number, min: number = 0): number: Generates a random number between min (inclusive) and max (exclusive).

randomNumberString(length: number): string: Generates a random string of digits with the specified length.

randomFromCollection(collection: T[]): T: Selects a random item from the provided collection.

randomLetter(): string: Generates a random lowercase letter from a to z.

generatePostalCode(): string: Generates a random Canadian-style postal code.

generateNationalInsuranceNumberUk(): string: Generates a random UK National Insurance Number.

Exported Types

Person: Represents a person with the following properties:

title: string
firstName: string
middleName: string
lastName: string
email: string
phoneNumber: string
address: Address
bankAccount: BankAccount

Address: Represents a unique address with US state and zip as well as a Canadian province and postal code
Example:

Person {
  title: 'Mr',
  firstName: 'Eddard',
  middleName: 'Ned',
  lastName: 'Stark',
  email: '[email protected]',
  phoneNumber: '4547820595',
  address: Address {
    line1: '421 Lord of Winterfell Street',
    line2: 'Building 49',
    city: 'Winterfell',
    state: 'Vermont',
    province: 'Prince Edward Island',
    postalCode: 'G5G 8W4',
    zipCode: '31280',
    country: 'Winterfell'
  },
  bankAccount: BankAccount {
    bankName: 'Iron Bank',
    bankAccountName: 'Eddard Stark',
    sortCode: '828430',
    accountNumber: '43810690'
  }
}