rquellh / testcafe-cucumber

Integration of TestCafe and CucumberJS
MIT License
95 stars 59 forks source link

testcafe-cucumber integration with Docker, Browserstack or SauceLabs #16

Open bhreinb opened 6 years ago

bhreinb commented 6 years ago

Hi @rquellh,

I came across your code repository. It looks fantastic 👍 .

I was able to run tests on my development machine straight forward enough.

I notice Testcafe supports testing with docker, saucelabs & browserstack. I'm new enough to Testcafe so I have only seen samples whereby integration with these providers have been through Testcafe command line. So my question would be, is their a way to run the tests against any of those providers given the way the tests are initiated in this project (via cucumberjs runner).

If their was a sample that would be very useful, because essentially I would think the project offering would be on par (if not better) with other alternatives (for example cucumberjs & protractor or cucumberjvm & selenium) which support that out of the box already.

Thoughts?

dn1231 commented 6 years ago

Yup this would be helpful for us too. We currently have browserstack running with testcafe but not sure how to integrate it when we have cucumber.

kenf128 commented 6 years ago

with browserstack local enabled and setting the browser parameter (e.g. to "browserstack:Samsung Galaxy S9 Plus@8.0"), we're able to run tests through remote browsers on browserstack.

however, this doesn't seem to work for iOS/ OSX devices. i think we need to be able to connect on a different port (e.g. 9000 instead of 1338)....

rquellh commented 5 years ago

It looks like this can be done with this plugin. You'll also have to change the hooks.js file to include the browserstack configuration you are testing with.

function runTest(iteration, browser) {
    createTestCafe('localhost', 1338 + iteration, 1339 + iteration)
        .then(function(tc) {
            cafeRunner = tc;
            const runner = tc.createRunner();
            return runner
                .src('./test.js')
                .screenshots('reports/screenshots/', true)
                .browsers('browserstack:Chrome@53.0:Windows 10')
                .run()

I don't have any experience using browserstack, but just reading the documentation this is what I could come up with.

Let me know if this helps.

kenf128 commented 5 years ago

thank you so much for looking into it! that is the plug-in we're working with. with your tips on port changing, we're able to get it working for all devices/ browsers except iphone and ipads. on those, browserstack told us this:

"MAC OS X and iOS devices have an issue while resolving localhost / 127.0.0.1 URLs on BrowserStack. I would recommend you replace localhost / 127.0.0.1 in your URL to the actual IP address. For example, if the IP for the machine on which application/webpage is hosted is 10.10.10.10, then change http://127.0.0.1:9000/index.html to http://10.10.10.10:9000/index.html in your test scripts running on OS X and iOS devices."

would what they suggested be feasible to do with testcafe-cucumber?

natkrish commented 5 years ago

Hi all Has anyone been successful in running tests via browser stack with the changes mentioned above in hooks? Has anyone tried it from CI server like Jenkins for example?

kenf128 commented 5 years ago

yes, i have -- and it works. however, the tests still wouldn't run on iphone or ipad because those devices apparently don't like the localhost redirect....

i suspect the change in hooks.js would work fine within jenkins as well, although i haven't tried it.

lobmails commented 5 years ago

Do we have any updates on iOS/iPhone support, any workaround? this is one of the crucial piece missing for end-to-end testing.

Manikanta6393 commented 3 years ago

Hey @kenf128, Could you please share your hook.js code... I tried @rquellh solution, it's working fine. However BrowserStack session is not getting stopped after test case execution. TIA.

haideralii commented 3 years ago

@kenf128 how are you able to integrate test for the issue occurs that ERROR The specified "browserstack" browser provider was not found. (when we install testcafe as dev dependency) and If I try to install testcafe as global then it does not execute the test