Routes registered via defineRoutes()
not working
#64
Replies: 4 comments
-
However, feel free to implement a PR to change this if you can. |
Beta Was this translation helpful? Give feedback.
-
I think a work around would be to define your routes in a TestProvider that is booted only in the test environment, by only registering with Testbench-Dusk You might also be able to use the tweakApplication method to inject the routes, since that is used when booting the server using the test class. |
Beta Was this translation helpful? Give feedback.
-
@Keoghan that does indeed work, but with a catch. I was hoping it would be as simple as this:
However, upon further investigation, I found that the way the server app stuff registered in the What does work is just defining the routes directly in the method:
So, as much as I'd like to submit a PR to provide this functionality, I'm not sure of a way to deal with the serialization. This is a shame, because it would be a really simple and universal way to allow routes to be registered regardless of how tests are being run. |
Beta Was this translation helpful? Give feedback.
-
UPDATE: I'm dumb. I can just call it statically. this works just fine:
as far as a PR goes, just dropping that in the base |
Beta Was this translation helpful? Give feedback.
-
N/A
Description:
I've found that routes defined in tests via
defineRoutes()
are not reachable via testbench-dusk`. Oddly, they are reachable via the standard test suite.I would very much like to avoid defining routes in a package I'm developing that exists just for the sake of testing. Being able to define routes that only exist for testing is a must.
Steps To Reproduce:
I've uploaded a barebones repo here: https://github.com/clink-aaron/testbench-demo that clearly demonstrates the issue. I've copied the instructions into the readme there as well.
First install the dependencies:
Run the tests
BasicTest::testRoute()
passesBrowserTest::testRoute()
passesBrowserTest::testBrowser()
failstests/Browser/sreenshots/
directory contains an image indicating a 404 errorI would expect that routes registered would be available. I've not yet found a workaround for this issue.
Beta Was this translation helpful? Give feedback.
All reactions