0.0.7 • Published 5 years ago

@bradmerlin/nonsense v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

npm (scoped) npm bundle size npm

Nonsense generates structured random data.

A step toward simple fuzz testing. Use it for testing code that accepts uncontrollable input 🐊🐊🐊


Usage

import { Generators, Nonsense } from '@bradmerlin/nonsense';

// Define data structure.
let bankAccount = {
  accountNumber:  Generators.INT,
  beneficiaryIDs: Generators.INT(5),
  accountType:    Generators.CHOICE(['cheque', 'savings', 'credit']),
  user:           {
    fullName:        Generators.STRING,
    someStaticValue: Generators.VALUE('Do not change'),
  },
};

// Create generator
let generator = Nonsense(bankAccount);

// New random values each time the generator generates.
let output = [];
for (let i = 0; i < 3; i++) {
  output.push(generator());
  // But actually use this in a test.
}
[
  {
    accountNumber: 1,
    beneficiaryIDs: [16, 53, 46, 7, 73],
    accountType: 'cheque',
    user: {
      fullName: "'=S:[~U£Æ¬Ž¥U8SÄ°6µV€žG)-_^hG¢f‰12gŽ¨™›w@ÇM€N&~",
      someStaticValue: 'Do not change'
    }
  },
  {
    accountNumber: 99,
    beneficiaryIDs: [84, 33, 5, 99, 74],
    accountType: 'cheque',
    user: {
      fullName: 'FŸ¯Á™I%w·½·\\¯´^ª%X?p†S€Â]p€’®JŠkE¶º}?Ty…J9•¬3³¨ŒÀ',
      someStaticValue: 'Do not change'
    }
  },
  {
    accountNumber: 52,
    beneficiaryIDs: [25, 6, 3, 33, 43],
    accountType: 'savings',
    user: {
      fullName: 'HEseœ¼V9I_·CMµS6r·Lª47º˜ª;4v_P>‡&<ÇqP®–b{PF’(›l',
      someStaticValue: 'Do not change'
    }
  }
]
0.0.7

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago