Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dl0312/cypress-tutorial
πΆ It's time to study cypress
https://github.com/dl0312/cypress-tutorial
Last synced: 11 days ago
JSON representation
πΆ It's time to study cypress
- Host: GitHub
- URL: https://github.com/dl0312/cypress-tutorial
- Owner: dl0312
- Created: 2019-08-12T07:17:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T01:47:45.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T21:12:47.918Z (about 1 month ago)
- Language: CSS
- Homepage:
- Size: 3.3 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cypress Tutorial
[cypress](https://github.com/cypress-io/cypress) - Fast, easy and reliable testing for anything that runs in a browser.
* OpenSource Project(MIT License)
* Browser Support: `Electron`, `Chrome`
* Element μ κ·Ό: `Iframe`μ `Target Web`μ μ¬λ¦° λ€ `Browser` λ΄λΆμμ μ κ·Όν¨.
* Headless Support: μ§μ
* CLI Support: μ§μ
* ScreenShot: μ§μ
* Video Record: `Electron`λ§ μ§μ
* μ¬νν API μ 곡
* `Mocha` κΈ°λ°μ΄κΈ° λλ¬Έμ `Nodejs` κ°λ°μλ€μκ² μ΅μν©λλ€.
* λ΄λΆμ μΌλ‘ `queue`λ₯Ό μ¨μ `sync`μΈκ² μ²λΌ λμν©λλ€.
## Cypressλ 무μμΈκ°?
`cypress`λ e2eEnd to End testing frameworkμ΄λ€. κ°λ°μ μ μ₯μμ νλ‘κ·Έλ¨μ λͺ¨λμ κ²μ¦νλ μ λ ν μ€νΈμ λ¬λ¦¬ e2e testλ μ¬μ©μ μ μ₯μμ ν μ€νΈνλ κ²μ λ»νλ€. e2e ν μ€νΈμ λν μμΈν μ€λͺ μ "[E2E Test μμ보기](https://medium.com/hbsmith/e2e-test-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-3c524862469d)"λ₯Ό μ°Έκ³ νλ€.`cypress`λ κ° ν μ€νΈμ κ³Όμ μ μΉνμ΄μ§λ₯Ό ν΅ν΄ 보μ¬μ£Όλ λ§€μ° μκ°μ λꡬμ΄λ€. λν, κ° ν μ€νΈ μνμ μ€λ μ·μ²λΌ μ°μ΄ ν΄λΉ ν μ€νΈνκ²½μΌλ‘λ λμκ° μ μλ€.
## μ λ λ€λ₯Έ ν μ€νΈ λκ΅¬κ° νμνκ°?
κΈ°μ‘΄μ ν μ€νΈλ λ무 μ΄λ ΅λ€.κΈ°μ‘΄ κ°λ°μλ€μ΄ ν μ€νΈ λꡬμ κ°μ§λ λΆλ§μ΄ 무μμΈκ°?
* κΈ°λ³Έ μ€μ μ΄ μ΄λ ΅λ€ - μ§μ μ₯λ²½μ΄ λλ€.
* μμ± - ν μ€νΈ μ½λλ₯Ό μμ±νλ κ²μ΄ μ΄λ ΅λ€.
* κ΄λ¦¬ - ν΄λΉ ν μ€νΈ μ½λμ κ²°κ³Όκ° μ΄ν΄νκΈ° μ΄λ ΅κ³ λ€λ£¨κΈ° μ΄λ ΅λ€.λλΆλΆμ Seleniumμ μ¬μ©ν e2e ν μ€νΈ λꡬλ€μ λ¬Έμ λ λ€μκ³Ό κ°μλ€.
* μΉμ λ°μ Evolution - AJAXμ λ±μ₯μΌλ‘ μΉμ κ΅¬μ‘°κ° μ μ λ 볡μ‘ν΄μ‘λ€.
* λΉλκΈ° μ½λAsync Code
* ꡬ쑰Architecture
* μ μ΄Control - κ°λ°μκ° μμ ν ν΅μ κΆμ κ°μ§μ§ λͺ»νλ€.
* μλSpeed - λ무λ무 λλ Έλ€.# Cypress with Vue.js
μ°μ `vue-cli`@3.x λ²μ μ μ¬μ©νμ¬ νλ‘μ νΈλ₯Ό ꡬμ±νκ³ , μΆκ° μ€μ μ λ€μκ³Ό κ°μ΄ ν΄μ€λ€.
```shell
$ vue create cypress-tutorial
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Linter, E2E
? Pick a linter / formatter config: Basic
? Pick additional lint features: (Press to select, to toggle all, to invert selection)Lint on save
? Pick a E2E testing solution: Cypress
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? No
```μ€μΉκ° λ§λ¬΄λ¦¬λλ©΄, `tests/e2e`λΌλ e2e ν μ€νΈ μ½λκ° λ€μ΄μλ ν΄λκ° μκΈ΄λ€.
κ·Έλ¦¬κ³ , `tests/e2e/specs` ν΄λμ μλ `test.js`κ° μ°λ¦¬κ° μ¬μ©ν e2e ν μ€νΈ μ½λμ΄λ€.
```js
// test.js
// https://docs.cypress.io/api/introduction/api.html
describe('My First Test', () => {
it('Visits the app root url', () => {
cy.visit('/')
cy.contains('h1', 'Welcome to Your Vue.js App')
})
})
```
μ΄ μ½λλ₯Ό νλ©΄ μ€κ°μ λμ€λ λ§ν¬μ κ°―μλ₯Ό νμΈνλ μ½λλ‘ λ°κΏλ³΄μ μ°μ `HelloWorld.vue` νμΌμ μμ ν΄μΌνλ€.
Essential Links μλ μλ ul tagμ `data-cy="links"`λΌλ μμ±μ μ£Όμ νλ€. μ΄ μμ±μ `cypress`μμλ§ μ°μ΄λ μμ±μ΄ λ κ² μ΄λ€.
```htmlEssential Links
```
κ·Έλ¦¬κ³ ν΄λΉ λ§ν¬μ κ°―μλ₯Ό νμΈνλ ν μ€νΈ μ½λλ₯Ό μμ±νλ€.
```js
// test.js
// https://docs.cypress.io/api/introduction/api.html
describe('Test main page', () => {
beforeEach(() => {
cy.visit('http://localhost:8080')
})
it('check links', () => {
cy.get('[data-cy=links]')
.children()
.should('have.length', 5)
})
})
```
μ΄μ ν μ€νΈ μ½λκ° μ λμνλ μ§ νμΈνλ μΌλ§ λ¨μλ€. λͺ λ Ήμ΄λ `vue-cli`λ‘ μλμΌλ‘ μμ±λ `yarn test:e2e`λ₯Ό μ΄μ©νλ€.
```shell
$ yarn test:e2e
```
λͺ λ Ήμ΄λ₯Ό μ λ ₯νκ³ μκ°μ΄ μ’ μ§λλ©΄ λΈλΌμ°μ ννμ `cypress` νλ‘κ·Έλ¨μ΄ μ€νλλ©΄μ ν μ€νΈκ° μ§νλ κ²μ΄λ€.
## References
* πΉ[Testing The Way It Should Be (aka Intro Into Cypress)](https://youtu.be/pJ349YntoIs)
* πΉ[Cypress Official Tutorial Videos](https://docs.cypress.io/examples/examples/tutorials.html#Best-Practices)