Custom path for elm tests fails

Hi Elm Community!

I am using elm-explorations/test with rtfeldman/node-test-runner to run tests within my elm project.

I have my tests within a custom directory so I attempt to use the glob option within the node-test-runner for elm to find and execute the tests. I receive this error every time I attempt to execute the tests:

My run command: elm-test "custom_name_example/*.elm"

Error:
I couldn't find any exposed values of type Test in files matching "/[abs_path]/custom_name_example/Example.elm"

I replicated this issue with a new elm project. To replicate:

  • Create a new elm project (elm init)
  • Init elm test (elm-test init)
  • Move the elm tests folder and call it something custom.
  • Attempt to run the tests from the custom folder (elm-test “[custom_name]/*.elm”)

I am unsure what the problem is as there are many examples of people using globs in custom directories for their elm tests.

Hi, the issue is that module names have to match with their paths. When you use globs, instead of the tests/ folder, the module names inside those files must match with the path from an elm source directory. I don’t think elm-test is able to guess which source directories exist if you don’t specify them somewhere. If you add custom_name_example to the list of source directories in your elm.json file, elm-test should work I think.

1 Like

See this for more information: https://github.com/lydell/node-test-runner/blob/improve-readme/README.md#where-to-put-your-tests

(That comes from this pull request: https://github.com/rtfeldman/node-test-runner/pull/473)

(Also note that some information in that link might not be 100% accurate currently – some details might depend on fixed bugs that haven’t been released to npm yet.)

1 Like

Thank you @mattpiz and @lydell, noob problem solved!! :slight_smile:

Also @lydell, as I tried to solve this problem myself I saw your recent activity on improving the node-test-runner package, excellent work on making the open source world better!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.