Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mix espec.init doesn't work in umbrella apps #307

Open
alec-c4 opened this issue Jan 19, 2023 · 4 comments
Open

mix espec.init doesn't work in umbrella apps #307

alec-c4 opened this issue Jan 19, 2023 · 4 comments

Comments

@alec-c4
Copy link

alec-c4 commented Jan 19, 2023

Hi!
I'm trying to start using espec in umbrella application. Because of there are no information in README, i've just done the following steps

1 - added espec to the deps section in main app, added preferred_cli_env
2 - added espec to the every mix.esx in apps folder

when I use mix espec.init in any app folder i see following message

** (Mix) The task "espec.init" could not be found

What's wrong? May I ask you to add in README file information how to use espec in umbrella apps?

@antonmi
Copy link
Owner

antonmi commented Jan 20, 2023

Hey @alec-c4 !
Please use specify the "test" env for the task
MIX_ENV=test mix espec.init
The task just creates the "spec_helper.exs" file.

ESpec.configure fn(config) ->
  config.before fn(tags) ->
    {:shared, hello: :world, tags: tags}
  end

  config.finally fn(_shared) ->
    :ok
  end
end

You need to run the task in each app in umbrella. Since all the apps need the file

@alec-c4
Copy link
Author

alec-c4 commented Jan 20, 2023

Yay! It works! Thanks a lot! May I ask you to update README with information how to use espec in umbrella apps? And one more question 'bout code organization - should I create espec-related stuff in every project or is it better to place spec-files in root or umbrella application?

@alec-c4
Copy link
Author

alec-c4 commented Jan 20, 2023

I've added espec for every app in apps directory, then created alias in umbrella's mix'exs

  defp aliases do
    [
      # run `mix setup` in all child apps
      setup: ["cmd mix setup"],
      lint: ["credo", "dialyzer"],
      test: ["cmd mix test", "cmd mix espec"]
    ]
  end

but i'm not sure that it is the best test running strategy

@antonmi
Copy link
Owner

antonmi commented Jan 20, 2023

It's better to have separate specs for each umbrella app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants