4

jasmine-nodemocha(と)の両方を使用してアプリケーションをテストする際に問題がありますzombie。ポイントはangular、このテスト環境では機能しないことです-レイアウトのみを表示し、テンプレートリンクbrowser.visit "http://localhost:3000/"をレンダリングしない場合。javascript はブラウザー (つまりゾンビ オブジェクト) でまったく実行されないと思います。私のテストそれを機能させる方法はありますか? それとも問題が違う?

別のプロジェクト仕様からコピーしたジャスミン仕様でエラーが発生します:

/home/alder/Node/angular-express-coffee/spec/app_spec.coffee:12
        throw error;
              ^
ReferenceError: angular is not defined
    at /js/services.js:4:3
    at /js/services.js:6:4
    in /js/services.js

したがって、JavaScriptも機能しないと思います。

更新: デバッグ オプションを追加すると、ここに表示される内容が表示されます:

➜  angular-express-coffee git:(master) ✗ mocha --require should --compilers coffee:coffee-script --colors  -R spec --ui bdd


  Given I am a new user
    When I visit the home page
Zombie: GET http://localhost:3000/newPost => 200
Zombie: GET http://localhost:3000/ => 200
Zombie: GET http://localhost:3000/js/lib/jquery-1.7.2.min.js => 200
Zombie: GET http://localhost:3000/js/lib/bootstrap.min.js => 200
Zombie: GET http://localhost:3000/js/lib/angular.min.js => 200
Zombie: GET http://localhost:3000/js/app.js => 200
Zombie: GET http://localhost:3000/js/controllers.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/controllers.js
Zombie: GET http://localhost:3000/js/lib/jquery-1.7.2.min.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/lib/jquery-1.7.2.min.js
Zombie: GET http://localhost:3000/js/filters.js => 200
Zombie: GET http://localhost:3000/js/directives.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/directives.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/filters.js
Zombie: GET http://localhost:3000/js/lib/bootstrap.min.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/lib/bootstrap.min.js
Zombie: GET http://localhost:3000/js/lib/angular.min.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/lib/angular.min.js
Zombie: GET http://localhost:3000/js/services.js => 200
Zombie: GET http://localhost:3000/js/filters.js => 200
Zombie: GET http://localhost:3000/js/directives.js => 200
Zombie: GET http://localhost:3000/js/controllers.js => 200
Zombie: GET http://localhost:3000/js/app.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/app.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/controllers.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/directives.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
    in /js/filters.js
Zombie: GET http://localhost:3000/js/services.js => 200

おそらくcoffeescriptの問題ですが、モカにオプションを追加しました。また、Angular チームによって伝播された JsTestDriver を使用せずに角度アプリをテストする方法はありますか。

更新しました。エラー アサーションをに変更しbrowser.errors.should.be.emptyたところ、エラーが表示されました。

1) Given I am a new user When I visit the home page Then browser status shold be ok:
AssertionError: expected [ [Error: Unexpected token ILLEGAL],
  [Error: Unexpected token ILLEGAL],
  [Error: Unexpected token ILLEGAL],
  [Error: Unexpected token ILLEGAL],
  [Error: Unexpected token ILLEGAL],
  [Error: Unexpected token ILLEGAL],
  [Error: Unexpected token ILLEGAL],
  [Error: angular is not defined] ] to be empty
  at Object.empty (/home/alder/Node/angular-express-coffee/node_modules/should/lib/should.js:229:10)
  at Context.<anonymous> (/home/alder/Node/angular-express-coffee/test/app_test.coffee:31:40)
  at Test.Runnable.run (/usr/lib/node_modules/mocha/lib/runnable.js:184:32)
  at Runner.runTest (/usr/lib/node_modules/mocha/lib/runner.js:300:10)
  at Runner.runTests.next (/usr/lib/node_modules/mocha/lib/runner.js:346:12)
  at next (/usr/lib/node_modules/mocha/lib/runner.js:228:14)
  at Runner.hooks (/usr/lib/node_modules/mocha/lib/runner.js:237:7)
  at next (/usr/lib/node_modules/mocha/lib/runner.js:185:23)
  at Runner.hook (/usr/lib/node_modules/mocha/lib/runner.js:205:5)
  at process.startup.processNextTick.process._tickCallback (node.js:244:9)

最終更新: 問題はアセット パイプラインにあり、ブラウザーでjsはすべて無効になっていました。Zombie今、私はコーヒーからjsに変更し、それは動作します. でも私はコーヒーが好きなので、誰か解決してくれたらありがたいです。

4

2 に答える 2

2

モカのせいでしょうか?名前のせいでトラブルになりやすいと聞きますが…

于 2014-04-28T17:13:49.153 に答える
0

Angular Scenario Runnerを試しましたか?

于 2012-11-16T20:16:29.720 に答える