Comments (2)
Hi @kioan000
I'm not sure I understand the issue. Can you clarify what you mean with "in-module" test configuration? And would it be possible for you to provide an SSCCE?
from elm-review-ports.
You're right sorry.
In this project I've configured elm-test to keep test functions within the source modules instead of having an external test
folder. The project have a quite strict elm-review configuration (almost 30-35 review rules)
Unluckily it regards code from a private organization so I can't share the repository and despite my efforts I didn't succeed in reproducing a simplified example since I can't find a common pattern. It's a very bizarre case
For example in the following situation
port module Lib.CookieBar exposing (CookieBar, init, subscriptions, view, update, test)
import Lib.Logger as Logger
...
update : Msg -> CookieBar msg -> ( CookieBar msg, Cmd msg )
update msg model =
case msg of
...
SubError error ->
model
|> PrimaUpdate.withCmds
[ Logger.devConsoleErrorForJsonDecodeError
{ location = "CookieBar subscription port is used wrongly: "
, error = error
}
]
test : Test
test =
Test.describe "Lib.CookieBar tests"
[ updateTest
]
updateTest : Test
updateTest =
Test.describe "Test over update function"
[ Test.test "Tests init state"
(\() ->
init (always ())
|> isVisible
|> Expect.false "Cookie bar should be invisibile at init"
)
]
everything works fine. But if I add a test that calls my update:
updateTest : Test
updateTest =
Test.describe "Test over update function"
[ Test.test "Tests init state"
(\() ->
init (always ())
|> isVisible
|> Expect.false "Cookie bar should be invisibile at init"
)
, Test.test "Visible flag should be True when cookies acceptance is not present"
(\() ->
init (always ())
|> update (HasCookiesAcceptance False)
|> Tuple.first
|> isVisible
|> Expect.true "Cookie bar should be visible"
)
]
Then the rule notices not only that CookieBar.test
calls a port inside Logger
module, but suddenly reports the same thing in Lib.Authenticator.test
(which calls the same port through its update function) that previously wasn't noticed
-- ELM-REVIEW ERROR --------------------------------- web-app/Lib/Logger.elm:8:6
NoUnusedPorts: Port `loggerPort_` is never used (Warning: can cause JS runtime
errors)
8| port loggerPort_ : JsonEncode.Value -> Cmd msg
^^^^^^^^^^^
Unused ports are not available in the compiled JavaScript and can cause runtime
errors when you try to access them.
You should either use this port somewhere, or remove it at the location I
pointed at. This may highlight some other unused code in your project too.
Warning: If you remove this port, remember to remove any calls to it in your
JavaScript code too.
I found this port called by the following functions, but none of them trace back
to a `main` function:
-> Lib.CookieBar.test
-> **Lib.Http.Authenticator.test**
-> Lib.Logger.devConsoleErrorForHttp
-> Lib.Logger.devConsoleErrorForJsonDecodeError
-> Lib.Logger.devConsoleLog
-> Lib.Logger.devConsoleWarn
from elm-review-ports.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elm-review-ports.