Giter VIP home page Giter VIP logo

Comments (12)

olivernybroe avatar olivernybroe commented on July 19, 2024 1

@TGNThump it could be a second method called executeAsResponse or you could just call getContent on the Response object. The point is we can't get the data before it gets manipulated which makes testing a lot harder.

from lighthouse.

TGNThump avatar TGNThump commented on July 19, 2024

Hmm. I'm not sure I like this idea, purely because it makes it hard to use the library in cases where you aren't parsing a response object, such as loading a query from another source (DB) or for subscriptions, where you aren't going to be returning a response object.

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

@olivernybroe I personally like the executeAsResponse idea. If there's no PR I'll add it this weekend but thanks for the feedback!!

from lighthouse.

olivernybroe avatar olivernybroe commented on July 19, 2024

@chrissm79 Sounds great! Looked into it, but tbh. I have no idea how to implement it.

from lighthouse.

spawnia avatar spawnia commented on July 19, 2024

Are you still interested in doing something like this? I think the tests work fine as they are, and i am not too big a fan of adding methods just for the sake of testing.

from lighthouse.

olivernybroe avatar olivernybroe commented on July 19, 2024

@spawnia I think it is really needed. Writing tests right now in Lighthouse isn't that nice as I can only check the returning data, not the actual data, which is what I am testing for in that particular test.

I think it is worth adding a method just for the sake of testing.

from lighthouse.

spawnia avatar spawnia commented on July 19, 2024

What is it that you are actually trying to test? For an integration test, we should definitely test the public interface. If it is a unit test, maybe we do not even need to execute the query fully?

from lighthouse.

olivernybroe avatar olivernybroe commented on July 19, 2024

@spawnia Sometimes I have a complex data definition in graphql. So I want to make sure that the data returned is the correct model. I am not interested in what fields I have defined in my SDL. I am interested in what is received before the data is transformed.

from lighthouse.

spawnia avatar spawnia commented on July 19, 2024

Seems like that can be achieved by calling the resolve function directly. Should this prove to be insufficient, you can add some utility functions to TestCase.php to help with such tests.

from lighthouse.

spawnia avatar spawnia commented on July 19, 2024

@olivernybroe Have you done anything on this? I would like to avoid adding complexity to the resolution itself, so if you can achieve what you need by adding a helper for testing, i would be up for including it as part of the test suite.

from lighthouse.

olivernybroe avatar olivernybroe commented on July 19, 2024

@spawnia haven't done anything for this.

from lighthouse.

spawnia avatar spawnia commented on July 19, 2024

I think this is a very specific use case for testing, and can be worked around. I think the public API should be kept small, and we can not really control the final execution result without reaching into the GraphQL core library.

Closing this for now, but am open for PR's that improve testability.

from lighthouse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.