Open michaeljones opened 6 years ago
So I had something strange in my set up (a wrapper script for elm-make) but I still experience problems with that removed. I see the issue above and then if I try to run it again I get:
$ elm coverage
[11:33:24.30] Instrumenting sources...
[11:33:28.57] Wrote original tests/elm-package.json to .coverage/elm-package.json.bak
[11:33:28.57] Running tests...
[11:33:29.50] Ruh roh, tests failed.
[11:33:29.50] Restored tests/elm-package.json
[11:33:29.50] Something went wrong:
Error: I found multiple modules named 'Coverage'.
Module 'Authoring.ActivityTemplate.Model' is trying to import it.
Modules with that name were found in the following locations:
directory /home/michael/root/projects/hive/portal/node_modules/elm-coverage/kernel-src/Coverage.elm
directory /home/michael/root/projects/hive/portal/node_modules/elm-coverage/kernel-src/Coverage.elm
Compilation failed while attempting to build ...
Which even happens immediately after elm-test
runs & passes just fine.
I'm afraid I'm quite clueless as to what it going on.
That looks like there's a duplicate entry in tests/elm-package.json
. Perhaps restoring it failed in a previous run? Can you verify that it does not include any weird stuff like that kernel-src
folder as a source-directory?
(If restoration failed, that's an issue by itself, though I suspect there's more going on here)
I'll check that. The test/elm-package.json
did seem to have been re-written to a single line of json for some reason. I'll explore that a bit more.
Another piece of the puzzle is that I have my working directly with a src
folder and 4 different entry files for 4 different apps. I have Authoring.elm
, Business.elm
, etc. I've just realised that each of these declare themselves as module Main exposing (..)
and I guess it works as they are all compiled separately via different imports to js code that is handled by webpack and webpack loader. Maybe the Main
in the original error is coming from one of those? I'll experiment.
Ohhh, yeah, that must be it.
Coverage is calculate per module. Afterwards, for generating the module, it "reverse engineers" the filename from the module-name. I hadn't realized people would have multiple Main modules, which is a perfectly fine thing to have.
I'm going to have to ponder how to handle this 🤔
Yeah, I can confirm that it works fine after fixing up the module names. Looks fantastic. Great job. Now if it could just write the tests too...
Hello @zwilias , having the same issue ("Unhandled rejection Error: ENOENT: no such file or directory, open 'src/ModuleX/Main.elm' ") just by putting my elm sources in subfolders under src, before naming the subsequent folders following the elm architecture.
Means, I have ---src/projectA/ModuleX/Main.elm
elm-coverage is trying to resolve "src/ModuleX/Main.elm" with reverse engeenering from module names, but it's not matching the actual files architecture. Maybe using the "source-directories" entry from elm-package.json can be a way to handle this problem.
Cheers,
I wanted to do some long overdue testing on my code base and hoped to use this project to guide me towards areas that could definitely need it. Looks super promising but I get an error when running it. No worries at all but just wanted to report it in case it was useful:
I'm not sure where the
src/Main.elm
is coming from as I don't have a file called that and I can't see that string in theelm-coverage
source code either.Thanks for the project though. As I said, exciting to see :)
Edit: Very happy to provide more information but I'm not sure what bits would be useful to know.