-
Notifications
You must be signed in to change notification settings - Fork 0
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
test: increase test coverage #32
Conversation
kkkaoru
commented
Apr 13, 2024
•
edited
Loading
edited
- increase test coverages
- add a test ci
- add a branch protection
statements: 98.74, | ||
branches: 81.25, | ||
functions: 100, | ||
lines: 98.74, |
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.
vitest の仕様を正確に把握していないんですが、現在のカバレッジに合わせて設定ファイルも自動で更新されるっぽいです
autoUpdate: true, | ||
}, | ||
exclude: ['**/*/index.ts', '**/*/*.types.ts', '**/*/*.d.ts', '**/*/*.js','*.cjs', 'apps', 'src/bin', '**/const/*.*'], |
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.
カバレッジをいい感じにする為のexclude
export const argsOptions = { | ||
output: { | ||
type: 'string', | ||
multiple: false, | ||
short: 'o', | ||
default: './licenses.json', | ||
}, | ||
pretty: { | ||
type: 'boolean', | ||
multiple: false, | ||
short: 'p', | ||
default: false, | ||
}, | ||
recursive: { | ||
type: 'boolean', | ||
multiple: false, | ||
short: 'r', | ||
default: false, | ||
}, | ||
dev: { | ||
type: 'boolean', | ||
multiple: false, | ||
short: 'd', | ||
default: false, | ||
}, | ||
'no-prod': { | ||
type: 'boolean', | ||
multiple: false, | ||
default: false, | ||
}, | ||
'no-optional': { | ||
type: 'boolean', | ||
multiple: false, | ||
default: false, | ||
}, | ||
} satisfies ParseArgsConfig['options']; |
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.
writeLicenses()
のテストを書く時にこのファイルの処理が実行されてしまうようだったので、 argsOptions の定義を別ファイルに分けています 🙏
const dirents = await readdir(pnpmPackage.path, { withFileTypes: true }); | ||
const licenseDirent = dirents.find((dirent) => dirent.name.toLowerCase().includes('license')); | ||
const licenseDirent = await findLicenseDirent(pnpmPackage.path); | ||
if (licenseDirent === undefined) { | ||
return undefined; | ||
} | ||
const licenseTxt = await readLicense({ | ||
name: pnpmPackage.name, | ||
licensePath: `${pnpmPackage.path}/${licenseDirent.name}`, | ||
}); | ||
// remove path property | ||
const { path, ...PnpmPackageInfo } = pnpmPackage; | ||
return licenseTxt === undefined ? PnpmPackageInfo : { ...PnpmPackageInfo, licenseTxt }; |
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.
カバレッジあげるために、処理のファイル分けをするように変更しました
@NEKOYASAN |
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.
LGTM!