Skip to content

Commit

Permalink
GITBOOK-13: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
fport authored and gitbook-bot committed Feb 21, 2023
1 parent 2fd1aed commit 99c14d4
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions 12.-cypress-eszamansiz-davranis-asynchronous-behavior.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,62 @@
---
description: >-
Cypress, JavaScript tabanlı node.js'den türetilmiştir. Cypress komutları, node
sunucusuna bağımlı oldukları için doğası gereği senkrondur. Asenkron akış test
adımının yürütme için önceki adıma bağlı o
---

# 12. Cypress Eşzamansız Davranış(Asynchronous Behavior)

Aşağıda Cypress'teki asenkron davranışa bir örnek verelim.

```javascript
describe("async ous behavior", () => {
it("senerio 1", () => {
// test step to launch a URL
cy.visit("https://accounts.google.com")

// identify element
cy.get('h1#headingText').find('span').should('have.text', 'Signin')

cy.get('h1#headingText').find('span')
.then(() => {
const t = e.text()

//get in console
console.log(t)
})

console.log("cypress notlari")
})
})
```

<figure><img src=".gitbook/assets/Screenshot 2023-02-21 at 09.10.43.png" alt=""><figcaption></figcaption></figure>

## Promise

Cypress komutları, her adımın sırayla yürütüleceği ve aynı anda tetiklenmeyeceği şekilde tasarlanmıştır. Ancak, birbiri ardına sıralanırlar. Böylece akışı senkronize hale getirir. Bu Promise ile sağlanır.



#### Modes in Promise

Bir Promise, bir komutun yürütülme durumunu kategorize etmek için üç moda sahiptir.

* **Resolved:** Test adımı başarıyla çalışırsa bu sonuç oluşur.
* **Pending:** Test adımı çalıştırma sonucu bekleniyorsa sonuç budur
* **Rejected:** Test adımı başarısız bir şekilde çalışırsa sonuç bu olur.

#### Example for Promise in Cypress:

```javascript
describe("async ous behavior", () => {
it("Promise", () => {
// test step to launch a URL
cy.visit("https://accounts.google.com")
.then(() => {
return cy.get('h1#heading')
})
})
})
```

0 comments on commit 99c14d4

Please sign in to comment.