Questions tagged [faker.js]

faker.js is a JavaScript library for generating fake data. Fake data is useful when building and testing our application. The faker.js can generate fake data for various areas, including address, commerce, company, date, finance, image, random, or name.

faker.js: generate massive amounts of fake data in the browser and node.js.

github repository: link to github repository

36 questions
27
votes
8 answers

cannot find module faker after npm install --save-dev

I want to install all my modules locally so I am installing everything with the "--save-dev" switch which updates the package.json. I am trying to include this module so I installed using this command: npm install Faker --save-dev My app structure…
dagda1
  • 26,856
  • 59
  • 237
  • 450
5
votes
2 answers

How do I use faker.js to pick a random enum value?

Given an enumeration such as: enum DistributionType { Calculated = "Calculated", Custom = "Custom", None = "None", } How do I use Faker.JS to pick a random enum value from it? const randomValue =…
Casey Plummer
  • 2,629
  • 23
  • 20
5
votes
2 answers

TypeError: Cannot read property 'uuid' of undefined faker-js faker

I am trying to use faker-js package, but I unexpectedly get a TypeError: Cannot read property 'uuid' of undefined for my variable businessId which try to use faker.datatype.uuid() It usually happen when I forget to install faker-js, but that's not…
A Mehmeto
  • 1,594
  • 3
  • 22
  • 37
5
votes
2 answers

Cannot find module 'faker' or its corresponding type declarations.(2307)

I was trying to use 'faker' with TypeScript in TestCafe Studio. But I'm getting an error saying Cannot find module 'faker' or its corresponding type declarations.(2307) import * as faker from 'faker'; This is what I have tried in TestCafe.
3
votes
1 answer

Webpack error during vuejs with cypress for e2e test

I am sorry for my bad English skill. I try to write e2e test for vuejs. I am using cypress for that. But there is a problem. This problem is a webpack error. The error occurs after import a thirdy package. My cypress test: import { faker }…
Halil
  • 211
  • 2
  • 7
2
votes
2 answers

Faker.js v7 clear store

I use faker.js in gulp to create a lot of unique data faker.helpers.unique Due to debugging, the store is often full and displays the error Error: Exceeded maxRetries: 1000 for uniqueness check. So I need to clear the store so that faker.js can…
aboutjquery
  • 838
  • 2
  • 11
  • 22
2
votes
2 answers

faker.helpers.unique(faker.datatype.number, options) does NOT honor submitted options

Objective I want to use @faker-js/faker's helpers.unique() function to generate an array of unique integers with a specified min and max. According to their docs, I should be able to do something like: // import faker import { faker } from…
morphatic
  • 7,677
  • 4
  • 47
  • 61
2
votes
1 answer

Can't use @faker-js/faker in TypeScript project -- undefined -- but older "faker" import works. Why?

Right now I have: "faker": "^5.5.3", "@types/faker": "^5.5.3", in my packages.json. I'm using 5.5.3 because there's another dependency in the project (codecept) that's locked to the older version. The original faker project at…
Aaron
  • 2,154
  • 5
  • 29
  • 42
1
vote
1 answer

Consuming an api using faker.js with nuxt 3

I want to create a shopping card with nuxt 3. For that I have an API which must provide data from faker.js. I want to show them in my about file and integrate sorting functionalities. but I can't in first show this datas in my screen. Here is the…
elza31
  • 9
  • 1
1
vote
2 answers

Is it safe to use fakerjs in production? Or any alternative?

I'm using fakerjs for testing my React app. Some of the random function like generating random colors or avatars or numbers are very useful. I'd like to use these random functions in production bussiness logic too. Is it safe to do that? Or should I…
CSSer
  • 2,131
  • 2
  • 18
  • 37
1
vote
0 answers

Cypress Error: Max -14876746378 should be greater than min 0

I am so sorry I am a beginner in programming as well as automation. I keep getting this error during my test runs. I was trying to create a random date using @faker-js/faker and I was able to do that earlier. I was even able to proceed up to the…
Wigii
  • 11
  • 2
1
vote
0 answers

Fakerjs unsafe assignment of an any value

Does anyone know why I'm getting the following error when trying to populate an array that I've typed? Unsafe assignment of an `any` value.eslint@typescript-eslint/no-unsafe-assignment Unsafe member access .lorem on an `any`…
Mathew
  • 318
  • 11
1
vote
0 answers

ApolloServer not respecting faker-js seeding

Right now I'm using apollo-server-express and creating my ApolloServer with mocks like so: import { faker } from "@faker-js/faker"; export const mocks = { Person: () => ({ name: faker.name.fullName }), People: () => ({ person: () =>…
elrobe
  • 555
  • 2
  • 16
1
vote
6 answers

Is there a new form of the contextualCard feature in faker.js

I haven't used faker since the wipe and am not familiar with the current form of it. Is there a function similar to the contextual card function in the new version? or a function to create fake usernames? my current code looks like this useEffect(()…
Hybrid1940
  • 11
  • 1
1
vote
1 answer

Anyone know how to add paramters to Faker functions on mockapi.io?

I'm exploring API mocking tool and this one seems to be the bee's knees. Even with out figuring this out, I'm still probably going to use it for my needs. But there's a thing that bugs me. You can mock the response you want using Faker.js in their…
Ivan M
  • 31
  • 2
1
2 3