cypress-parallel icon indicating copy to clipboard operation
cypress-parallel copied to clipboard

parallel-weights.json not generated

Open delmorof opened this issue 3 years ago • 6 comments

When cypress-parallel is running in a Docker container that exits immediately after having completed the tests suites, it never writes the file parallel-weights.json because the process terminate before.
I think that the problem it's caused by using asynchronous write API to write the file.

function generateWeightsFile(specWeights, totalDuration, totalWeight) {
  Object.keys(specWeights).forEach((spec) => {
    specWeights[spec].weight = Math.floor(
      (specWeights[spec].time / totalDuration) * totalWeight
    );
  });
  const weightsJson = JSON.stringify(specWeights);
  fs.writeFile(`${settings.weightsJSON}`, weightsJson, 'utf8', (err) => {
    if (err) throw err;
    console.log('Generated file parallel-weights.json.');
  });
}

I have changed this function and apparently works:

function generateWeightsFile(specWeights, totalDuration, totalWeight) {
  Object.keys(specWeights).forEach((spec) => {
    specWeights[spec].weight = Math.floor(
      (specWeights[spec].time / totalDuration) * totalWeight
    );
  });
  const weightsJson = JSON.stringify(specWeights);
  fs.writeFileSync(`${settings.weightsJSON}`, weightsJson, 'utf8');
}function generateWeightsFile(specWeights, totalDuration, totalWeight) {
  Object.keys(specWeights).forEach((spec) => {
    specWeights[spec].weight = Math.floor(
      (specWeights[spec].time / totalDuration) * totalWeight
    );
  });
  const weightsJson = JSON.stringify(specWeights);
  fs.writeFileSync(`${settings.weightsJSON}`, weightsJson, 'utf8');
}

delmorof avatar Sep 30 '21 09:09 delmorof

I've put up a PR for this issue here https://github.com/tnicola/cypress-parallel/pull/73

brady727 avatar Dec 12 '21 04:12 brady727

@delmorof Should be fixed now in 0.7.0, thanks @brady727

tnicola avatar Dec 13 '21 19:12 tnicola

Hi @tnicola

I'm a beginner in Cypress and currently trying to implement Parallel execution in my project. Since I do not have a distributed environment, hence trying to have parallel execution locally.

Came across your solution for this and after doing npm i cypress-parallel, I still don't see the parallel-weights.json being generated(considering the latest version 0.7.0). And when I run my npm run cy:parallel script, I see below message on terminal Weights file not found in path cypress/parallel-weights.json and the tests are not running in parallel in fact there is only 1 instance of browser opening.

Could you please help me overcome this issue.

TIA.

aasthajk avatar Dec 16 '21 09:12 aasthajk

I am using version 0.9.0, and I'm getting the same error "Weights file not found in path cypress/parallel-weights.json." please replay how to resolve this issue.

HM-Tapan avatar Jan 28 '22 14:01 HM-Tapan

I am using version 0.9.0, and I'm getting the same error "Weights file not found in path cypress/parallel-weights.json." please replay how to resolve this issue.

Any idea when the problem will be solved?

laviniaSer07 avatar Feb 16 '22 15:02 laviniaSer07

I encountered this issue, but I have already resolved it. Here is my solution: I relocated the specs directory to a specific folder that only contains spec files, with no sub-folders present

haucongle avatar Feb 01 '23 02:02 haucongle