๐๏ธ๐จ๏ธ ํ ์คํธ๋ฅผ ๋์ ํ๊ฒ ๋ ๋ฐฐ๊ฒฝ
ํ์ฌ ํ์ฌ์์ ๊ฐ๋ฐํ๊ณ ์๋ ํ์ํ์ฌ erp ์์คํ ์ด ๊ท๋ชจ๊ฐ ๊ฝค ์ปค์ก๋ค.
ERP ์์คํ ์ธ ๋งํผ ๊ธ์ฌ์์คํ ์ ๋ค๋ฃจ๊ณ ๋ง์ ํ์ํ์ฌ๋ค์ ๋ค๋ฃจ๊ฒ ๋๋ค๋ณด๋ ๊ด๋ฆฌํฌ์ธํธ๋ ์ปค์ง๊ฒ ๋์๋ค.
๋ถ๋ฆฌ๋์ด ์๋ ํ์ด์ง์์ ๋ค๋ฅธ ํ์ด์ง์ ์๋ก ์ํฅ์ด ๊ฐ๋ ๊ธฐ๋ฅ๋ ๋ง๊ธฐ ๋๋ฌธ์ ๊ฑฐ๊ธฐ์ ์ฌ์ฉ์๊ฐ ๋ณต์กํจ์ ๋๋ผ์ง ์๋์ง, flow ์ ๋ฐฉํด๊ฐ ๋๊ฑฐ๋ ํผ๋์ ์ฃผ์ง ์๋์ง, ๋ฑ๋ฑ์ ๊ณ ๋ คํด์ ํ ์คํธํด์ผํ๋ค.
๋ณต์กํ ๋น์ฆ๋์ค ๋ก์ง์ ์ด๋ป๊ฒ ํ๋ฉด ๋น ๋ฅด๊ณ ์์ ์ฑ์ ๋ณด์ฅํ ์ ์์๊น ๋ผ๋ ๊ณ ๋ฏผ๋ ์ปค์ง๊ฒ ๋์๊ณ ์ด์ํฝ์ค์ ๋๋์ฑ์ด๋ ํ ์คํธ ํ๊ฒฝ์ด ํ์ํ๊ฒ ๋์๋ค.
+ ํ์๋ค์ PR๋ฆฌ๋ทฐํ๋๋ฐ ์๊ฐ๋ ๋ง์ด ๊ฑธ๋ฆฐ๋ค...
์ฆ, ํ ์คํธํ๋๋ฐ ์๊ฐ์ ๋จ์ถ์์ผ๋ณด์!
โฟ ์ E2E?
snapshot test, unit test, integration test, e2e test.. ํ๋ก ํธ์๋ ํ ์คํธ์๋ ์ข ๋ฅ๊ฐ ๋ง๋ค.
์ฌ์ฉ์ ๊ด์ ์์ ๋์ ์๋ฎฌ๋ ์ด์ ๊ณผ ์ ์ฒด์ ์ธ ํ๋ฆ์ ํ ์คํธ์ ํ์์ฑ์ ๋๊ผ๋ค.
์ฌ๋ฌ ํ ์คํธ๋ฅผ ๊ณ ๋ คํ๋ ์ค ๊ฒ์ํ๋ค๊ฐ cypress ๋ฅผ ์๊ฒ ๋์๋ค.
cypress๋ ์ค์๊ฐ์ผ๋ก ํ ์คํธ๋ฅผ ํ์ธํ ์ ์๋ ์๊ฐ์ ๋๋ฒ๊น ๊ธฐ๋ฅ์ ํ ์คํธ ์ฝ๋ ์์ฑ ๋ฐ ์ ์ง๋ณด์๋ฅผ ๋์ฑ ํธ๋ฆฌํ๊ฒ ๋ง๋ค์ด ์ฃผ๋ ํ ์คํธ์ฌ์ ์ค๋ฌด์ ๋์ ํ๊ฒ ๋์๋ค.
๐ ํ ์คํธ ํ๊ฒฝ ์ค์
โณ๏ธ E2E
๐ ํ๋ก์ ํธ setup
1๏ธโฃ ์ค์น
npm install cypress --save-dev
2๏ธโฃ script
"e2e": "cypress run --browser chrome", // terminal ์์ ์คํํ๋ ๊ฒฝ์ฐ
"e2e": "cypress open --browser chrome", // web ์ผ๋ก ์คํํ๋ ๊ฒฝ์ฐ
ํด๋น script๋ฅผ ์คํ ์ํฌ ๊ฒฝ์ฐ ๋ก์ปฌ ์๋ฒ์ ์คํ ์ค์ด์ด์ผ ํ๋ค.
3๏ธโฃ cypress๋ฅผ ์ค์นํ๊ฒ ๋๋ฉด ๋ก์ปฌ ํ๋ก์ ํธ์ configํ์ผ์ด ์๊ธฐ๋๋ฐ baseUrl ์ค์ ํด ์ค๋ค.
import { defineConfig } from 'cypress'
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:8081',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
})
4๏ธโฃ ๋ก์ปฌ ํ๋ก์ ํธ์ cypress๋ผ๋ directory๊ฐ ์์ฑ๋๊ณ 4๊ฐ์ง ํด๋๊ฐ ์์ ์๊ฒ ๋๋๋ฐ e2eํ ์คํธ์ ์๋๋ฆฌ์ค๋ฅผ ์์ฑํ๋๋ก ํ๋ค.
โณ๏ธ Units
Tool Options
โ๏ธ Vitest
- vite ๋ฅผ ์ฌ์ฉํ๊ณ ์๊ณ vite ์์ ๋์จ ์ต์ ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก์จ ์ง๊ธ ํ๋ก์ ํธ๋ ์ข ๋ ์ ๋ง์ง ์์ ๊น?
- ์คํจ -> ํ์ฌ ํ๋ก์ ํธ์ ๋ ธ๋ ๋ฒ์ ์ด 14.xx.. ์ธ ์ด์ ๋ก ์๋์ ๊ฐ์ ๋ฌธ์ ๋ฐ์
Vitest ์ญ์ node version 18.0 ์ด์์ ์๊ตฌํจ
node version ์ ์ฌ๋ฆด ์ ์์ผ๋ฉด ์ข์ง๋ง (ํ์ฌ์์ ์ฌ์ฉํ๋ ํ๋ก์ ํธ๋ lerna๋ก ๋ชจ๋ ธ๋ ํฌ ์ฌ์ฉ์ค)ํ์ฌ ํ๋ก์ ํธ์ ๋ค๋ฅธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์์กด์ฑ ๋ฌธ์ ๋ก ์ฝ๊ฒ ์ฌ๋ฆด ์ ์๋ค ..
โ๏ธ Jest
์ค๋์ ๋ถํฐ ํํํ๊ฒ ์์์จ ์ด๋ ฅ์ด ์์ด์ ๊ทธ๋ฐ์ง ์ด์ ๋ฒ์ ์๋ ์ ์ฐํ ํธํ์ฑ์ ๊ฐ์ง๊ณ ์๋ค.
Vitest vs Jest
chat gpt ์ ๋ฌผ์ด๋ดค๋ค
์ ๋ง์ ๋ง์ถฐ ์ฌ์ฉํ๋ฉด ๋ ๋ฏ ํ๋ค...
๐ ํ๊ฒฝ์ค์
1๏ธโฃ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น
$ npm install --save-dev jest ts-jest @types/jest
2๏ธโฃ ์ด๋ ๊ฒ ์ถ๊ฐ ํ์ ๊ฒฝ์ฐ์๋ ๋ชป ๋ถ๋ฌ ์ค๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.
$ npx ts-jest config:init
3๏ธโฃ ์ด๋ ๊ฒ ํด์ jest config ํ์ผ์ ์ถ๊ฐํ๋๋ก ํ๋ค. ์ดํ ๋ฐ๋ก config ํ์ผ์ ๋ฌด์ธ๊ฐ๋ฅผ ํด์ฃผ์ง ์์๋ค.
// jest.config.js file
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
4๏ธโฃ package.json -> script ์ ๋ค์๊ณผ ๊ฐ์ด ์ถ๊ฐํ๋ค.
"scripts": {
... ,
"test": "jest"
},
๐ํ ์คํธ ํ์ผ์ ๊ตฌ์กฐ
โฒ E2E
project-name/
โโโ cypress/
โ โโโ download/
โ โโโ e2e/
โ โโโ fixtures/
โ โโโ screenshots/
โ โโโ support/
โโโ ...
โฒ Units
project-name/
โโโ src/
โ โโโ tests/
โโโ ...
๐ E2E ํ ์คํธ CI ์ ์ฉ
pipelines:
branches:
develop:
- step:
name: e2e test
image: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1
caches:
- node
- cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1
script:
- npm install
- npx lerna bootstrap --hoist
- npx lerna run dev --scope=rev-erp &
- npx lerna run e2e --scope=rev-erp
์ด๋์ ๋ e2e ํ ์คํธ ํ ๊ธฐ๋ณธ์ ๋ง๋ค์ด ๋จ๊ณ ํ ์คํธ๋ฅผ ์ ์ฉํด ๋ณผ ์์ ~
์ฐธ๊ณ
'front-TEST' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Github Action Cache ๋ฅผ ์ฌ์ฉํ์ฌ CI/CD ์ต์ ํ (0) | 2025.01.13 |
---|---|
[vue.js] Storybook + Quasar + Vue3 (์คํ ๋ฆฌ๋ถ์ Quasar์ ์ฉ) (0) | 2024.05.08 |
[vue.js] storybook ๋์ (vue3 + vite) (1) | 2024.05.03 |
Mixpanel + vue ์ฐ๋ (0) | 2024.02.27 |
ํ๋ก ํธ์๋ ๊ฐ๋ฐ์์ ํ ์คํธ๋? (0) | 2023.09.02 |