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

ときどきCIのテストが落ち、ReRunすると落ちない #745

Open
yonta opened this issue Jul 1, 2024 · 6 comments · Fixed by #746
Open

ときどきCIのテストが落ち、ReRunすると落ちない #745

yonta opened this issue Jul 1, 2024 · 6 comments · Fixed by #746
Assignees
Labels
bug Something isn't working

Comments

@yonta
Copy link
Collaborator

yonta commented Jul 1, 2024

💡 Summary

ときどきテストが失敗する。
再現性が低い、おしまいだ。

📝 再現方法

  1. テストCIをまわす
  2. 時々落ちる

>わからない!!!<

🤬 失敗例

https://github.com/momocus/sakazuki/actions/runs/9731029983/job/26854920162

@yonta yonta added the bug Something isn't working label Jul 1, 2024
@yonta yonta self-assigned this Jul 1, 2024
@yonta
Copy link
Collaborator Author

yonta commented Jul 1, 2024

エラー内容は、酒フォームで酒の名前から加水・原酒を原酒に自動補完する機能。
原酒の補完ができてない。

エラーログ

...........................................................................................................................................................................................................................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.

@yonta
Copy link
Collaborator Author

yonta commented Jul 1, 2024

よくあるのはJSの実行よりもCapybaraセレクタが早すぎること。
今回の補完機能もTS/JSで書かれているので、TAB後の補完が行われる前にマッチしてる?

でも1sスリープとかは入れたくない。テスト全体が恐ろしく遅くなる。

@yonta
Copy link
Collaborator Author

yonta commented Jul 1, 2024

「フレーキーなテスト」というらしい。
よくまとまってて助かる~。
sleepは悪!!

https://qiita.com/jnchito/items/56ba52c9a7246fc5016a

@yonta
Copy link
Collaborator Author

yonta commented Jul 1, 2024

カピバラは失敗したアサーションを自動で待ってリトライしてくれる。
この待つ時間(デフォルト2s)を少し伸ばしておくのがいいかな。3~5くらいか。

https://github.com/teamcapybara/capybara/blob/master/README.md#asynchronous-javascript-ajax-and-friends

これの面白いところは、

  • ! have_selecthave_no_select
  • not_to have_select = have_no_select

なんだね。
アサーションがfalseを返したときだけ、待機・自動リトライをするから、気を付けて書かないと引っ掛かりそう。

@yonta
Copy link
Collaborator Author

yonta commented Jul 1, 2024

Capybara.default_max_wait_time = 2を5に伸ばして様子見るかー

@yonta
Copy link
Collaborator Author

yonta commented Jul 31, 2024

治っとらーーーーん!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant