monkeygroover

monkeygroover

Issue with ExUnit coloring

I have an issue since upgrading to Elixir 1.15, some of our tests that use capture log are failing because the output contains ansi color escape codes. I added the following before each ExUnit.start() in each app in the umbrella to try to fix this:

ExUnit.configure(
exclude: :skip,
formatters: [ExUnit.CLIFormatter, JUnitFormatter],
capture_log: true,
colors: [enabled: false]
)

however it is now not deterministically fixing it. some runs the tests pass, and some runs the tests fail with the escape codes. Are these settings per umbrella app, or is it possible they share some global state and depending on ordering there is a race somewhere?

Most Liked

monkeygroover

monkeygroover

Yes, thank you, that helped. I’m not completely sure why i was seeing seemingly intermittent failures, but i’ve gone through and reviewed/updated all the logging settings to use the latest :default_formatter changes and then added using your suggested colors section in test and it’s all working nicely again. thanks.

eksperimental

eksperimental

You can use IO.ANSI.format(chardata, false) , convert it to a string and match on it.

iex> IO.ANSI.format(["Hello, ", :red, :bright, "world!"], true) |> to_string()
"Hello, \e[31m\e[1mworld!\e[0m"

iex> IO.ANSI.format(["Hello, ", :red, :bright, "world!"], false)
[[[], "Hello, "], "world!"]

iex> IO.ANSI.format(["Hello, ", :red, :bright, "world!"], false) |> to_string()
"Hello, world!"

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New

Other popular topics Top

stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
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
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

We're in Beta

About us Mission Statement