Reputation: 10818
I have an issues with faker.fake()
generating decimal value from template
const a = faker.finance.amount(9, 100, 4); // all good
const b = faker.fake('{{finance.amount(9, 100, 4)}}'); // always NaN
However things like
const c = faker.fake('{{random.number}}') // all good
works just fine ^.
I am using fakerjs
4.1.0
Thoughts?
Upvotes: 2
Views: 308
Reputation: 18217
This seems to be a bug inside faker.js, so you will have to use finance.amount directly and not faker.fake.
If you read the faker.js source, you can see it uses call:
this.fake = function fake (str) {
...
result = fn.call(this, params);
...
}
If you call faker.fake('{{finance.amount(9, 100, 4)}}'); it will internally try to call faker.finance.amount("9, 100, 4"); which results in NaN.
There seems to be no way to pass three arguments to finance.amount using faker.fake.
Upvotes: 1