سؤال

I want to make continuous integration for my chrome extension. Using tools: GitHub, Travis, Bower, components-jasmine. In .travis.yml:

  • install bower
  • in bower download jasmine
  • change default SpecRunner.html on my SpecRunner.html, which contains my src and specs
  • load my SpecRunner.html in phantomjs

.travis.yml:

language: node_js
node_js:
  - "0.10"
install:
  - npm install -g bower
  - bower install
  - cd $TRAVIS_BUILD_DIR
script:
  - mv -f ./test/SpecRunner.html ./vendor/components-jasmine
  - phantomjs ./test/runTests.js

runTests.js:

var page = require('webpage').create();
page.open('../vendor/components-jasmine/SpecRunner.html', function(){
    phantom.exit();
});

Tests should be failed, but status on travis - passed. Why my tests don't run?

هل كانت مفيدة؟

المحلول

Results of tests is showing on the same SpecRunner.html.

For getting results need to print this loaded page. If html loaded in phantomjs locally, then url should to follow classic Url/Uri rules, especially for a local file (that's why page not loaded):

file:///c:/path/to/the%20file.txt #win
file:///etc/fstab #unix

For getting results of tests need parse logs in after_script in .travis.yml and return value - 0 if tests passed or non-null if tests failed.

Also, probably, it's possible with help itself jasmine (but i'm not sure).

نصائح أخرى

Try to add after_script: echo $? to .travis.yml to see what is the return value of your test. If it's 0 then Travis behavior is correct.

I merely guess that your test just return 0 regardless of a result. According to the documentation this code just tries to open the file and calls a callback on failure - since there is no not-0-exit callback whole scripts exits normally and build passes.

EDIT:

From what you wrote I understand that Travis runs just fine, and it's phantomjs ./test/runTests.js that isn't returning non 0 value. Try to change:

function(){
  phantom.exit();
}

into something like:

function(status){
  if (status === 'success')
    phantom.exit(0);
  else
    phantom.exit(-1);
}

And say it that fail the build (I assume that page opening always fails).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top