How can I run an acceptance test?

I have the following tests/acceptance/index-test.jsin application 0.0.22 ember-cli version:

import startApp from '../helpers/start-app';
test('index transitions', function(){
  visit('/');
});

When I go to http://localhost:4200/tests, I see:

Died on test #1
at eval (ember-cli/tests/acceptance/index-test.js:7:5)
at requireModule (loader/loader.js:54:29)
at eval (ember-cli/tests/test-loader.js:9:7)
at Array.forEach (native)
at eval (ember-cli/tests/test-loader.js:8:8)
at requireModule (loader/loader.js:54:29)
at http://localhost:4200/tests:43:7: visit is not defined

Source: ReferenceError: visit is not defined
at Object.eval (ember-cli/tests/acceptance/index-test.js:8:7)

I seem to have problems downloading the code. Placeholder files in a project would be helpful. How can I make it work?

+4
source share
2 answers

I needed to call startApp();in a test file, for example:

import startApp from '../helpers/start-app';

test('index transitions', function(){
  startApp();
  visit('/');
  andThen(function(){
    equal(find('h3.breadcrumb').text(), 'Title');
  });
});
+9
source

I have added this section to the documentation for ember-cli.

Be sure to call startApp()in the setupmodule, for example:

 module('An Integration test', {
     setup: function() {
         App = startApp();
     },
     teardown: function() {
         Ember.run(App, App.destroy);
     },
 });

... instead of everyone test.

+4
source

Source: https://habr.com/ru/post/1536024/


All Articles