Files
nomad/ui/mirage/faker.js
Buck Doyle 5237c11817 Add logged Faker seed when none is set in tests (#9140)
This will hopefully make it easier to reproduce test failures
that happen intermittently, especially in CI.
2020-10-22 13:45:51 -05:00

21 lines
654 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);
}
} 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;