위대한 yeoman generator-ember
(버전 0.7.1)을 통해 ember.js 프로젝트를 생성 한 후 통합 된 mocha
으로 테스트를 실행하려고합니다.Ember.JS 응용 프로그램이 ReferenceError와 함께 실패 함 : Ember가 정의되지 않았습니다.
grunt test
또는
npm test
을 표준 시험은 잘 작동하지만 엠버 프로젝트를 참조하지 미상. 그래서 자신의 모델을 테스트
ReferenceError: Ember is not defined
at Context.<anonymous> (/home/lray/workspace/js/mediator/test/spec/source_model_test.js:9:9)
at Hook.Runnable.run (/home/lray/workspace/js/mediator/node_modules/mocha/lib/runnable.js:213:32)
at next (/home/lray/workspace/js/mediator/node_modules/mocha/lib/runner.js:243:10)
at Object._onImmediate (/home/lray/workspace/js/mediator/node_modules/mocha/lib/runner.js:254:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
이것은 언급 된 테스트 ...
'use strict';
(function() {
describe('Mediator.Source (Model)', function() {
beforeEach(function() {
Ember.run(function() { Mediator.reset(); });
Ember.testing = true;
});
afterEach(function() {
Ember.testing = false;
});
describe('initialize like expected', function() {
it('should return the given parameters correctly', function(){
var oItem;
Ember.run(function() {
// Won't actually load until the end of the run-block.
oItem = Mediator.Source.find(1);
});
expect(oItem.get("id")).to.be.equal("myId");
expect(oItem.get("name")).to.be.equal("myName");
expect(oItem.additional).to.be.false();
})
})
});
})();
내 package.json
꽤 그대로 보이는 던졌습니다 :
{
"name": "mediator",
"version": "0.0.1",
"dependencies": { },
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.5.0",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.3.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "0.1.4",
"grunt-contrib-watch": "~0.5.2",
"grunt-rev": "~0.1.0",
"grunt-usemin": "~0.1.12",
"grunt-mocha": "~0.4.1",
"grunt-open": "~0.2.0",
"grunt-svgmin": "~0.2.0",
"grunt-concurrent": "~0.3.0",
"load-grunt-tasks": "~0.1.0",
"connect-livereload": "~0.2.0",
"grunt-ember-templates": "0.4.14",
"time-grunt": "~0.1.1",
"grunt-neuter": "~0.5.0",
"mocha": "~1.9.0",
"expect.js": "~0.2.0"
},
"scripts": {
"test": "mocha --recursive test/spec/*.js"
},
"engines": {
"node": ">=0.8.0"
}
}
업데이트 :가에 require("ember");
추가 테스트 케이스 파일 npm test
이 불평합니다.
> [email protected] test /home/lray/workspace/js/mediator
> mocha --recursive test/spec/*.js
module.js:340
throw err;
^
Error: Cannot find module 'ember'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/lray/workspace/js/mediator/test/spec/source_model_test.js:4:1)
grunt test
은 테스트 파일을 무시합니다.
Ember와 어떻게 다르게 연결해야합니까? 그렇게하는 가장 좋은 방법은 무엇입니까? 미리 감사드립니다 ...
안녕하세요, @ 루위, 그 초고속 응답에 대한 thnx. 나는 그것을 일찍 시도했지만, 꿀꿀기가 테스트 케이스를 무시하기 시작하는 동안, 모카는 '엠버'모듈을 찾지 못한다고 불평했다. 접근법에 대해 다른 아이디어가 있습니까? –