From fda18c543412de8f417a091fe3641b399e66eab1 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 9 Feb 2026 10:22:03 -0800 Subject: [PATCH] Snapshot faker template function names in test Replace the brittle count assertion (toBe(226)) with a snapshot of all exported function names. This catches accidental additions, removals, or renames across faker upgrades with a clear diff. Co-Authored-By: Claude Opus 4.6 --- .../tests/__snapshots__/init.test.ts.snap | 233 ++++++++++++++++++ .../tests/init.test.ts | 13 +- 2 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 plugins/template-function-faker/tests/__snapshots__/init.test.ts.snap diff --git a/plugins/template-function-faker/tests/__snapshots__/init.test.ts.snap b/plugins/template-function-faker/tests/__snapshots__/init.test.ts.snap new file mode 100644 index 00000000..adc26a67 --- /dev/null +++ b/plugins/template-function-faker/tests/__snapshots__/init.test.ts.snap @@ -0,0 +1,233 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`template-function-faker > exports all expected template functions 1`] = ` +[ + "faker.airline.aircraftType", + "faker.airline.airline", + "faker.airline.airplane", + "faker.airline.airport", + "faker.airline.flightNumber", + "faker.airline.recordLocator", + "faker.airline.seat", + "faker.animal.bear", + "faker.animal.bird", + "faker.animal.cat", + "faker.animal.cetacean", + "faker.animal.cow", + "faker.animal.crocodilia", + "faker.animal.dog", + "faker.animal.fish", + "faker.animal.horse", + "faker.animal.insect", + "faker.animal.lion", + "faker.animal.petName", + "faker.animal.rabbit", + "faker.animal.rodent", + "faker.animal.snake", + "faker.animal.type", + "faker.color.cmyk", + "faker.color.colorByCSSColorSpace", + "faker.color.cssSupportedFunction", + "faker.color.cssSupportedSpace", + "faker.color.hsl", + "faker.color.human", + "faker.color.hwb", + "faker.color.lab", + "faker.color.lch", + "faker.color.rgb", + "faker.color.space", + "faker.commerce.department", + "faker.commerce.isbn", + "faker.commerce.price", + "faker.commerce.product", + "faker.commerce.productAdjective", + "faker.commerce.productDescription", + "faker.commerce.productMaterial", + "faker.commerce.productName", + "faker.commerce.upc", + "faker.company.buzzAdjective", + "faker.company.buzzNoun", + "faker.company.buzzPhrase", + "faker.company.buzzVerb", + "faker.company.catchPhrase", + "faker.company.catchPhraseAdjective", + "faker.company.catchPhraseDescriptor", + "faker.company.catchPhraseNoun", + "faker.company.name", + "faker.database.collation", + "faker.database.column", + "faker.database.engine", + "faker.database.mongodbObjectId", + "faker.database.type", + "faker.date.anytime", + "faker.date.between", + "faker.date.betweens", + "faker.date.birthdate", + "faker.date.future", + "faker.date.month", + "faker.date.past", + "faker.date.recent", + "faker.date.soon", + "faker.date.timeZone", + "faker.date.weekday", + "faker.finance.accountName", + "faker.finance.accountNumber", + "faker.finance.amount", + "faker.finance.bic", + "faker.finance.bitcoinAddress", + "faker.finance.creditCardCVV", + "faker.finance.creditCardIssuer", + "faker.finance.creditCardNumber", + "faker.finance.currency", + "faker.finance.currencyCode", + "faker.finance.currencyName", + "faker.finance.currencyNumericCode", + "faker.finance.currencySymbol", + "faker.finance.ethereumAddress", + "faker.finance.iban", + "faker.finance.litecoinAddress", + "faker.finance.pin", + "faker.finance.routingNumber", + "faker.finance.transactionDescription", + "faker.finance.transactionType", + "faker.git.branch", + "faker.git.commitDate", + "faker.git.commitEntry", + "faker.git.commitMessage", + "faker.git.commitSha", + "faker.hacker.abbreviation", + "faker.hacker.adjective", + "faker.hacker.ingverb", + "faker.hacker.noun", + "faker.hacker.phrase", + "faker.hacker.verb", + "faker.image.avatar", + "faker.image.avatarGitHub", + "faker.image.dataUri", + "faker.image.personPortrait", + "faker.image.url", + "faker.image.urlLoremFlickr", + "faker.image.urlPicsumPhotos", + "faker.internet.displayName", + "faker.internet.domainName", + "faker.internet.domainSuffix", + "faker.internet.domainWord", + "faker.internet.email", + "faker.internet.emoji", + "faker.internet.exampleEmail", + "faker.internet.httpMethod", + "faker.internet.httpStatusCode", + "faker.internet.ip", + "faker.internet.ipv4", + "faker.internet.ipv6", + "faker.internet.jwt", + "faker.internet.jwtAlgorithm", + "faker.internet.mac", + "faker.internet.password", + "faker.internet.port", + "faker.internet.protocol", + "faker.internet.url", + "faker.internet.userAgent", + "faker.internet.username", + "faker.location.buildingNumber", + "faker.location.cardinalDirection", + "faker.location.city", + "faker.location.continent", + "faker.location.country", + "faker.location.countryCode", + "faker.location.county", + "faker.location.direction", + "faker.location.language", + "faker.location.latitude", + "faker.location.longitude", + "faker.location.nearbyGPSCoordinate", + "faker.location.ordinalDirection", + "faker.location.secondaryAddress", + "faker.location.state", + "faker.location.street", + "faker.location.streetAddress", + "faker.location.timeZone", + "faker.location.zipCode", + "faker.lorem.lines", + "faker.lorem.paragraph", + "faker.lorem.paragraphs", + "faker.lorem.sentence", + "faker.lorem.sentences", + "faker.lorem.slug", + "faker.lorem.text", + "faker.lorem.word", + "faker.lorem.words", + "faker.music.album", + "faker.music.artist", + "faker.music.genre", + "faker.music.songName", + "faker.number.bigInt", + "faker.number.binary", + "faker.number.float", + "faker.number.hex", + "faker.number.int", + "faker.number.octal", + "faker.number.romanNumeral", + "faker.person.bio", + "faker.person.firstName", + "faker.person.fullName", + "faker.person.gender", + "faker.person.jobArea", + "faker.person.jobDescriptor", + "faker.person.jobTitle", + "faker.person.jobType", + "faker.person.lastName", + "faker.person.middleName", + "faker.person.prefix", + "faker.person.sex", + "faker.person.sexType", + "faker.person.suffix", + "faker.person.zodiacSign", + "faker.phone.imei", + "faker.phone.number", + "faker.science.chemicalElement", + "faker.science.unit", + "faker.string.alpha", + "faker.string.alphanumeric", + "faker.string.binary", + "faker.string.fromCharacters", + "faker.string.hexadecimal", + "faker.string.nanoid", + "faker.string.numeric", + "faker.string.octal", + "faker.string.sample", + "faker.string.symbol", + "faker.string.ulid", + "faker.string.uuid", + "faker.system.commonFileExt", + "faker.system.commonFileName", + "faker.system.commonFileType", + "faker.system.cron", + "faker.system.directoryPath", + "faker.system.fileExt", + "faker.system.fileName", + "faker.system.filePath", + "faker.system.fileType", + "faker.system.mimeType", + "faker.system.networkInterface", + "faker.system.semver", + "faker.vehicle.bicycle", + "faker.vehicle.color", + "faker.vehicle.fuel", + "faker.vehicle.manufacturer", + "faker.vehicle.model", + "faker.vehicle.type", + "faker.vehicle.vehicle", + "faker.vehicle.vin", + "faker.vehicle.vrm", + "faker.word.adjective", + "faker.word.adverb", + "faker.word.conjunction", + "faker.word.interjection", + "faker.word.noun", + "faker.word.preposition", + "faker.word.sample", + "faker.word.verb", + "faker.word.words", +] +`; diff --git a/plugins/template-function-faker/tests/init.test.ts b/plugins/template-function-faker/tests/init.test.ts index e16b5bd1..e344e5ae 100644 --- a/plugins/template-function-faker/tests/init.test.ts +++ b/plugins/template-function-faker/tests/init.test.ts @@ -1,9 +1,12 @@ import { describe, expect, it } from 'vitest'; -describe('formatDatetime', () => { - it('returns formatted current date', async () => { - // Ensure the plugin imports properly - const faker = await import('../src/index'); - expect(faker.plugin.templateFunctions?.length).toBe(226); +describe('template-function-faker', () => { + it('exports all expected template functions', async () => { + const { plugin } = await import('../src/index'); + const names = plugin.templateFunctions?.map((fn) => fn.name).sort() ?? []; + + // Snapshot the full list of exported function names so we catch any + // accidental additions, removals, or renames across faker upgrades. + expect(names).toMatchSnapshot(); }); });