Closed ronaldwanink closed 8 months ago
Hmm.. reading 110 this should not happen?
update: I get a InvalidPathException, not a MissingSpecException (which I expected) update: the controller does not get called, so apparently the exception is caused by Spectator before calling it.
From Middleware.php
$pathItem = $this->pathItem($request_path, $request->method())
throws InvalidPathException, so not only request and response validations are skipped, but also the actual call $response = $next($request);
Since this is opposite of the expected behaviour, this seems a blocking issue for me so far? It did not happen with v1.7.1, the tests use a ton of these constructs.
I solved this issue for now by disabling the middleware, execute the call, and enable the middleware again.
I have a similar problem: I'm trying to call in my test a route that's covered by a different spec that was loaded via Spectator::setPathPrefix and the middleware complains it doesn't know about it.
I can't figure out a simple way to disable Spectator for that particular request, but it would be useful to be able to put it in "transparent mode" (probably raising an exception if some schema assertion is attempted).
Meanwhile I can probably move my call in a different testcase.
@ronaldwanink You can call Spectator::using(null);
before the http call to disable Spectator for the route.
Does it work the way you expected ?
Just saw in the codebase, you cal also call Spectator::reset();
to disable Spectator
I have some API calls that are not documented, and find these hard to test with Spectator. It used to work using v1.7.1 but after upgrading to Laravel 10 I get
Undefined variable $response
.Adding the suggested
return $response ?? null;
to the Middleware.php of course does not work, I want to skip the test, not get the (clearer) MissingSpecException which undoubtedly will be happening.Is there a way to switch off Spectator testing for some calls? I am explicitly not trying to validate request or response structures in my test code, it is the HTTP POST that causes issues with the latest version.