Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use faker.js in typescript?

As in topic. I cannot handle it :/ I've installed npm i faker and also npm i @types/faker --save-dev

my IDE found fakerStatic.name.findName() but browser not recognizes fakerStatic.

import 'faker'; does not help.

like image 733
piernik Avatar asked Jul 24 '17 10:07

piernik


People also ask

Can we still use Faker JS?

FAQ - What happened to the original faker. js? This project was originally created and hosted at https://github.com/marak/Faker.js/ - however around 4th Jan, 2022 - the author decided to delete the repository (for unknown reasons).

What can I use instead of Faker in Javascript?

Falso is a modern alternative to Faker. js. Fake data can be useful when building and testing applications. Falso can generate fake data in various areas, including address, commerce, company, date, finance, image, random, and more.

What is NPM faker?

Faker is a popular library that generates fake (but reasonable) data that can be used for things such as: Unit Testing. Performance Testing. Building Demos. Working without a completed backend.


1 Answers

You have to import it like:

import * as faker from 'faker';

And use it like:

faker.name.findName()
like image 111
Saravana Avatar answered Oct 10 '22 21:10

Saravana