I’m writing some tests for my app and sometimes I change the runtime configs for a specific test. To make sure each test runs with the config specified in config/config.exs
I’d like to “reset” the config before each test. I’ve tried adding Mix.Config.import_config("config/config.exs)
to the ExUnit setup_all
callback but apparently this function cannot be called during runtime (** (RuntimeError) could not set configuration via Mix.Config. This usually means you are trying to execute a configuration file directly instead of using the proper command, such as mix loadconfig
). Any suggestions?
Hmm, the config’s are immutable so I don’t see how they would be changing at run time…
Are you talking about something else like the application environment or so? If so then you could just take a snapshot of all it’s values and reset them all to that at the end of the testing run.
Yeah, I meant the application environment and that’s a great idea! Thanks!
1 Like