hardhat/builtin-tasks/task-names#TASK_TEST_GET_TEST_FILES TypeScript Examples

The following examples show how to use hardhat/builtin-tasks/task-names#TASK_TEST_GET_TEST_FILES. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: parallelTest.ts    From hoprnet with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Put test files into groups that shares the same ganache instances
 */
async function main(opts: ParallelTestCLIOpts, { run, config }: HardhatRuntimeEnvironment): Promise<void> {
  const groupedTestFiles = [] // an array of arrays of relative paths of test files. Test files of one array shares the same hardhat node instance.
  // Test files without specifying their initialDate are saved in this variable. They use the default initialDate (now). This variable is populated with all the test files under the default test folder
  let remainingTestFiles: string[] = await run(TASK_TEST_GET_TEST_FILES)

  // put test files into groups with specified ganach starting dates
  if (opts.config.length > 0) {
    // put test files into groups
    opts.config.forEach((parallelGroup) => {
      const testFiles = parallelGroup.testFiles.map((testFile) => resolve(config.paths.tests, testFile))
      remainingTestFiles = remainingTestFiles.filter((remainingTestFile) => !testFiles.includes(remainingTestFile))
      groupedTestFiles.push(testFiles)
    })
  }
  // leave the remaining test files with the default hardhat config file.
  groupedTestFiles.push([...remainingTestFiles])

  // run tests with their config files
  for (const testFiles of groupedTestFiles) {
    await run(TASK_TEST, { testFiles })
  }
}
Example #2
Source File: hardhat.config.ts    From shoyu with MIT License 5 votes vote down vote up
task(TASK_TEST_GET_TEST_FILES).setAction(async (args, hre, runSuper) => {
    const files = await runSuper(args);
    return files.filter(file => !file.includes("test/typechain") && !file.includes("test/utils"));
});