All files / src/tests mocking.ts

91.66% Statements 11/12
72.72% Branches 8/11
100% Functions 2/2
91.66% Lines 11/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28300x         1x 1x         1x   1x   1x 1x     1x 1x 1x     1x      
// Creates a global seed used for generating mock data for this test
// Mock data is generated using faker.js based on the Zod schema which
// is defined in our ts-rest contract
 
// Generates a random integer between min and max inclusive
function randInt(min: number, max: number): number {
  return Math.floor(Math.random() * (max - min + 1) + min);
}
 
// Use seed from npm command line (or generate one if not found)
// npm --seed=123456 run test
let usingRandomSeed = process.env.npm_config_seed == null;
 
let seed: number = Number(process.env.npm_config_seed);
 
if (!Number.isSafeInteger(seed)) {
  usingRandomSeed = true;
}
 
if (usingRandomSeed) {
  seed = randInt(1, 100000);
  console.log(`Running tests with random seed [${seed}]`);
} else E{
  console.log(`Running tests with set seed [${seed}]`);
}
 
export { seed };