Open yonta opened 5 days ago
エラー内容は、酒フォームで酒の名前から加水・原酒を原酒に自動補完する機能。 原酒の補完ができてない。
...........................................................................................................................................................................................................................F................................................................................................
Failures:
1) Sake Form Completion for Detail for detail accordion warimizu is completed 原酒
Failure/Error: expect(page).to have_select("sake_warimizu", selected:)
expected to find visible select box "sake_warimizu" that is not disabled but there were no matches. Also found "", which matched the selector but not all filters.
[Screenshot Image]: /home/runner/work/sakazuki/sakazuki/tmp/capybara/failures_r_spec_example_groups_sake_form_completion_for_detail_for_detail_accordion_warimizu_is_completed_原酒_309.png
# ./spec/system/sake_form_completion_for_detail_spec.rb:178:in `block (4 levels) in <top (required)>'
Finished in 1 minute 48.9 seconds (files took 3.81 seconds to load)
3[16](https://github.com/momocus/sakazuki/actions/runs/9731029983/job/26854920162#step:9:17) examples, 1 failure
Failed examples:
rspec ./spec/system/sake_form_completion_for_detail_spec.rb:[17](https://github.com/momocus/sakazuki/actions/runs/9731029983/job/26854920162#step:9:18)5 # Sake Form Completion for Detail for detail accordion warimizu is completed 原酒
Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected
Coverage report generated for RSpec to /home/runner/work/sakazuki/sakazuki/coverage/coverage.xml. 310 / 321 LOC (96.57%) covered
Error: Process completed with exit code 1.
よくあるのはJSの実行よりもCapybaraセレクタが早すぎること。 今回の補完機能もTS/JSで書かれているので、TAB後の補完が行われる前にマッチしてる?
でも1sスリープとかは入れたくない。テスト全体が恐ろしく遅くなる。
「フレーキーなテスト」というらしい。 よくまとまってて助かる~。 sleepは悪!!
カピバラは失敗したアサーションを自動で待ってリトライしてくれる。 この待つ時間(デフォルト2s)を少し伸ばしておくのがいいかな。3~5くらいか。
これの面白いところは、
! have_select
≠ have_no_select
not_to have_select
= have_no_select
なんだね。 アサーションがfalseを返したときだけ、待機・自動リトライをするから、気を付けて書かないと引っ掛かりそう。
Capybara.default_max_wait_time = 2
を5に伸ばして様子見るかー
💡 Summary
ときどきテストが失敗する。 再現性が低い、おしまいだ。
📝 再現方法
>わからない!!!<
🤬 失敗例
https://github.com/momocus/sakazuki/actions/runs/9731029983/job/26854920162