Skip to content

Commit

Permalink
feat: ✨ Added vitest arg passthrough to moonwall config
Browse files Browse the repository at this point in the history
  • Loading branch information
timbrinded committed Dec 5, 2024
1 parent d892adc commit 02f186b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .changeset/smooth-bears-hunt.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@
```bash
moonwall test dev_test --vitest "bail=2 retry=2"
```

This can also be added to your `moonwall.config.json` file like:

```json
{
"name": "passthrough_test",
"testFileDir": ["suites/multi_fail"],
"description": "Testing that bail can be passed through",
"foundation": {
"type": "read_only"
},
"vitestArgs": {
"bail": 1
},
"connections": []
}
```
6 changes: 6 additions & 0 deletions packages/cli/src/cmds/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export async function executeTests(env: Environment, testRunArgs?: testRunArgs)
.setTimeout(env.timeout || globalConfig.defaultTestTimeout)
.setInclude(env.include || ["**/*{test,spec,test_,test-}*{ts,mts,cts}"])
.addThreadConfig(env.multiThreads)
.addVitestPassthroughArgs(env.vitestArgs)
.build();

if (
Expand Down Expand Up @@ -218,6 +219,11 @@ class VitestOptionsBuilder {
return this;
}

addVitestPassthroughArgs(args?: object): this {
this.options = { ...this.options, ...args };
return this;
}

addThreadConfig(threads: number | boolean | object = false): this {
this.options.fileParallelism = false;
this.options.pool = "forks";
Expand Down
7 changes: 7 additions & 0 deletions packages/types/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@
},
"type": "object"
},
"Record<string,any>": {
"type": "object"
},
"ZombieLaunchSpec": {
"description": "A launch specification object for the \"zombie\" foundation type.",
"properties": {
Expand Down Expand Up @@ -679,6 +682,10 @@
"timeout": {
"description": "The default timeout for tests and hooks",
"type": "number"
},
"vitestArgs": {
"$ref": "#/definitions/Record<string,any>",
"description": "An optional object to add extra arguments to the Vitest test runner.\n Use with caution as this will override the default arguments, which\nmay cause unexpected behaviour.\n\nVisit https://vitest.dev/config/ for more info"
}
},
"type": "object"
Expand Down
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"ethers": "*",
"polkadot-api": "*",
"viem": "*",
"vitest": "*",
"web3": "*"
},
"publishConfig": {
Expand Down
9 changes: 9 additions & 0 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ export type Environment = {
* A list of test to skip.
*/
skipTests?: SkipTestSpec[];

/**
* An optional object to add extra arguments to the Vitest test runner.
* Use with caution as this will override the default arguments, which
* may cause unexpected behaviour.
*
* Visit https://vitest.dev/config/ for more info
*/
vitestArgs?: Record<string, any>;
};

export type SkipTestSpec = {
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

3 changes: 3 additions & 0 deletions test/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
"disableRuntimeVersionCheck": true
}
},
"vitestArgs": {
"bail": 1
},
"connections": []
},
{
Expand Down

0 comments on commit 02f186b

Please sign in to comment.