Giter Site home page Giter Site logo

Comments (8)

brian-mann avatar brian-mann commented on May 17, 2024

Have you loaded your app via cy.visit before hand?

That's what the error is saying. Sinon is dynamically injected into your page after you cy.visit it.

Is there any code above the describe block? If so paste it in please!

from cypress.

lorennorman avatar lorennorman commented on May 17, 2024

Interesting. No I didn't load it first because it calls the server
immediately and I want it mocked first. Trying it now...

On Saturday, April 4, 2015, Brian Mann [email protected] wrote:

Have you loaded your app via cy.visit before hand?

That's what the error is saying. Sinon is dynamically injected into your
page after you cy.visit it.


Reply to this email directly or view it on GitHub
#12 (comment).

from cypress.

lorennorman avatar lorennorman commented on May 17, 2024

Yeah it works now. I'll report a typo in the error message instead:
if you testing a page

👍

from cypress.

brian-mann avatar brian-mann commented on May 17, 2024

Yah that error message needs work.

from cypress.

brian-mann avatar brian-mann commented on May 17, 2024

I think this does bring up an interesting point.

The way visit works is that it doesn't resolve until your page fires the load event. By the time the page does that, it's possible you had scripts that immediately made AJAX requests when they first loaded.

If that's the case, those requests would go out, since they'd happen before visit resolves, and therefore before the server command was even processed.

I'll need to set up a scenario where I can cause this to happen. visit does take some options like onLoad and onBeforeLoad, but that wouldn't help starting a server because that's async anyway.

I may have to expand visit to allow for immediately starting a server prior to any scripts being parsed or loaded.

I think the situation works in your case because you're either not firing anything immediately on load, or because you're using angular, it doesn't fire off the requests until much later. Though its possible due to a timing issue sometimes it may request faster than server can be booted.

When are your requests being made?

from cypress.

lorennorman avatar lorennorman commented on May 17, 2024

We're using UI Router and there are requests in the resolve block. I
believe that means that Angular loads fully and fires the event, then it
starts the navigation cycle which leads to the request being made. I really
don't know what I'm talking about, though.

Maybe you could make .server() hold its state until the appropriate time
then slip it in in the case where visit() hasn't been called yet? Even if
not, maybe you can better detect this situation and improve the error
message, "you called .server() before you called .visit()", because when
you start mentioning sinon and iframes you break the magic barrier and I
have to understand the entire system suddenly.

Instead of accepting that I was wrong, I assumed something was broken.
Because I'm an asshole. And so is everyone else.

On Sat, Apr 4, 2015 at 4:38 PM, Brian Mann [email protected] wrote:

I think this does bring up an interesting point.

The way visit works is that it doesn't resolve until your page fires the
load event. By the time the page does that, it's possible you had scripts
that immediately made AJAX requests when they first loaded.

If that's the case, those requests would go out, since they'd happen
before visit resolves, and therefore before the server command was even
processed.

I'll need to set up a scenario where I can cause this to happen. visit
does take some options like onLoad and onBeforeLoad, but that wouldn't
help starting a server because that's async anyway.

I may have to expand visit to allow for immediately starting a server
prior to any scripts being parsed or loaded.

I think the situation works in your case because you're either not firing
anything immediately on load, or because you're using angular, it doesn't
fire off the requests until much later. Though its possible due to a timing
issue sometimes it may request faster than server can be booted.

When are your requests being made?


Reply to this email directly or view it on GitHub
#12 (comment).

from cypress.

brian-mann avatar brian-mann commented on May 17, 2024

Such wise words.

Yah I'll make some adjustments for sure.

Starting the server before visit should be possible. I can create some hooks when the page initially loads to enable the server prior to anything else loading.

from cypress.

brian-mann avatar brian-mann commented on May 17, 2024

This is fixed in 0.4.3. Changelog

from cypress.

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.