Skip to content
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

Merged
merged 2 commits into from
Apr 14, 2024
Merged

test: increase test coverage #32

merged 2 commits into from
Apr 14, 2024

Conversation

kkkaoru
Copy link
Contributor

@kkkaoru kkkaoru commented Apr 13, 2024

  • increase test coverages
  • add a test ci
  • add a branch protection

image

@kkkaoru kkkaoru self-assigned this Apr 13, 2024
@kkkaoru kkkaoru marked this pull request as ready for review April 13, 2024 21:29
@kkkaoru kkkaoru requested a review from NEKOYASAN April 13, 2024 21:29
Comment on lines +10 to +13
statements: 98.74,
branches: 81.25,
functions: 100,
lines: 98.74,
Copy link
Contributor Author

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/*.*'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

カバレッジをいい感じにする為のexclude

Comment on lines -7 to -42
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'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeLicenses() のテストを書く時にこのファイルの処理が実行されてしまうようだったので、 argsOptions の定義を別ファイルに分けています 🙏

Comment on lines -8 to -19
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 };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

カバレッジあげるために、処理のファイル分けをするように変更しました

@kkkaoru
Copy link
Contributor Author

kkkaoru commented Apr 13, 2024

@NEKOYASAN
カバレッジ上げたのとCI追加してbranch protection でtest も必須にしたので、これでより壊れにくくなってるかなと思います!
merge は ねこやさんの方で merge していただけると 🙏

Copy link
Member

@NEKOYASAN NEKOYASAN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@NEKOYASAN NEKOYASAN merged commit 5bfd908 into main Apr 14, 2024
2 checks passed
@NEKOYASAN NEKOYASAN deleted the increase-test-coverage branch April 14, 2024 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants