mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 01:15:43 +03:00
This sets a default-but-query-configurable Faker seed in development, via faker-seed. It also changes uses of Math.random to use Faker’s randomness so auto-generated data remains stable in development.
17 lines
438 B
JavaScript
17 lines
438 B
JavaScript
import faker from 'faker';
|
|
import config from 'nomad-ui/config/environment';
|
|
|
|
const searchIncludesSeed = window.location.search.includes('faker-seed');
|
|
|
|
if (config.environment !== 'test' || searchIncludesSeed) {
|
|
if (searchIncludesSeed) {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const seed = parseInt(params.get('faker-seed'));
|
|
faker.seed(seed);
|
|
} else {
|
|
faker.seed(1);
|
|
}
|
|
}
|
|
|
|
export default faker;
|