-
Notifications
You must be signed in to change notification settings - Fork 103
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
docs: es-hangul의 신뢰성을 나타낼 수 있는 문서를 만듭니다 #302
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
{coverageItems.map(item => ( | ||
<td key={item} className="px-6 py-4"> | ||
✅ (100%) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
특정 상황에서는
함수의 테스트 커버리지가 100%가 되지 않는 타이밍도 있을 것 같은데요.
그러면 거짓된 정보를 제공하는것이라 좋지 않은 것 같아요.
항상 100%로 하드코딩하기보다는, 테스트 커버리지를 동적으로 받아올 수 있는 방법이 없을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build 전 테스트 커버리지 파일 업데이트를 통해 '최신 커버리지 파일'을 이용하는 방식으로 변경했습니다. 파일의 무게는 13kb로 기존 빌드배포 시간에 큰 영향을 미치지 않는다고 판단하였습니다. 해당 이슈를 진행하면서 한가지 아쉬웠던 점은 es-hangul의 공식문서에서 공개하고 있는 API 리스트들을 커버리지 파일을 이용하여 가져올 수 없는지 확인을 해봤는데 실패했습니다.
그러하여, deduplicationAPIList
라는 상수를 통해 es-hangul 내에서 테스트되고 있는 파일들 중 사용자들에게 보여주고 있는 API 테스트 파일들만 필터링 했습니다. 이렇게 하지 않으면 _internal
, standardizePronunciation
의 transform과 관련된 테스트 값들이 불필요하게 사용자들에게 보여집니다.
그리고 docs를 build 하기 전, 배포 명령어에 "yarn test"를 넣어주실 수 있나요? 해당 명령어를 통해 coverage 파일을 최신화하고자 합니다.
coverage/coverage-summary.json
Outdated
@@ -0,0 +1,44 @@ | |||
{"total": {"lines":{"total":540,"covered":540,"skipped":0,"pct":100},"statements":{"total":545,"covered":545,"skipped":0,"pct":100},"functions":{"total":101,"covered":101,"skipped":0,"pct":100},"branches":{"total":339,"covered":339,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn test실행시 업데이트 되는 파일이라면,
gitignore에 기존대로 넣어도 괜찮지 않나요?
개인 파일 경로가 들어가있어서 main에 머지되어도 괜찮을까 걱정이 되어서요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gitignore에 다시 coverage 경로를 넣어도 될 것 같습니다. 다만, 제가 알고있는 사항으로는 docs 배포시에 따로 yarn test
명령어를 통해 coverage를 생성하지 않는 것으로 알고 있습니다. 혹시 yarn test 명령어를 배포 명령시 추가해주실 수 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const filteredCoverage = (coverageFileEntries: typeof fileEntries, openAPIList: typeof deduplicationAPIList) => { | ||
return Object.entries(coverageFileEntries) | ||
.filter(([filePath]) => { | ||
const fileNameWithoutExt = filteredFilePath(filePath); | ||
|
||
if (!fileNameWithoutExt) { | ||
return false; | ||
} | ||
|
||
return filteredFileName(fileNameWithoutExt, openAPIList); | ||
}) | ||
.map(([filePath, coverage]) => { | ||
const fileNameWithoutExt = filteredFilePath(filePath); | ||
|
||
return [fileNameWithoutExt, coverage] as const; | ||
}); | ||
}; | ||
|
||
const filteredFilePath = (filePath: string) => { | ||
const segments = filePath.split('/'); | ||
const lastSegment = segments[segments.length - 1]; | ||
|
||
if (!lastSegment.endsWith('.ts')) { | ||
return ''; | ||
} | ||
|
||
return lastSegment.replace(/\.ts$/, ''); | ||
}; | ||
|
||
const filteredFileName = (fileNameWithoutExt: string, openAPIList: typeof deduplicationAPIList) => { | ||
return openAPIList.some(api => { | ||
if (fileNameWithoutExt === api) { | ||
return true; | ||
} | ||
|
||
if (fileNameWithoutExt.startsWith(api) && fileNameWithoutExt.length > api.length) { | ||
const nextChar = fileNameWithoutExt.charAt(api.length); | ||
|
||
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase(); | ||
} | ||
|
||
return false; | ||
}); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분 풀고자 하는 문제보다 약간 복잡하게 코드가 작성되어 있는 느낌을 받았는데요,
- 생각보다 많은 분기가 있고
- 함수명이 상수명처럼 과거형으로 되어있고 ( 필터하는 함수라면 filtered가 아닌 filter가 더 적절해보여요.)
- name과 path의 구분을 잘 이해하지 못했어요.
- deduplicationAPIList를 상수로 관리하는 이유를 코맨트로 적어주셨지만 이해하지 못하였어요. coverage-summary.json에 함수명들이 다 존재하지 않나요?
const result = {};
// for 구문은 명령형 구조이므로 수정은 필요함
for (const [key, value] of Object.entries(fileEntries)) {
const name = key.split('/').pop()?.split('.')[0];
if (name == null) {
return;
}
result[name] = {
lines: value.lines.pct,
functions: value.functions.pct,
statements: value.statements.pct,
branches: value.branches.pct,
};
}
위와 같이 간단히 생각해보았는데요, 위처럼 간단하게만 해도 함수별로 각 커버리지를 알 수 있는데, 기존 코드로 풀고자 하는 문제가 어떤것이셨나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 코드에서는 constants.ts, transform*.ts, _internal 경로등의 모든 테스트 파일이 fileEntries에 담겨져 있어서 사용자들에게 보여주는 API로만 목록을 구성하고 싶었기에 '필터'를 위한 상수와 함수를 고안했습니다.
@okinawaa 님과 대화를 해보면서 현재 추가한 코드보다 더 간단하게 풀어낼 수 있는 것 같아서 수정해보았습니다.
코드를 매끄럽게 풀어나갑니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다~
Overview
resolve #297
PC version.

Mobile Version.
default.mp4
es-hangul의 API들이 높은 신뢰성을 제공함을 사용자에게 보여줄 수 있는 문서를 제작했습니다.
[제공]
PR Checklist