agentsclimarketplace

Cbmockdata

Skill ColdBox/skills/modules/cbmockdata

Use this skill when generating realistic fake seed/test data in ColdBox/BoxLang using the cbmockdata module. Covers installation, the mock() API, built-in data types, entity population, testing integration, and bulk generation patterns for prototyping and test suites.From its SKILL.md

Install
npx -y skills add ColdBox/skills --skill cbmockdata

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

5.4 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

CBMockdata Skill

When to Use This Skill

Load this skill when:

  • Generating realistic seed data for development databases
  • Creating large datasets for load/performance testing
  • Populating test fixtures in TestBox specs
  • Prototyping UI with varied, realistic content
  • Generating fake API payloads for contract testing

Installation

box install cbmockdata

Language Mode Reference

FeatureBoxLangCFML
Struct syntax{}{} or structNew()
Array syntax[][] or arrayNew(1)
Arrow functions( x ) => x.nameNot supported

Core API

Injection

property name="mockDataService" inject="MockDataService@cbmockdata";

Basic Generation

// Generate an array of 10 user structs
var users = mockDataService.mock(
    $num  = 10,
    id    = "uuid",
    name  = "name",
    email = "email",
    age   = "num:18:65",
    bio   = "sentence:2:4"
)

Built-in Data Types

TypeExample Value
uuid3f2504e0-4f89-...
nameJohn Doe
fnameJane
lnameSmith
email[email protected]
urlhttps://example.com
phone555-123-4567
num:min:max42 (integer in range)
string:nRandom string, n chars
sentence:min:max2-4 sentence lorem ipsum
lorem:nn words of lorem
date2024-03-15
datetime2024-03-15 10:45:00
booleantrue/false
imageUrl:w:hPlaceholder image URL
oneof:a:b:cOne of the listed values
countryUnited States
stateCalifornia
zipcode90210
websitehttps://acme.com
color#FF5733

Fixed Values

var posts = mockDataService.mock(
    $num    = 5,
    title   = "sentence:1:2",
    status  = "oneof:draft:published:archived",
    userId  = "num:1:100",
    created = "datetime"
)

Nested Objects

var orders = mockDataService.mock(
    $num      = 20,
    id        = "uuid",
    customer  = {
        name  = "name",
        email = "email"
    },
    total     = "num:10:500",
    items     = mockDataService.mock(
        $num    = 3,
        product = "sentence:1:2",
        qty     = "num:1:10",
        price   = "num:5:100"
    )
)

Production Patterns

TestBox Seed Helper

// tests/resources/SeedHelper.bx
class {

    property name="mockDataService" inject="MockDataService@cbmockdata";

    function seedUsers( count = 10 ) {
        return mockDataService.mock(
            $num      = count,
            id        = "uuid",
            firstName = "fname",
            lastName  = "lname",
            email     = "email",
            createdAt = "datetime",
            isActive  = "boolean"
        )
    }

    function seedProducts( count = 50 ) {
        return mockDataService.mock(
            $num        = count,
            id          = "uuid",
            name        = "sentence:1:3",
            description = "sentence:2:5",
            price       = "num:1:999",
            sku         = "string:8"
        )
    }
}

Database Seeder

function run( event, rc, prc ) {
    var users = mockDataService.mock(
        $num     = 500,
        id       = "uuid",
        name     = "name",
        email    = "email",
        password = "string:40"     // placeholder — hash in afterEach
    )

    for ( var user in users ) {
        queryExecute(
            "INSERT INTO users (id, name, email, password) VALUES (:id, :name, :email, :password)",
            {
                id       : { value: user.id,       cfsqltype: "cf_sql_varchar" },
                name     : { value: user.name,     cfsqltype: "cf_sql_varchar" },
                email    : { value: user.email,    cfsqltype: "cf_sql_varchar" },
                password : { value: bcrypt.hashPassword( user.password ),
                             cfsqltype: "cf_sql_varchar" }
            }
        )
    }

    return "Seeded 500 users."
}

API Prototype Handler

function index( event, rc, prc ) {
    prc.data = mockDataService.mock(
        $num      = rc.limit ?: 20,
        id        = "uuid",
        title     = "sentence:2:5",
        body      = "sentence:4:8",
        author    = "name",
        published = "datetime",
        tags      = [
            "oneof:tech:news:health:sports",
            "oneof:tech:news:health:sports"
        ]
    )

    event.renderData( type = "json", data = prc.data )
}

Best Practices

  • Use oneof: for status/type columns — realistic constraint-safe values
  • Use uuid for primary keys in prototyping — avoids sequence/auto-increment conflicts
  • Nest with real mock() calls for related data arrays — do not hand-craft nested loops
  • Hash passwords generated with string: — mock passwords should never be stored plain
  • Seed only in dev/test environments — gate seeders with an environment check
  • Keep seed counts small in unit tests — use large counts only in dedicated perf tests

Documentation

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,758. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.