YusukeIwaki / playwright-ruby-client

Playwright client for Ruby
https://playwright-ruby-client.vercel.app/
MIT License
336 stars 34 forks source link

Minitest spec expectations #309

Open davekaro opened 3 weeks ago

davekaro commented 3 weeks ago

Simple description about the feature

Add Minitest spec expectations for parity with rspec

Usecase / Motivation

I'm using Minitest spec in my project and trying to figure out what is needed to enable tests like the rspec examples on https://playwright-ruby-client.vercel.app/docs/article/guides/rspec_integration

I think the desired outcome would be something similar to capybara's expectations here https://github.com/teamcapybara/capybara/blob/master/lib/capybara/minitest/spec.rb

For example,

it 'should show username after login' do
  page.fill('input[name="username"]', 'playwright')
  page.fill('input[name="password"]', 'password123')
  page.expect_navigation do
    page.locator('button[type="submit"]').click
  end

  dashboard_container = page.locator('.dashboard')

  # Web-first assertion
  expect(dashboard_container).must_have_text('Hi, playwright!')
end

I'm happy to try and make a PR for this work, but wondered if any thought has already been done on how to handle, or maybe it already works and I just don't know the right syntax.

YusukeIwaki commented 2 days ago

@davekaro Hi, I haven't worked for MiniTest integration at this moment, however Pull Request is really welcome.

Probably, https://github.com/YusukeIwaki/playwright-ruby-client/blob/1.47.0/lib/playwright/test.rb#L65-L76 this is RSpec-specific matcher. We have to define minitest matcher when minitest is used.