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

chore: migrate tests from karma to jest #8

Merged
merged 4 commits into from
Jun 18, 2021
Merged

Conversation

jajugoguma
Copy link
Contributor

Please check if the PR fulfills these requirements

  • It's submitted to right branch according to our branching model
  • It's right issue type on title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has description for the breaking change

Description

  • remove karma-jasmine test environment
  • set jest test environment
  • tests migrate from jasmine to jest

Thank you for your contribution to TOAST UI product. 🎉 😘 ✨

Copy link

@adhrinae adhrinae left a comment

Choose a reason for hiding this comment

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

리뷰완료합니다 👏

});

it('should change text in the placeholder by the Item.', () => {
const item = new Item({ value: 1, label: 'first', index: 0 });
input.changeText(item);
expect(input.placeholderEl).toContainText('first');

expect(input.placeholderEl.textContent).toContain('first');

Choose a reason for hiding this comment

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

jest-dom 을 사용한다면 toHaveTextContent 단언이 있습니다.
https://github.com/testing-library/jest-dom#tohavetextcontent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

기존에 toContainText 단언을 사용하고 있어서 부분 문자열에 대한 검증을 하기 위해 toContain 단언을 사용했습니다.
확인 결과, 해당 테스트는 문자열 전체에 대해 검사를 하는 것이 맞다고 판단되어 toHaveTextContent 단언을 사용하는 것으로 변경했습니다.


expect.extend({
toBeSelected(actual) {
const result = actual.selected === true;

Choose a reason for hiding this comment

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

이 단언이 사용되는 테스트 케이스가 item, selectBox 두 개인데
item쪽의 테스트 케이스는 단언 자체가 private 구현에 의존하고 있어서 좀 걱정되네요.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

해당 커스텀 단언을 삭제하고 위 단언이 검증하던 속성인 'selected'의 값을 toBe 단언을 이용해 검증하는 것으로 변경했습니다.

Copy link

@lja1018 lja1018 left a comment

Choose a reason for hiding this comment

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

리뷰완료합니다.

@jajugoguma jajugoguma merged commit 715445a into master Jun 18, 2021
@jajugoguma jajugoguma deleted the chore/karma-to-jest branch June 18, 2021 18:55
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.

3 participants