node.js – 测试AngularJS express节点应用程序

我在使用jasmine-node和mocha(使用zombie)测试我的应用程序时遇到问题.点是角度不适用于此测试环境 – 当browser.visit“http:// localhost:3000 /”它只显示布局,并且不渲染任何模板
link.我猜javascript不能在浏览器中运行(我的意思是僵尸对象).
My test有什么方法可以使它有效吗?还是问题不同?

在我从另一个项目spec复制的jasmine规范中发生错误:

/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中的问题,但我添加了mocha的选项.是否有任何方法可以在没有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,它有效.但我更喜欢咖啡,所以如果有人能解决它,我将不胜感激.

最佳答案 你试过
Angular Scenario Runner吗?

点赞