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

The following examples show how to use hardhat/builtin-tasks/task-names#TASK_TEST. 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: index.ts    From hardhat-deploy with MIT License 6 votes vote down vote up
task(TASK_TEST, 'Runs mocha tests')
  .addFlag('deployFixture', 'run the global fixture before tests')
  .addFlag('noImpersonation', 'do not impersonate unknown accounts')
  .setAction(async (args, hre, runSuper) => {
    if (args.noImpersonation) {
      deploymentsManager.disableAutomaticImpersonation();
    }
    if (args.deployFixture || process.env.HARDHAT_DEPLOY_FIXTURE) {
      if (!args.noCompile) {
        await hre.run('compile');
      }
      await hre.deployments.fixture(undefined, {
        keepExistingDeployments: true, // by default reuse the existing deployments (useful for fork testing)
      });
      return runSuper({...args, noCompile: true});
    } else {
      return runSuper(args);
    }
  });
Example #3
Source File: hardhat.config.ts    From balancer-v2-monorepo with GNU General Public License v3.0 5 votes vote down vote up
task(TASK_TEST)
  .addOptionalParam('fork', 'Optional network name to be forked block number to fork in case of running fork tests.')
  .addOptionalParam('blockNumber', 'Optional block number to fork in case of running fork tests.', undefined, types.int)
  .setAction(test);