How do you perform javascript tests with Minitest, Capybara, Selenium?

后端 未结 4 1047
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 23:34

There are a lot of examples on how to perform javascript tests with Capybara/Selenium/Rspec in which you can write a test like so:

it \"does som         


        
4条回答
  •  萌比男神i
    2021-02-16 00:09

    https://github.com/wojtekmach/minitest-metadata seems to have provided a solution to exactly this.

    You can do the following:

    describe "something under test" do
      it "does not use selenium for this test" do
        visit "/"
        assert body.has_content?("Hello world")
      end
    
      it "does use selenium for this test", :js => true do
        visit "/"
        click_link "Hide" # a link that uses a javascript click event, for example
        assert body.has_no_link?("Hide")
      end
    end
    

提交回复
热议问题