mirror of
https://github.com/jbranchaud/til
synced 2026-01-05 16:18:01 +00:00
Add Create Umbrella Task For All Test Tasks as a Mise TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1613 TILs and counting..._
|
_1614 TILs and counting..._
|
||||||
|
|
||||||
See some of the other learning resources I work on:
|
See some of the other learning resources I work on:
|
||||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||||
@@ -692,6 +692,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
|
|
||||||
### Mise
|
### Mise
|
||||||
|
|
||||||
|
- [Create Umbrella Task For All Test Tasks](mise/create-umbrella-task-for-all-test-tasks.md)
|
||||||
- [List The Files Being Loaded By Mise](mise/list-the-files-being-loaded-by-mise.md)
|
- [List The Files Being Loaded By Mise](mise/list-the-files-being-loaded-by-mise.md)
|
||||||
- [Preserve Color Output For Task Command](mise/preserve-color-output-for-task-command.md)
|
- [Preserve Color Output For Task Command](mise/preserve-color-output-for-task-command.md)
|
||||||
- [Read Existing Dot Env File Into Env Vars](mise/read-existing-dot-env-file-into-env-vars.md)
|
- [Read Existing Dot Env File Into Env Vars](mise/read-existing-dot-env-file-into-env-vars.md)
|
||||||
|
|||||||
53
mise/create-umbrella-task-for-all-test-tasks.md
Normal file
53
mise/create-umbrella-task-for-all-test-tasks.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Create Umbrella Task For All Test Tasks
|
||||||
|
|
||||||
|
When I was first sketching out the [`mise`
|
||||||
|
tasks](https://mise.jdx.dev/tasks/running-tasks.html) for a Rails app, I added
|
||||||
|
the following two tasks. One is for running all the `rspec` tests. The Other is
|
||||||
|
for running all the `vitest` (JavaScript) tests.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[tasks."test:rspec"]
|
||||||
|
run = "unbuffer bundle exec rspec"
|
||||||
|
description = "Run RSpec tests"
|
||||||
|
depends = ["bundle-install"]
|
||||||
|
|
||||||
|
[tasks."test:vitest"]
|
||||||
|
run = "unbuffer yarn test run"
|
||||||
|
description = "Run Vitest tests"
|
||||||
|
depends = ["node-install"]
|
||||||
|
```
|
||||||
|
|
||||||
|
I didn't want to have to invoked both of this individually every time I wanted
|
||||||
|
to run the full suite. So I added a `test:all` task to do it all.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[tasks."test:all"]
|
||||||
|
description = "Run all tests (RSpec and Vitest)"
|
||||||
|
run = [
|
||||||
|
"unbuffer bundle exec rspec",
|
||||||
|
"unbuffer yarn test run",
|
||||||
|
]
|
||||||
|
description = "Run RSpec tests"
|
||||||
|
depends = ["bundle-install", "node-install"]
|
||||||
|
```
|
||||||
|
|
||||||
|
This worked (for now). But it ate at me, for a couple reasons. I had to
|
||||||
|
duplicate everything about the existing `test:rspec` and `test:vitest` tasks.
|
||||||
|
And this didn't account for a new kind of test task being added (e.g.
|
||||||
|
`test:e2e`).
|
||||||
|
|
||||||
|
Instead, I can rely on `depends` and wildcards to achieve this without the
|
||||||
|
duplication which makes it more future-proof.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[tasks."test:all"]
|
||||||
|
description = "Run all tests (RSpec and Vitest)"
|
||||||
|
depends = ["test:*"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Running `mise run test:all` won't execute its own command, but because it
|
||||||
|
depends on all other `test:*` tasks, the tests will get run through those
|
||||||
|
dependencies.
|
||||||
|
|
||||||
|
This task naming pattern also allows for calling all tests with `mise run
|
||||||
|
"test:**"`.
|
||||||
Reference in New Issue
Block a user