-
Notifications
You must be signed in to change notification settings - Fork 28
[Bug] mix() function throw exceptions during testing. #634
Comments
Just ran into this issue on CircleCI. |
A while ago Taylor said he was interested in resolving this issue, so I think a PR would definitely be welcome. I think I'd rather keep the Maybe a config value like |
function mix($path, $manifestDirectory = '')
{
return app('mix')->mix($path, $manifestDirectory);
} This is the way to go in my opinion. |
Sounds good for me @sebastiandedeyne! So for you we have to let all this stuff just in the helper function? I think it could be a good idea to migrate that to a proper dedicated service. edit: didn't see @JulienTant comment (and your +1 on it) |
Changed my mind, actually prefer @JulienTant's idea 😄 |
So, first case I described? Just a container, and then we have to mock it? Or we can mix both: migrate to a proper service, AND use a config variable, which is my opinion. |
Yeah that would definitely be easier to use. Not sure about what the variable should be called though... Something like |
Yep, but I like mix.environments. or maybe in I personally prefer the first case. |
There's two cases where the
I can understand that you want to mock it for the tests when you don't want to run your assets compilation, but i'm not a supporter of having a configuration option to "bypass" the function when you decide to use it (instead of just calling the If you have this special case when you want to change something or bypass for some reason, you can always overload |
Using a manifest file and not wanting to depend on assets in a CI environment seems like a common enough use case to have an "easy way out" imo, instead of having to maintain a custom service provider in your application. |
You can simply mock the I'm quite against the configuration here because you add in the code complexity which has the only purpose of helping you doing tests. Using |
@JulienTant As you can see in my post, it was my first idea. If it's not a config variable, it totally can be just method which mock mix(), like The only problem here is dusk, so the real question is:
I don't think so personally, so this solution is totally ok for me. |
Instead of resolving stuff out of the container, why not just check to see if |
@joshmanders because in case of a non testing env, mix() should trow an error if the manifest doesn't exist. The is the case now and it should do that actually. |
@sebastiandedeyne @JulienTant |
Guys, I'm sorry but @taylorotwell closed all the PRs I've made for that, without any consideration for all the comments, reviews, and after 3 weeks of discussions. I've no idea of what is the problem, code is cleaner, fully tested, and all the demanded features was added. I'm done with that, I've lost enough time, if someone want to try, please do ! The last PR is here : laravel/framework#19895 |
Thanks for your work @mathieutu and please don't get discouraged, as @taylorotwell mentioned on laravel/framework#19895 (comment) smaller improvements are always better than rewriting the whole thing in one go. While i would really appreciate your PR to be merged i also see @taylorotwell point of view. Maybe @taylorotwell can shed some light on what he would prefer to see done first? |
Just ran into the same issue, thanks for your work @mathieutu! Using your helper function for the time being, hope @taylorotwell will fix this. |
Yeah, thank you @mathieutu for working so hard on a fix for this, really disappointed this is still an issue. |
Just an observation: I too am having this issue. I did use the method that @mathieutu suggested: |
@amylashley Can you give us some more information ? What did you do exactly, and what is the error ? |
Sure @mathieutu. I used this package to change the loading order so that I could add a helpers.php file. Then in my helpers.php file I added this method:
This works great with PHPUnit. The test that was failing is now passing. However, with the same code in place, running Dusk (or Selenium with this package) both fail and give me only a white browser screen. That's the only feedback I seem to be able to get from Dusk- just a white screen. Once I comment out my new mix method, the Dusk tests are back to passing. |
Hi, it's totally normal that in that case dusk fail, your function can't work properly. The mix() function is overwritten, so you can't call it inside itself. You're just doing some recursive calls... |
This should be closed. You can simply run |
Hi,
as @themsaid asked in laravel/framework#19552, I'm reposting here :
I have a problem with the
mix()
function.When I'm executing my tests, especially with travis I don't run all the webpack stuff: I don't need it, as I'm just testing controllers, services, etc.
Not Js and css things.
BUT, when I'm trying to make a
get
on a route which return a view, I always have a an exception from the mix() helper method.Example :
Will throw a
The Mix manifest does not exist.
exception.This is really annoying to have to install modules and compile assets we don't need..!
And we can't overwrite, or mock, or anything, because this is not part of the container or something like that, but just a basic function in
helpers.php
file.Maybe we can make a service for that, and just do:
in helpers.php
It will permit to mock it in tests:
or something like that.
I can make the PR when we have choose a solution.
For now, I've just made this bad thing to fix it:
This is also a (quickest and dirtiest) option, but it may cause conflict with Laravel dusk ?
We also could do sort of:
I'm waiting for all your good ideas guys !
Matt'
The text was updated successfully, but these errors were encountered: