Coder Social home page Coder Social logo

Comments (3)

cah4a avatar cah4a commented on August 11, 2024

Hey, @jseminck

No, currently nock doesn't support performing real HTTP requests. Any request that didn't mock will fail the test using NetConnectionNotAllowed error.

I don't know whether it is a good idea, cuz in this case the tests will test much more than the code: internet connection, DNS, SSL, remote servers, response content, etc...

Reproducibility is a central tenet of testing. So I'm trying to avoid testing a real API that belongs to me and, of course, don't want to test some API that doesn't.

from dart_nock.

jseminck avatar jseminck commented on August 11, 2024

I agree with you, and I managed to find another workaround to my problem.

Just for context, we are using https://pub.dev/packages/cached_network_image to get flags from https://flagcdn.com/ and this package throws exceptions in case an invalid URL is given to it. I didn't want to mock out all the flags as that seems kind of silly. My other best solution was to create a wrapper widget around CachedNetworkImage that returns a SizedBox() when running the test.

Thanks for the reply!

from dart_nock.

cah4a avatar cah4a commented on August 11, 2024

Yeah, I bet this is the best solution.

Thanks for sharing your experience. It could be useful for others who face similar issues.

from dart_nock.

Related Issues (15)

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.