Skip to content

Commit

Permalink
Merge pull request #5584 from NomicFoundation/node-test-runner
Browse files Browse the repository at this point in the history
Node test runner plugin supporting js tests
  • Loading branch information
zoeyTM authored Aug 26, 2024
2 parents 17ba161 + c2d5655 commit 1bdf98d
Show file tree
Hide file tree
Showing 20 changed files with 360 additions and 46 deletions.
85 changes: 78 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions v-next/core/src/internal/hre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ async function resolveUserConfig(
root: projectRoot,
cache: config.paths?.cache ?? "", // TODO: resolve cache path
artifacts: config.paths?.artifacts ?? "", // TODO: resolve artifacts path
tests: config.paths?.tests ?? "test", // TODO: resolve tests path
},
};

Expand Down
2 changes: 2 additions & 0 deletions v-next/core/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface ProjectPathsUserConfig {
root?: string;
cache?: string;
artifacts?: string;
tests?: string;
}

/**
Expand All @@ -69,4 +70,5 @@ export interface ProjectPathsConfig {
root: string;
cache: string;
artifacts: string;
tests: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("ResolvedConfigurationVariable", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
hooks: hookManager,
Expand Down
14 changes: 14 additions & 0 deletions v-next/core/test/internal/hook-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
hooks: hookManager,
Expand Down Expand Up @@ -175,6 +176,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand Down Expand Up @@ -230,6 +232,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand Down Expand Up @@ -335,6 +338,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
hooks: hookManager,
Expand All @@ -355,6 +359,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand Down Expand Up @@ -441,6 +446,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand Down Expand Up @@ -564,6 +570,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
hooks: hookManager,
Expand Down Expand Up @@ -658,6 +665,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand Down Expand Up @@ -702,6 +710,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
hooks: hookManager,
Expand All @@ -720,6 +729,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand All @@ -740,6 +750,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand Down Expand Up @@ -825,6 +836,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
};

Expand Down Expand Up @@ -869,6 +881,7 @@ describe("HookManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
hooks: hookManager,
Expand Down Expand Up @@ -1030,6 +1043,7 @@ function buildMockHardhatRuntimeEnvironment(
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
tasks: mockTaskManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("UserInterruptionManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
globalOptions: {},
Expand Down Expand Up @@ -78,6 +79,7 @@ describe("UserInterruptionManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
globalOptions: {},
Expand Down Expand Up @@ -126,6 +128,7 @@ describe("UserInterruptionManager", () => {
root: projectRoot,
cache: "",
artifacts: "",
tests: "",
},
},
globalOptions: {},
Expand Down
42 changes: 3 additions & 39 deletions v-next/example-project/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { HardhatPluginError } from "@ignored/hardhat-vnext/plugins";

import {
task,
HardhatUserConfig,
emptyTask,
overrideTask,
configVariable,
globalOption,
HardhatUserConfig,
} from "@ignored/hardhat-vnext/config";
import HardhatNodeTestRunner from "@ignored/hardhat-vnext-node-test-runner";

const exampleEmptyTask = emptyTask("empty", "An example empty task").build();

Expand Down Expand Up @@ -47,40 +47,6 @@ const exampleTaskOverride = task("example2")
})
.build();

const testTask = task("test", "Runs mocha tests")
.addVariadicArgument({
name: "testFiles",
description: "An optional list of files to test",
// defaultValue: [],
})
.addFlag({
name: "noCompile",
description: "Don't compile before running this task",
})
.addFlag({
name: "parallel",
description: "Run tests in parallel",
})
.addFlag({
name: "bail",
description: "Stop running tests after the first test failure",
})
.addOption({
name: "grep",
description: "Only run tests matching the given string or regexp",
defaultValue: "",
})
.setAction(import.meta.resolve("./tasks/non-existing.ts"))
.build();

const testTaskOverride = overrideTask("test")
.addFlag({
name: "newFlag",
description: "A new flag",
})
.setAction((_taskArguments, _hre, _runSuper) => {})
.build();

const testSolidityTask = task(["test", "solidity"], "Runs Solidity tests")
.setAction(async () => {
console.log("Running Solidity tests");
Expand Down Expand Up @@ -131,14 +97,12 @@ const pluginExample = {
const config: HardhatUserConfig = {
tasks: [
exampleTaskOverride,
testTask,
testTaskOverride,
testSolidityTask,
exampleEmptyTask,
exampleEmptySubtask,
greeting,
],
plugins: [pluginExample],
plugins: [pluginExample, HardhatNodeTestRunner],
privateKey: configVariable("privateKey"),
};

Expand Down
Loading

0 comments on commit 1bdf98d

Please sign in to comment.