"elm test" for 0.19

The documentation for package.json indicates that elm test exists, however it doesn’t seem to ship with the elm install. Is there a new elm-test command to be found somewhere, or should we wait for elm-community/elm-test to be updated?

I’m not sure where those docs are, but it sounds like they’re pointing to the wrong thing!

Here is the elm-test CLI:

…and here is the 0.19 package:

1 Like

The documentation I mentioned are application.md and package.md linked from the 0.19 release notes. One mentions elm-test, the other elm test.

It turns out I did install the right elm-test then from NPM, but it behaves like it’s meant for 0.18, which is what caused me to ask the question. I seem to be doing something wrong:

$ ls
...
elm.json
src
tests
$ elm test
There is no test command. Try repl or init instead?

Run `elm` with no arguments to get more hints.

$ elm-test
It looks like you're running elm-test from within your tests directory.

Please run elm-test from your project's root directory, where its elm-package.json lives!
$ elm --version
0.19.0
$ elm-test --version
0.18.12

Have you tried 0.19.0-beta4?

Have you tried 0.19.0-beta4 3?

I have now, thanks. npm install elm-test@0.19.0-beta4. It seems not ready, I’m getting a host of different errors. Initially without the test dependencies specified and possibly with connectivity issues.

$ elm-test 
Unhandled exception while running the tests: SyntaxError: Unexpected token E in JSON at position 0
    at Object.parse (native)
    at askElmForMissingTransitiveDependencies (.../node_modules/elm-test/lib/elm-test.js:566:21)
$ elm-test
elm-test internal error: got an unexpected result from 'elm make' when validating transitive dependencies.  Please report this at https://github.com/rtfeldman/node-test-runner/issues
$ elm-test init
Error reading elm.json: Error: ENOENT: no such file or directory, open '.../node_modules/elm-test/templates/tests/elm.json'
$ elm-test
Unhandled exception while running the tests: TypeError: version.split is not a function
    at .../node_modules/elm-test/lib/elm-test.js:451:27
1 Like

You may have to add the --compiler=/path/to/your/elm/compiler flag if you’ve not installed 0.19 globally

Thanks, but nope, that doesn’t help. Would have been a surprise given that elm on the PATH is version 0.19.

So, small progress. It turns out that the test-dependencies fragment generated by elm-test is completely wrong. Removing direct/indirect and filling the version bound to include an upper bound gets me further.

I also struggled with switching tests of my package myrho/elm-round from 18 to 19. I ran into similar issues. My learnings:

  • There must not be an elm.json file in your tests directory. There need only be your elm files with Tests in it.
  • Cleanup your workspace: Delete elm-stuff.
  • in your elm.json file’s test-dependencies section, add the line `“elm-explorations/test”: “1.0.0 <= v < 2.0.0”
  • Here is a working package that helped me also: https://github.com/lukewestby/elm-string-interpolate. Its updated for elm 0.19 in source and tests.
3 Likes

Hmm, what fragment is this? I’m not sure what this is referring to, sorry!

I had used elm-test init which put a test-dependencies section in elm.json, including a dependency on elm-explorations/test with a fixed version. I think the core of the issue was that I was trying to test a package, while elm-test assumes that you’re testing an app and sets things up accordingly. This was quite hard to figure out because it doesn’t say very clearly what goes wrong.

I’m having some really basic issues getting elm-test working with 0.19. I installed what I think is the correct version of elm-test:

elm-quickstart master % elm-test --version                
0.19.0-beta4

But when I try to run elm-test init, I get this:

elm-quickstart master % elm-test init
Created /Users/bill/Projects/elm-quickstart/tests
Error reading elm.json: Error: ENOENT: no such file or directory, open '/Users/bill/.nvm/versions/node/v8.7.0/lib/node_modules/elm-test/templates/tests/elm.json'

Any idea what I’m missing?

@bill.peregoy, elm-test@beta is now 0.19.0-beta6, so I would remove the build artifact directory elm-stuff and try again with the last release. Also check that you use the last elm-exploration/test version, which is 1.1.0.

Thanks @dmy but I still get the same error with the beta6 version of elm-test.

@bill.peregoy the beta doesn’t support init yet, sorry! If you want to track when it’ll be added, this is the WIP PR: https://github.com/rtfeldman/node-test-runner/pull/265

2 Likes

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