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

"MODULE NOT FOUND" error for test-dependencies #105

Closed
robyoder opened this issue May 19, 2020 · 6 comments
Closed

"MODULE NOT FOUND" error for test-dependencies #105

robyoder opened this issue May 19, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@robyoder
Copy link

Expected Behavior

I have elm-explorations/test in my test-dependencies in elm.json. That should be sufficient for my test files to be able to import modules from that package without errors.

Current Behavior

The following errors show up in the Problems pane in VS Code (although compiling and running elm-test work just fine):

MODULE NOT FOUND - You are trying to import a `Expect` module:

3| import Expect
          #^^^^^^#
I checked the "dependencies" and "source-directories" listed in your elm.json,
but I cannot find it! Maybe it is a typo for one of these names?

#    Dict
    Set
    Array
    Html#

#Hint#: If it is not a typo, check the "dependencies" and "source-directories" of
your elm.json to make sure all the packages you need are listed there!
MODULE NOT FOUND - You are trying to import a `Test` module:

5| import Test exposing (Test, describe, test)
          #^^^^#
I checked the "dependencies" and "source-directories" listed in your elm.json,
but I cannot find it! Maybe it is a typo for one of these names?

#    Set
    Task
    Dict
    Html#

#Hint#: If it is not a typo, check the "dependencies" and "source-directories" of
your elm.json to make sure all the packages you need are listed there!

Screen Shot 2020-05-18 at 9 46 08 PM

Steps to Reproduce

I have the following elm.json:

{
    "type": "application",
    "source-directories": [
        "client/src",
        "client/tests"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "NoRedInk/elm-json-decode-pipeline": "1.0.0",
            "elm/browser": "1.0.1",
            "elm/core": "1.0.2",
            "elm/html": "1.0.0",
            "elm/http": "2.0.0",
            "elm/json": "1.1.3",
            "elm/url": "1.0.0",
            "elm-community/dict-extra": "2.4.0",
            "elm-community/json-extra": "4.0.0"
        },
        "indirect": {
            "elm/bytes": "1.0.8",
            "elm/file": "1.0.5",
            "elm/parser": "1.1.0",
            "elm/time": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "rtfeldman/elm-iso8601-date-strings": "1.1.2"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {
            "elm/random": "1.0.0"
        }
    }
}

As you can see from source-directories, the file structure is

client
    src
        [main app files]
    tests
        SortTests.elm

It's inside SortTests.elm that this error appears (and other files in that directory). I can get rid of the error by moving elm-explorations/test and elm/random into the corresponding fields under dependencies instead of under test-dependencies.

Your Environment

  • Version used: 0.10.2
  • Editor name and version: VS Code 1.45.1
  • Environment name and version: node.js 10.16.0
  • Operating System and version: macOS 10.15.4
@razzeee
Copy link
Member

razzeee commented May 21, 2020

Can you manage to get the same error with https://github.com/rtfeldman/elm-spa-example ? Do you need to make changes for it to error for you, or does it error out of the box?

@razzeee razzeee added the bug Something isn't working label Aug 29, 2020
@razzeee
Copy link
Member

razzeee commented Oct 10, 2020

Closing due to no reply.

@witoldsz
Copy link

I am having similar problems: the project compiles and tests just fine, but the plugin complains:

Could not find a module to import named `Expect` in `dependencies` or `source-directories`.
Could not find a module to import named `Test` in `dependencies` or `source-directories`.

The "blue bulb" asks me if I want to install elm-explorations/test and when I do so, the message pops up:

I found it in your elm.json file, but in the "test-dependencies" field. 
Should I move it into "dependencies" for more general use?

Source: Elm (Extenstion)    [Yes]  [No]

The directory contains both TypeScript files (in ./src and ./test) and Elm (in ./elm and ./test/elm).

I have tried the elm-spa-example and it works fine, however it's strange that there are additional elm-package.json. I don't know what's that file there for?

@witoldsz
Copy link

OK, now I can see the problem. This plugin expects the tests to be in tests directory and I have them in test. Oh, too bad the #139 is not ready yet.

It looks my colleague who was coding the code I am working with right now, he was using Intellij Idea plugin, because I can see the elm.intellij.json file:

{
  "test-directory": "test/elm"
}

@abury
Copy link

abury commented Jun 22, 2021

I'm having the same issue, would love to know if there is a work around. The project I'm working on has the test file alongside the regular file with the Testsuffix.

@razzeee
Copy link
Member

razzeee commented Jun 23, 2021

No, there is no work around, test detection needs to be implemented, which should be a bit more straight forward since the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants