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
1
vote
3 answers

Error when trying to create fake data with faker.js

At first, I install faker using the command npm i faker Now i am trying to run my npm server up npm run start. But i am getting the following error. Can some one please help me here and thanks in advance. **Compiled with problems:X ERROR in…
sruthi
  • 35
  • 1
  • 5
1
vote
4 answers

Faker.js random word with choices

I'm trying to use faker.js to generate some random words, but I want it to choose between a few choices. faker.random.word() I tried something like this faker.random.word({constraints: ['','','']}) This didn't work, and I could be way off since…
ternt
  • 21
  • 1
  • 3
1
vote
1 answer

Setting up and configuring Faker Js for CodeceptJs

really having trouble with setting up and configuring faker to work on codeceptjs, I have had a look at their website but no luck with the set up. I just need need a simple example of faker within a test case. I have installed through npm 'rosie'…
redoptics
  • 65
  • 6
1
vote
1 answer

NodeJS | Jest | Factory Girl | Faker: Faker generating the same values

I'm developing a Node.js API and now I'm creating the tests using supertest for all the routes. I found the best practice is to use the factory-girl and the faker to generate random values for the models. Knowing that, I created my factory.js: …
0
votes
1 answer

How to fix faker.date.past deprecation warning

I found multiple deprecation warnings such as: import { faker } from '@faker-js/faker'; const pastDate = faker.date.past(1); const futureDate = faker.date.future(2); const betweenDate = faker.date.between('2001-02-02', '2002-02-02'); const…
Kostanos
  • 9,615
  • 4
  • 51
  • 65
0
votes
0 answers

How can I make a typescript fixture that allows partial defaults to be supplied?

Say I have a helper function to create text data in my fixture. The test data has a type definition of: type Locomotive = { name: string; serialNumber: string; engine: Engine; model: Model; gauge: number; }; type Engine = { fuel: …
AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
0
votes
0 answers

Faker.js v7 limit the result string length of uniqueArray on nodejs

const dummy = { country: faker.helpers.uniqueArray(faker.address.country, 100), }; console.log(dummy.country) As far as the above code is concerned, 20 country names will be output, but some strings are too long (United States Minor Outlying…
aboutjquery
  • 838
  • 2
  • 11
  • 22
0
votes
0 answers

I am unable to seed my mongodb with some sample data

I am learning React through a tutorial made by Mosh Hamadani(CodeWithMosh). In the section where we are supposed to learn how to connect the front end with the back end I encountered an error. I made sure I did everything according to the video but…
0
votes
0 answers

JS Faker Always Return the same data type

I'm using faker as putty and tests for Cypress. But it is always returning the same data in different tests, it randomizes the words but in the next test it returns them const Nome_Empresa = faker.random.word() + ' LTDA'; const Nome_Fantasia =…
0
votes
0 answers

json-server + faker-js yielding always the same random number sequence, even changing some random seed. How to get true randomnes in every web call?

I'm kind of new with json-server + faker-js (and generally with javascript). I know the expected basics regarding randomness + seeds so I don't know what's happening in this piece of code below (some expected json-server index.js file), which gives…
Isaac
  • 1,794
  • 4
  • 21
  • 41
0
votes
2 answers

Why can't I import this CardList in JSX?

I'm doing with my homework about React. I'm tring to add Cards to the page and I created a Card.jsx and a CardList.jsx file to achieve this. And I used the faker to help generating some random fake info. However, when I imported the CardList.jsx to…
Wonster
  • 27
  • 6
0
votes
1 answer

How do I get a 4-digit year from fakerjs date.birthdate() when setting `max` and `min`

I'm trying to use the community fakerjs library to get a random birthdate. I want it to be within the last 70 years at the latest. In my output, though, I keep getting years like 79 and 12 instead of 1979 or 2012. I can only get a 2-digit year. let…
Mixchange
  • 893
  • 1
  • 8
  • 14
0
votes
0 answers

Is there a `faker.fake` method for python faker library?

I wasn't able to find a method in the python faker library similar to the javascript library method faker.fake for combining faker API methods using a mustache string format. If this does exist, can someone share references/docs on how to use this?…
K.N. Bhargav
  • 55
  • 1
  • 6
0
votes
1 answer

Using Faker to get and set gender for all following data

I'm using Faker with TypeScript and am struggling to figure out how to capture the returned gender from Faker in a way that I can then use in subsequent calls. This is what I'd like to do: const gender = faker.name.gender(true); // <-- returns a…
Anton
  • 761
  • 17
  • 40
0
votes
2 answers

Cannot integrate third party tools with TectCafe Studio

I'm new to TestCafe and TypeScript. I was trying to integrate the NanoID module to TestCafe following this tutorial. But it shows an error saying Cannot find module 'nanoid' or its corresponding type declarations. (2307). But when I tried with uuid,…