4

jasmine-node我在使用and mocha(with )测试我的应用程序时遇到问题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中的问题,但我已经添加了mocha选项。是否有任何方法可以在没有 Angular 团队传播的 JsTestDriver 的情况下测试 Angular 应用程序。

更新。我已将错误断言更改为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 回答