2

I'm aware that ember-cli can be used write unit, integration and acceptance tests for apps with default test-runners: QUnit and PhantomJS. I want to write acceptance tests for a remote website using ember-cli . I was able to write basic test cases for a local app created using:

ember new <login-test-repo>
ember generate acceptance-test login-test

I'm able to fill in, click and run tests on the local app, but when I change the rootURL of in the environment as I need a remote website to be tested, ember-cli adds "/" at the start to the remote website URL and tests fail with error:

The URL "/https://my-website.com" did not match any routes in your application

I'm pretty new to testing front-end apps with ember-cli. I've tested the same workflow with selenium where I can scrap and run acceptance tests for the webpage easily.

Any help on setting up ember-cli routes for remote webpage would be of great help. Thanks.

pritam
  • 2,452
  • 1
  • 21
  • 31

1 Answers1

0

I don't want to be prophet of doom, but it is just not meant to test remote websites using Ember CLI tooling. First, you can see in your config different configuration for tests, develop and production environments. One of key things is:

ENV.APP.rootElement = '#ember-testing';

And application is rendered into that element. Also the application is closed after each acceptance test, then booted again, initializers are fired. It works because start-app test helper is called:

import Ember from 'ember';
import Application from '../../app';
import Router from '../../router';
import config from '../../config/environment';

export default function startApp(attrs) {
  let application;

  let attributes = Ember.merge({}, config.APP);
  attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;

  Ember.run(function() {
    application = Application.create(attributes);
    application.setupForTesting();
    application.injectTestHelpers();
  });

  return application;
}

You don't have any of these things remotely. Also, how would you expect your tests to get this remote website? Via IFRAME - I seriously doubt there's any logic in Ember CLI tooling to make it work. :)

The standard I'm familiar with is remote websites are tested via Selenium, for example, by QA or developers. Separate Ember CLI test suite is maintained by developers.

Daniel Kmak
  • 18,164
  • 7
  • 66
  • 89