Skip to content
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

Add window.prompt stubbing example to api section #294

Merged
merged 2 commits into from
Dec 2, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions source/api/commands/stub.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ App.stop()
expect(removeStub).to.be.called
```

***Replace built-in window methods like prompt***
```javascript
// assume App.start uses prompt to set the value of an element with class "name"
cy.visit('http://localhost:3000', {
onBeforeLoad(win) {
cy.stub(win, 'prompt').returns('my custom message');
}
});

App.start();

cy.window().its('prompt').should('be.called');
cy.get('.name').should('have.value', 'my custom message');
```

***Using cy.stub***

{% note info %}
Expand Down