-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server XHR is not detected / stubbed when using document.write #1139
Comments
The test stubs the route, mounts the component, then expects to find the synthetic data cy.server()
cy.route('/todos?_limit=3', mockTodos)
})
context('Stubbed server', () => {
beforeEach(() => {
const state = {
todos: []
}
const actions = {
setTodos: todos => state => ({ todos }),
toggle
}
const view = (state, actions) =>
h(ServerTodos, {
n: 3,
todosLoaded: actions.setTodos,
todos: state.todos,
toggle: actions.toggle
})
mount(state, actions, view)
})
// skip until can figure out why the server is not stubbed
// when writing into document directly.
it.skip('shows todos', () => {
cy.contains('Todo')
cy.get('.todo').should('have.length', 3)
cy.get('.todo').first().contains('Stub server')
}) |
We don't bind to the remote app before the first |
Yeah I even tried to visit a dummy page just for this before writing to the document- did not help either
…Sent from my iPhone
On Dec 31, 2017, at 09:26, Brian Mann ***@***.***> wrote:
We don't bind to the remote app before the first cy.visit so we just need to add the bindings immediately when the remote window is first created.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I see now. You are initiating the XHR from the spec frame - not the app frame. The test frame is not bound to - although we could do that as well. |
If we can do this behavior from test frame then the argument for unit testing components becomes irresistible- especially because react unit testing works beautifully :)
…Sent from my iPhone
On Dec 31, 2017, at 10:06, Brian Mann ***@***.***> wrote:
I see now. You are initiating the XHR from the test frame - not the app frame. The test frame is not bound to - although we could do that as well.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
This appears to be fixed. Ran https://github.com/bahmutov/cypress-hyperapp-unit-test/blob/master/cypress/integration/server-todos-spec.js#L8 in Cypress 3.4.0. |
Cypress 1.4.x
If we do NOT use
cy.visit
to open a page, and just dodocument.write
, then the XHR requests are not detected and are not stubbed.Example: https://github.com/bahmutov/cypress-hyperapp-unit-test/blob/master/cypress/integration/server-todos-spec.js#L8 where I stub the server XHR route before mounting a Hyperapp component. Same stubbing works if we do not mount Hyperapp but just load an HTML page. In this example, the command log does not even show XHR
The text was updated successfully, but these errors were encountered: