试图让QUnit与Emberjs一起工作



我正在尝试使用QUnit设置ember测试,以测试我的ember.js应用程序。

我的问题是该应用程序没有在QUnit测试页面上呈现,因此visit("/")功能不起作用。

index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>MKTS Tests</title>
  <meta name="viewport" content="width=device-width" />
  <link rel="stylesheet" href="./bower_components/qunit/qunit/qunit.css">
  <!--
  <link rel="stylesheet" href="./css/foundation.css"> 
  <link rel="stylesheet" href="./css/app.css">
  -->
  <style type="text/css">
    #qunit-fixture, #app-root {
      position: relative;
      top: 0;
      left: 0;
      width: auto;
      height: auto;
    }
  </style>
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
  <!-- Libraries (Dependencies) -->
  <script src="../app/bower_components/requirejs/require.js"></script>
  <script src="../app/bower_components/jquery/dist/jquery.min.js"></script>
  <script src="../app/bower_components/handlebars/handlebars.js"></script>
  <script src="../app/bower_components/ember/ember.js"></script>
  <script src="../app/bower_components/ember-data/ember-data.js"></script>
  <!-- App and Templates -->
  <script src="../app/scripts/app.js"></script>
  <script src="../app/scripts/models/fleets.js"></script>
  <script src="../app/scripts/routes/application_route.js"></script>
  <script src="../app/scripts/routes/index_route.js"></script>
  <script src="../app/scripts/router.js"></script>
  <script src="../app/scripts/store.js"></script>
  <!-- Test Helpers -->
  <script src="./support/test_helper.js"></script>
  <!-- Test Library -->
  <script src="./bower_components/qunit/qunit/qunit.js"></script>
  <script src="./spec/integration.js"></script>
  <script src="./spec/unit.js"></script>
</body>
</html>

integration.js

test('hello world', function() {
  //debugger;
  //expect(1);
  MarketSetupAdminUi.reset();
  visit("/").then(function() {
    var title = find('title');
    equal(title.text(), 'Market Setup Tool', 'Title check');
  });
});

test-helper.js

(function (host) {
  var document = host.document;
  var App = host.MarketSetupAdminUi;
  var testing = function(){
    var helper = {
      container: function(){
        return App.__container__;
      },
      controller: function( name ){
        return helper.container().lookup('controller:' + name);
      },
      path: function(){
        return helper.controller('application').get('currentPath');
      }
    };
    return helper;
  };
  Ember.Test.registerHelper('path', function() {
    return testing().path();
  });
  Ember.Test.registerHelper('getFoodController', function() {
    return testing().controller('food');
  });
  // Move app to an element on the page so it can be seen while testing.
  document.write('<div id="test-app-container"><div id="ember-testing"></div></div>');
  App.rootElement = '#ember-testing';
  App.setupForTesting();
  App.injectTestHelpers();
  function exists(selector) {
    return !!find(selector).length;
  }
}(window));

我将应用程序更新为Ember 1.10.0和Ember数据测试版15。

我计划使用Ember CLI重新生成该应用程序,它似乎有更好的测试。

相关内容

  • 没有找到相关文章

最新更新