open-nomad/ui/mirage/faker.js
Phil Renaud 916dbdcd2f
Visual diff tests seed-stabilized by default (#12965)
* Seed-stabilization by default

* Hide right-column of topology viz route

* Remove seedless run from thee test:* suite

* Related evals paths render too late

* Vis:Hidden another topo viz unstable item
2022-05-12 16:09:19 -04:00

27 lines
694 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' ||
config.percy.enabled ||
searchIncludesSeed
) {
if (searchIncludesSeed) {
const params = new URLSearchParams(window.location.search);
const seed = parseInt(params.get('faker-seed'));
faker.seed(seed);
} else {
faker.seed(1);
}
} else if (config.environment === 'test') {
const randomSeed = faker.random.number();
console.log(
`No seed specified with faker-seed query parameter, seeding Faker with ${randomSeed}`
);
faker.seed(randomSeed);
}
export default faker;