Skip to content

Add data-testid feature spec helper method rubocop rule

Doug Stull requested to merge 422349-add-find-data-testid-cop into master

Description of the proposal

Add data-testid helper method rubocop rule for helpers added in !129391 (merged)

  • encourage use of helper
      # Prefer to use data-testid helpers for Capybara
      #
      # @example
      #   # bad
      #   find('[data-testid="some-testid"]')
      #   within('[data-testid="some-testid"]')
      #
      #   # good
      #   find_by_testid('some-testid')
      #   within_testid('some-testid')
      #

Check-list

  • Make sure this MR enables a static analysis check rule for new usage but ignores current offenses.
  • Mention this proposal in the relevant Slack channels (e.g. #development, #backend, #frontend).
  • The MR doesn't have significant objections, and is getting a majority of 👍 vs 👎 (remember that we don't need to reach a consensus).
  • Create a follow-up issue to fix the current offenses as a separate iteration: #422558 (closed)
  • Follow the review process as usual.
  • Once approved and merged by a maintainer, mention it again:
    • In the relevant Slack channels (e.g. #development, #backend, #frontend).
    • (Optional depending on the impact of the change) In the Engineering Week in Review.

/cc @gitlab-org/maintainers/rails-backend

Related to #422349 (closed)

Edited by Doug Stull

Merge request reports

Loading