From 062e26ec4f0a29344be1eb1eedbe797f2795f542 Mon Sep 17 00:00:00 2001 From: Yuri Tkachenko Date: Mon, 26 Feb 2024 12:26:46 +0100 Subject: [PATCH] test: run tests in parallel mode by default --- hardhat.config.ts | 5 +++++ package.json | 2 +- .../assertion/revertedWithOZAccessControlError.ts} | 3 +-- test/setup/index.ts | 12 ++++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) rename test/{utils/expect.ts => setup/assertion/revertedWithOZAccessControlError.ts} (99%) create mode 100644 test/setup/index.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index 9691b7518..28e4f6a23 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -14,6 +14,8 @@ import { globSync } from "glob"; import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names"; import { HardhatUserConfig, subtask } from "hardhat/config"; +import { mochaRootHooks } from "./test/setup"; + const config: HardhatUserConfig = { defaultNetwork: "hardhat", solidity: { @@ -75,6 +77,9 @@ const config: HardhatUserConfig = { start: "echo Running tests...", }, }, + mocha: { + rootHooks: mochaRootHooks, + }, warnings: { "@aragon/**/*": { default: "off", diff --git a/package.json b/package.json index e0cc163a2..1288c3ae9 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint:ts:fix": "pnpm lint:ts --fix", "lint": "pnpm lint:sol && pnpm lint:ts", "format": "prettier . --write --ignore-path .gitignore --ignore-path .prettierignore", - "test": "pnpm hardhat test", + "test": "pnpm hardhat test --parallel", "test:coverage": "pnpm hardhat coverage", "test:trace": "pnpm hardhat test --trace", "watch:test": "pnpm hardhat watch test", diff --git a/test/utils/expect.ts b/test/setup/assertion/revertedWithOZAccessControlError.ts similarity index 99% rename from test/utils/expect.ts rename to test/setup/assertion/revertedWithOZAccessControlError.ts index 750ed0d5c..c30dfe2ee 100644 --- a/test/utils/expect.ts +++ b/test/setup/assertion/revertedWithOZAccessControlError.ts @@ -1,9 +1,8 @@ -import { Assertion, expect, util } from "chai"; - /** * Custom Chai assertions along with types should be defined in this file. * The file will be auto-included in the test suite by the chai setup, no need to import it. */ +import { Assertion, expect, util } from "chai"; declare global { // eslint-disable-next-line @typescript-eslint/no-namespace diff --git a/test/setup/index.ts b/test/setup/index.ts new file mode 100644 index 000000000..5045f4531 --- /dev/null +++ b/test/setup/index.ts @@ -0,0 +1,12 @@ +import * as Mocha from "mocha"; + +import "./assertion/revertedWithOZAccessControlError"; + +/** + * This is used to add custom assertions to the Chai assertion library in the test suite when it's run in parallel mode. + */ +export const mochaRootHooks = { + beforeEach(done: Mocha.Done) { + done(); + }, +};