ember-cli:未找到ember测试错误全局模块

时间:2015-03-01 16:28:09

标签: ember.js ember-cli

使用ember-cli 0.1.15' ember test'尝试使用时刻给出错误。 下面的帮助程序在浏览器中加载正常,但测试无法尝试查找moment.js:

Could not find module app/helpers/bower_components/moment/moment

App Helper

import Ember from 'ember';
import moment from './bower_components/moment/moment';
export function formattedDate(date, format) {
  return moment(date).format(format);
}
export default Ember.Handlebars.makeBoundHelper(formattedDate);

测试

import {
  formattedDate
} from '../../../helpers/formatted-date';
import { module, test } from 'qunit';

module('FormattedDateHelper');

test('Unit FormattedDate', function(assert) {
  var Xmas95 = new Date('December 25, 1995 11:15:30');
  var result = formattedDate(Xmas95,'MMMM Do, YYYY [at] h:mm a');
  assert.ok(result === 'December 25th, 1995 at 11:15 am', 'boom:  '.concat(result));
});

Brocfile.js

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var app = new EmberApp();

app.import('bower_components/moment/min/moment.min.js');
module.exports = app.toTree();

完整错误消息

不行21 PhantomJS 1.9 - TestLoader失败:market / tests / unit / helpers / formatted-date-test:无法加载     ---         实际:>             空值         消息:>             死于http://localhost:7357/assets/test-support.js:2535的测试#1                 在http://localhost:7357/assets/test-support.js:5297                 在http://localhost:7357/assets/test-loader.js:31                 在http://localhost:7357/assets/test-loader.js:21                 在http://localhost:7357/assets/test-loader.js:40                 在http://localhost:7357/assets/test-support.js:5301:无法找到模块市场/助手/ bower_components /时刻/时刻         记录:>     ...

1 个答案:

答案 0 :(得分:0)

我只需要添加"时刻"到#34; predef"我的.jshintrc文件的部分如下:     " predef":[       "文件&#34 ;,       "窗口&#34 ;,       " -Promise&#34 ;,       "时刻"     ],