1
1
import type { HardhatConfig } from "@ignored/hardhat-vnext/types/config" ;
2
2
import type { NewTaskActionFunction } from "@ignored/hardhat-vnext/types/tasks" ;
3
+ import type { LastParameter } from "@ignored/hardhat-vnext/types/utils" ;
3
4
4
5
import { finished } from "node:stream/promises" ;
5
6
import { run } from "node:test" ;
@@ -11,6 +12,7 @@ import { getAllFilesMatching } from "@ignored/hardhat-vnext-utils/fs";
11
12
interface TestActionArguments {
12
13
testFiles : string [ ] ;
13
14
only : boolean ;
15
+ grep : string ;
14
16
}
15
17
16
18
function isTypescriptFile ( path : string ) : boolean {
@@ -48,7 +50,7 @@ async function getTestFiles(
48
50
* Note that we are testing this manually for now as you can't run a node:test within a node:test
49
51
*/
50
52
const testWithHardhat : NewTaskActionFunction < TestActionArguments > = async (
51
- { testFiles, only } ,
53
+ { testFiles, only, grep } ,
52
54
hre ,
53
55
) => {
54
56
const files = await getTestFiles ( testFiles , hre . config ) ;
@@ -58,6 +60,13 @@ const testWithHardhat: NewTaskActionFunction<TestActionArguments> = async (
58
60
59
61
async function runTests ( ) : Promise < number > {
60
62
let failures = 0 ;
63
+
64
+ const nodeTestOptions : LastParameter < typeof run > = { files, only } ;
65
+
66
+ if ( grep !== "" ) {
67
+ nodeTestOptions . testNamePatterns = grep ;
68
+ }
69
+
61
70
const reporterStream = run ( { files, only } )
62
71
. on ( "test:fail" , ( event ) => {
63
72
if ( event . details . type === "suite" ) {
0 commit comments