Mock Data Form Filler

Developers

Mock data generator for form tests

One file. Zero dependencies. No network. Generate realistic test values, then fill a whole form with a single call — the same values the Chrome extension writes.

npm install mock-data-form-filler

MIT · ~9 KB · Node 14+ and every modern browser · no runtime deps

Try it here

This form is filled by MockFiller.fillAll(form) — the exact file the package ships.


          

Click “Fill the form” to see the values.

Use it in your tests

The package has no build step and no framework bindings. Load it as a script, or import it in the test runner.

Browser

<script src="/node_modules/mock-data-form-filler/index.js"></script>
<script>
  // fills every safe field under the given root
  MockFiller.fillAll(document); // → { filled: 7 }
</script>

Playwright

const { test, expect } = require("@playwright/test");

test("signup accepts mock data", async ({ page }) => {
  await page.goto("/signup");
  await page.addScriptTag({ path: require.resolve("mock-data-form-filler") });
  const { filled } = await page.evaluate(() => MockFiller.fillAll(document));
  expect(filled).toBeGreaterThan(4);
});

Cypress

// cypress/support/e2e.js
import MockFiller from "mock-data-form-filler";

// in a spec
cy.visit("/signup");
cy.document().then((doc) => MockFiller.fillAll(doc));

Deterministic runs

MockFiller.setSeed(42);
MockFiller.email(); // the same string on every run
MockFiller.reset(); // back to Math.random

API

Method Returns
firstName() lastName() fullName() "Alex", "Smith", "Alex Smith"
email() phone() url() username() alex.smith42@example.com, +15550123456
company() street() city() state() zip() country() a full address block
date() time() month() week() datetime() values that native inputs accept
number(min?, max?) color() sentence() password() "42", "#3f8ac1", a short sentence
record() all values in one object — handy for API fixtures
fill(el, options?) true when a value was written
fillAll(root?, options?) { filled: number }
setSeed(n) reset() isSeeded() reproducible output

Detection reads type, autocomplete, name, id, placeholder, aria-label and the closest <label> — so it also works on forms without semantic markup.

Why this one

FAQ

Does it only work in Chrome?

No. The extension is Chrome-only, but the package is plain JavaScript and runs in any modern browser, Playwright, Cypress and Node.

Does it call an API?

Never. Every value is generated locally with Math.random() or, if you call setSeed(), with a small deterministic PRNG.

Can I use it for manual testing too?

Yes — that is what the Chrome extension is for: click the toolbar icon or press Alt+Shift+F on any page.

Links

Package: npm · product home · test forms · fake data extension · privacy