Fl4m3Ph03n1x

Fl4m3Ph03n1x

Create an alias for another task in mix.exs?

Background

So I am using this library mix-test.watch from @lpil which I really like.

Usually I just run mix test.watch and I let the process running.

As a bonus to this library, you can also execute it by passing the --only flag. For example, if I want to watch only my “super_duper_tests” I can do it like this: mix text.watch --only super_duper_tests and this will only watch all the tests that have, for example, the @moduletag :super_duper_tests on them.

Enter Alias

So, this is all fun, but I am lazy and I don’t like typing. So I want to create an alias like this:

mix test.watch.super_duper that will be translated to mix text.watch --only super_duper_tests.

To achieve this I tried the following on my mix.exs file:

defp aliases do
  [
    "test.watch.super_duper": ["test.watch --only super_duper_tests"]
  ]
end

Problem

You may have guessed, since I am posting here, that this is not working. When I try my new alias, I get the error message Could not find test.watch task.

So obviously I am doing something wrong in the configuration.

Questions

How can I create an alias for mix test.watch?

Marked As Solved

Fl4m3Ph03n1x

Fl4m3Ph03n1x

This is how I defined it:

[{:mix_test_watch, "~> 1.0", only: :dev}]

Perhaps it should be:

[{:mix_test_watch, "~> 1.0", only: [:dev, :test]}]

right?

EDIT

Yep, it needed to be [{:mix_test_watch, "~> 1.0", only: [:dev, :test]}].

Also Liked

hauleth

hauleth

BTW I prefer to use entr or watchman with mix test --listen-on-stdin

stefanchrobot

stefanchrobot

I personally use watchexec:

watchexec -e 'ex,exs,eex,leex' -- 'mix format && mix test --stale'
stuartbain

stuartbain

Blog post showing usage of entr
https://jvns.ca/blog/2020/06/28/entr/

hauleth

hauleth

How did you defined the dependency? Are you running in correct Mix environment?

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement