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

E2E Testing with Protractor #42

Closed
lathonez opened this issue Mar 9, 2016 · 13 comments
Closed

E2E Testing with Protractor #42

lathonez opened this issue Mar 9, 2016 · 13 comments

Comments

@lathonez
Copy link
Owner

lathonez commented Mar 9, 2016

Angular 2 seed have a good set up we can hopefully borrow

@lathonez
Copy link
Owner Author

lathonez commented Mar 9, 2016

Looking at this now

@lathonez
Copy link
Owner Author

lathonez commented Mar 9, 2016

groundwork: fd563d5

@lathonez
Copy link
Owner Author

#50

@lathonez
Copy link
Owner Author

So since #50, all we need to do is:

  • move app.e2e.js to typescript inside the source folder
  • split app into separate files where appropriate
  • compile above to js in gulp
  • integrate with Travis

@mebibou
Copy link

mebibou commented Mar 14, 2016

FYI, if you add those lines in your protractor.conf.js, you don't need to do npm run webdriver-start anymore:

seleniumAddress: 'http://localhost:4444/wd/hub',
seleniumPort: 4444,
chromeDriver: '../node_modules/protractor/selenium/chromedriver'

@lathonez
Copy link
Owner Author

Thank you, will give it a go.

@mebibou
Copy link

mebibou commented Mar 14, 2016

Also, I don't know if you know ripple-emulator, but it allows you to run your app like an Android or iPhone app with some Cordova features (or writing your own bridges if you need more). Here's my full protractor.conf.js to give you an idea:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  seleniumPort: 4444,
  chromeDriver: '../node_modules/protractor/selenium/chromedriver',
  directConnect: true,
  framework: 'jasmine2',
  baseUrl: 'http://localhost:8100',
  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ['--disable-web-security']
    }
  },
  specs: [
    'protractor/**/*.js'
  ],
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30 * 1000,
    isVerbose: true
  },
  onPrepare: function() {
    // Use ripple emulator to run the tests
    var url = 'http://localhost:4400/?enableripple=cordova-3.0.0-' + browser.params.device;
    browser.driver.manage().window().maximize();
    browser.ignoreSynchronization = true;
    browser.driver.get(url);
    // Allow ripple to load
    browser.driver.wait(function() {
      return browser.driver.getCurrentUrl().then(function(actualUrl) {
        return url == actualUrl;
      });
    }, 10000, 'url hasnt changed');
    browser.driver.wait(function() {
      return element(by.id('document')).isPresent();
    }, 10000, 'ripple not loaded');
    browser.driver.switchTo().frame(0);
  }
};

Although this used to be working before, since I updated to ionic2-beta.3 it doesn't work anymore 😞 (ripple doesn't want to load anymore I don't know why)

@lathonez
Copy link
Owner Author

I don't, again thank you. I have basically zero experience with Protractor and E2E testing generally, so this is a big learning curve for me and I appreciate the advice.

You don't have a public repo with this in by any chance?

@mebibou
Copy link

mebibou commented Mar 14, 2016

Ah sorry I don't for now, but I could probably do something simple when I find the time for it

@lathonez
Copy link
Owner Author

No worries. Hopefully I will be able to get your suggestions in this and they will help some other people.

@lathonez
Copy link
Owner Author

Removing webdriver-start works well, thank you very much.

c5d3a46

Also raised #52 for ripple when I get round to it.

@mebibou
Copy link

mebibou commented Mar 14, 2016

eheh nice

@lathonez
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants