Dynamic chunks in parallel execution

To be more flexible in specifying chunks, passing a function will enable you to provide your own chunking algorithm. The first argument passed to you function is an array of all test files, if you enabled grep the test files passed are already filtered to match the grep pattern.

Example 1:

"multiple": {
  "parallel": {
    // Splits tests into chunks by passing an anonymous function,
    // only execute first and last found test file
    "chunks": (files) => {
      return [
        [ files[0] ], // chunk 1
        [ files[files.length-1] ], // chunk 2
      ]
    },
    // run all tests in chrome and firefox
    "browsers": ["chrome", "firefox"]
  }
}

Example 2:

"multiple": {
    "parallel": {
         "chunks": (files) => {
                return files.map(file => [file]);
              },
        }
    },
1 Like