hotmeteor / spectator

OpenAPI testing for PHP
MIT License
285 stars 53 forks source link

I can't make the test fail #170

Closed davidyell closed 9 months ago

davidyell commented 9 months ago

I am running Laravel 10 with an OpenAPI 3.0.3 version specification and no matter how hard I try and break both the spec and the code generating the response, the $response->assertValidResponse(200); always passes the test.

What am I missing? I am testing by commenting out properties from my Resource class, which is serialized to json, and the test still passes.

I have my spec at ./openapi.yaml and have added to my .env.testing file, perhaps I misconfigured the project?

# .env.testing
SPEC_SOURCE=local
SPEC_PATH=.
// MyOpenApiTest.php
Spectator::using('openapi.yaml');

Do I have to clear my application cache when making changes to my test or openapi spec?

bastien-phi commented 9 months ago

Try adding an assertValidRequest() before validating the response. It will maybe tell you what's going wrong

davidyell commented 9 months ago

Awesome, thanks for the quick reply. That assertion has highlighted that I had accidentally missed the prefix from path names. However the response assertion is still passing, even with a totally garbage response.

davidyell commented 9 months ago

Does this validator support allOf etc?

davidyell commented 9 months ago

Nevermind, I'll try a different validator. Thanks for the replies

bastien-phi commented 9 months ago

You can try future v2 requiring hotmeteor/spectator:dev-master There is still some improvements to make but we are working on it.