Week 7, day 7
I'm sort of ok with my ToDo Challenge JavaScript backend at the moment but need to brush up a lot on my Protractor end-to-end testing and Angular implementation, but I'm sure I'll get there by the Tuesday morning deadline.
An interesting diversion I've taken today is to set up Travis-CI on my own from scratch for this repo. Join me after the break for the detailed steps.
So the first step is to head over to travis-CI and set it to track your repo and follow their limited instructions, then await the bevvy of errors to come!
First error:
todo_challenge@1.0.0 test /home/travis/build/sanjsanj/todo_challenge
karma start test/karma.conf.js
sh: 1: karma: not found
npm ERR! Test failed. See above for more details.
The command "npm test" exited with 1.
Setup your .travis.yml like so:
language: node_js
node_js:
- "0.12"
- "0.11"
- "0.10"
script: node_modules/karma/bin/karma start test/karma.conf.js --single-run
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
Source 1 and Source 2
Despite what they say, you can actually use Chrome as a test-browser if set up right.
Next error:
Uncaught ReferenceError: angular is not defined
at /home/travis/build/sanjsanj/todo_challenge/js/app.js:1
The command "node_modules/karma/bin/karma start test/karma.conf.js --single-run" exited with 1.
It's not finding Angular before it finds the app, I tried loading angular from CDN but that didn't work so I just moved the necessary files into a new public lib/ directory.
Edit your karma.conf.js like so:
module.exports = function(config) {
var configuration = {
basePath: '../',
frameworks: ['jasmine'],
files: [
'lib/angular.min.js',
'lib/angular-route.js',
'lib/angular-resource.js',
'lib/angular-mocks.js',
'js/**/*.js',
'test/**/*.spec.js',
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
singleRun: true
};
if(process.env.TRAVIS){
configuration.browsers = ['Chrome_travis_ci'];
}
config.set(configuration);
};
And then it actually worked! Now add your passing badge to your README and then kiss the sky.