I have an issue with testing my application with both jasmine-node
and mocha
(with zombie
). The point is angular
doesn't work with this test environment - when browser.visit "http://localhost:3000/"
it displays only layout, and don't render any templates link. I guess javascript doesn't run in browser (I mean zombie object) at all. My test Is there any way to make it works? Or problem is different?
In jasmine spec that i copied from another project spec occures an error:
/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
So I guess javascript doesn't work too.
Update: I add debug option and here what it displays:
➜ 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
Perhaps the problem in coffeescript but i had add option to mocha. And is there any method to test angular apps without JsTestDriver propagated by Angular team.
Updated.
I had changed errors assertions to browser.errors.should.be.empty
and it had shown me an error:
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)
Last update:
The problem was in assets pipeline, all js
was disabled for Zombie
browser. Now I change to js from coffee and it works. But I prefer coffee, So if anyone can solve it, i'll be grateful.
Can it be because of Mocha? I hear it can cause problems because of its name...
Have you tried the Angular Scenario Runner?