opitzconsulting / uitest.js

uitest.js is able to load a webpage into a frame, instrument that page and the javascript in that page (e.g. add additional scripts at the end of the document, ...) and execute actions on that page.
MIT License
67 stars 8 forks source link

angularIntegration gets Uncaught TypeError: Object #<Object> has no method 'runs' #27

Open apraditya opened 10 years ago

apraditya commented 10 years ago

First off, I can't find any doc on how to explicitly set this testing library on AngularJS app with Karma. So I blindly set it up from what I understand from the readme. Here's what I put in the karma-e2e.conf.js

files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
  'test/vendor/uitest.js',
  'test/e2e/**/*.js',
];

As for the rest of the Usage part of the readme, I don't quite get them. So I skip them anyway and straight away to the AngularJS-support and put these lines in my e2e spec:

describe("E2E: Testing RegisterCtrl", function() {

  var uit = uitest.current;
  uit.feature('angularIntegration');
  uit.append('lib/angular-mocks.js');
  uit.runs(function($httpBackend) {

    $httpBackend.whenPOST('../api/register/number/validno').respond(successfulResponse);
  });
  // ...
});

and I get the error, Uncaught TypeError: Object #<Object> has no method 'runs'. Is this due to uitest.js isn't set properly? Step 2 says the following line should be included in the pages that should be tested

<script type="text/javascript">parent.uitest && parent.uitest.instrument(window);</script>

Does it mean all of my views or I have to prepend this in beforeEach block? Thank you for creating the lib.

apraditya commented 10 years ago

After seeing your test/ui/angularSpec.js I created an html file following test/ui/fixtures/angular.html and added this line after var uit = uitest.current;

uit.url('../uitestjs_runner.html');

However I still get the same error. Thanks

tbosch commented 10 years ago

Hi, you need to load Jasmine first, and dont' load scenario, e.g.

files = [
  JASMINE,
  JASMINE_ADAPTER,
  'dist/uitest.js',
  'test/ui/**/*Spec.js'
]