我正在尝试为我的Ember应用程序编写验收测试,而且在使用PhantomJS和Ember测试服务器时,我似乎遇到了一些问题。
我正在运行以下版本:
Ember : v1.13.6
Ember Data : v1.13.7
PhantomJS失败并出现以下错误:
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
这是一个已知问题吗?
测试在镀铬流道内运行良好。
这是我的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');
});
});
谢谢!
答案 0 :(得分:5)
我注意到你在路径文件(平台)中使用了.bind而且.bind并不是非常友好的:(所以我做了以下......
将es5垫片和西兰花漏斗添加到package.json
"broccoli-funnel": "^0.2.3",
"es5-shim": "^4.0.5"
接下来我打开了ember-cli-build.js(以前称为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上面的tests / index.html
<script src="assets/es5-shim.js"></script>
下面是github上的完整提交,显示所有文件都已更改(注意:此提交示例中为Brocfile,因为我使用的是较旧的ember-cli版本)
https://github.com/toranb/ember-cli-simple-store/commit/4f46a392b3be0ec93864342ba2edddbd3430e293