Skip to content

テストコードの修正・安定化#180

Open
knaito-asial wants to merge 12 commits intomasterfrom
fix_test_code
Open

テストコードの修正・安定化#180
knaito-asial wants to merge 12 commits intomasterfrom
fix_test_code

Conversation

@knaito-asial
Copy link
Contributor

https://monaca.atlassian.net/browse/MN-6079?atlOrigin=eyJpIjoiMDMyN2YxMDI0ZGE2NDM1MmI4NjgyYjNjZTdkZTNjNzEiLCJwIjoiaiJ9

概要

テストコードの修正と安定化を行いました。主に以下の問題に対処しています。

  • 非推奨のJasmine API(waitsFor/runs)を置き換え、Promiseハンドリングを修正
  • 各specファイルのセットアップ処理をbeforeAllに移動し、テストのランダム実行順序による失敗を解消
  • テストのエラーハンドリングやexpect文字列の修正

変更対象

  • spec/ 配下のテストファイル全般(11ファイル)
  • src/monaca.js(軽微な修正)

変更内容の詳細

  1. monaca.spec.js:
    非推奨のwaitsFor/runsを削除し、async/awaitベースのPromiseハンドリングに修正。clientTypeの設定とcatch句を追加
  2. localkit.localAuth.spec.js / localProperties.spec.js: テストコードの修正
  3. templates.spec.js / config.spec.js: expect文字列やテスト内容の修正
  4. cloneProject / uploadProject / downloadProject / buildProject / localkit の各spec:
    セットアップ処理をbeforeAllに移動し、テストの実行順序に依存しない構成に変更
  5. spec/common.js: 共通セットアップの調整

テスト計画

  • npm test で全テストがパスすることを確認
  • テストのランダム実行順序(--random)でも安定して通ることを確認

knaito-asial and others added 12 commits March 13, 2026 22:10
Use toThrowError instead of toThrow for Jasmine compatibility,
check err.message instead of err for rejected promises,
and add missing catch clause to prevent unhandled rejection warning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e handling

- Replace Jasmine 1.x waitsFor/runs with modern done callback pattern in common.js login() and monaca.spec.js beforeEach blocks
- Fix logout test to use getData() synchronously (returns value, not promise)
- Add .catch with done.fail() to prevent unhandled promise rejections
- Add 30s timeout to downloadFile failure tests (retry logic exceeds default 5s)
- Fix logout() to return setData() promise so callers await cleanup
- Set clientType to 'cli' in Monaca constructor

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When getProjects fails or times out, dependent cloneProject tests now
skip gracefully instead of failing with a null projectId. Also adds a
test case for cloneProject behavior when projectId is unavailable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rder

Separate 'Test setup' describe block caused failures when Jasmine
ran tests in random order. Move login/getProjects into beforeAll
within the cloneProject describe block and remove the now-unnecessary
setupFailed guards and failure-scenario describe block.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cloneProject.spec.jsと同様に、別のdescribeブロックにあったログイン・クローン処理を
beforeAllに移動し、テストの実行順序に依存しないようにした。
エラーハンドリングも追加。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- buildProject: Setupテスト用describeを廃止しbeforeAllに統合
- monaca: getProjects/downloadFile/uploadFileのbeforeEachをbeforeAllに変更
- 空プロジェクト時のガードとエラーハンドリングを追加

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant