ccswbs / testing

Testcafe-based test suite for hjckrrh.
GNU General Public License v3.0
0 stars 1 forks source link

Install Faker.js module to generate fake data for tests #41

Closed mmafe closed 7 years ago

mmafe commented 7 years ago

Recommend installing Faker.js so we can generate fake data for tests.

Ended up doing this locally while writing tests related to https://github.com/ccswbs/hjckrrh/issues/739.

It worked very nicely for generating content for people profiles, including names, lorem ipsum snippets (paragraphs, words, sentences, slugs, etc.), phone numbers, etc.

Process was to:

  1. Run npm install faker --save to include in package.json
  2. Include const Faker = require('faker'); at the top of your test file
  3. In your test, you can generate random data using format Faker.<lib name>.<method()>; so for example:
var firstName = Faker.name.firstName();
var lastName = Faker.name.lastName();
var summary = Faker.lorem.paragraph();
var teaser = Faker.lorem.sentence();
bdavey07 commented 7 years ago

Merged