愚蠢验收测试在PhantomJS中失败,但在Chrome中传递 [英] Ember Acceptance Test Failing in PhantomJS but Passing in Chrome

查看:229
本文介绍了愚蠢验收测试在PhantomJS中失败,但在Chrome中传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的Ember应用程序写一个验收测试,而在PhantomJS和Ember测试服务器上,我似乎有些麻烦。

I'm trying to write an acceptance test for my Ember app and I seem to be having some trouble when it comes to PhantomJS and the Ember test server.

我正在运行以下版本:

Ember      : v1.13.6
Ember Data : v1.13.7

PhantomJS失败,出现以下错误:

PhantomJS is failing with the following error:

Died on test #1     at http://localhost:7357/assets/test-support.js:2934
            at http://localhost:7357/assets/test-support.js:6640
            at http://localhost:7357/assets/test-loader.js:31
            at http://localhost:7357/assets/test-loader.js:21
            at http://localhost:7357/assets/test-loader.js:40
            at http://localhost:7357/assets/test-support.js:6647: Can't find variable: DS

这是一个已知问题吗?

测试在铬转轮内运行良好。

The test is running fine within the chrome runner.

这是我的ember-cli-buil d.js(Brocfile):

Here is my ember-cli-build.js (Brocfile):

/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  // Build Options
  var options = {
    // Build for development (ember s)
    development: {
      sassOptions: {
        includePaths: ['bower_components/materialize/sass']
      }
    },

    // Build for deployments
    dev_deploy: {
      sassOptions: {
        includePaths: ['bower_components/materialize/sass']
      },

      fingerprint: {
        enabled: true,
        prepend: 'redacted',
        extensions: ['js', 'css', 'png', 'jpg', 'gif', 'woff', 'ttf']
      }
    },

    // Build for deployments
    staging_deploy: {
      sassOptions: {
        includePaths: ['bower_components/materialize/sass']
      },

      fingerprint: {
        enabled: true,
        prepend: 'redacted',
        extensions: ['js', 'css', 'png', 'jpg', 'gif', 'woff', 'ttf']
      }
    },

    prod_deploy: {
      sassOptions: {
        includePaths: ['bower_components/materialize/sass']
      },

      fingerprint: {
        enabled: true,
        prepend: 'redacted',
        extensions: ['js', 'css', 'png', 'jpg', 'gif', 'woff', 'ttf']
      }
    }
  };

  var env = process.env.EMBER_ENV || 'development';

  var app = new EmberApp(defaults, options[env]);

  // IMPORTED LIBRARIES
  app.import('vendor/js/ember-uploader.named-amd.js', {
    exports: {
      'ember-uploader': [ 'default' ]
    }
  });

  app.import('vendor/js/faye-browser.js');
  app.import('vendor/js/Util.js');
  app.import('vendor/js/CanvasVirtualJoyStick.js');
  app.import('vendor/js/CanvasZoomController.js');
  app.import('vendor/js/chosen.jquery.js');

  app.import('vendor/css/chosen.css');

  return app.toTree();
};

这是我的测试:

import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'teal-turtle/tests/helpers/start-app';

var application;

module('Acceptance | platforms', {
  beforeEach: function() {
    application = startApp();
  },

  afterEach: function() {
    Ember.run(application, 'destroy');
  }
});

test('visiting /platforms', function(assert) {
  authenticateSession();
  visit('/platforms');

  andThen(function() {
    assert.equal(currentURL(), '/platforms');
  });
});

谢谢!

推荐答案

我注意到你在路由文件(平台)中使用.bind,并且.bind不是很phantomJS友好:(所以我做了以下...

I noticed you were using .bind in the route file (platform) and .bind isn't very phantomJS friendly :( so I did the following...

将es5垫片和西兰花漏斗添加到您的package.json

Added the es5 shim and broccoli funnel to your package.json

"broccoli-funnel": "^0.2.3",
"es5-shim": "^4.0.5"

打开ember-cli-build.js(以前称为Brocfile)

Next I opened the ember-cli-build.js (prev known as the Brocfile)

var funnel = require('broccoli-funnel');
var es5Shim = funnel('node_modules/es5-shim', {
    files: ['es5-shim.js'],
    destDir: '/assets'
});

return app.toTree([es5Shim]);

最后,我将es5垫片添加到vendor.js上面的/ index.html上。

And finally I added the es5 shim to your tests/index.html above vendor.js

<script src="assets/es5-shim.js"></script>

以下是github的完整提交,显示人l文件已更改(注意:此提交示例中的Brocfile,因为我使用的是较旧的ember-cli版本)

Below is a full commit on github showing all the files changed (note: Brocfile in this commit example because I'm using an older ember-cli version)

https://github.com/toranb/ember-cli-simple-store/commit/4f46a392b3be0ec93864342ba2edddbd3430e293

这篇关于愚蠢验收测试在PhantomJS中失败,但在Chrome中传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆