lundi 17 octobre 2016

karma tests passing in local but failing with Travis CI because Angular

I am trying to use Travis CI for my Angular project. I have setup one unit test that passes in local, but I got a failure in Travis CI.

I am trying to configure the .travis.yml file but I am a novice and I am not sure what I am missing.

PACKAGE.JSON

{
  "name": "webapp-boilerplate",
  "version": "1.0.0",
  "description": "Custom webapp boilerplate",
  "repository": {
    "type": "git",
    "url": "http://ift.tt/2dmpMcj"
  },
  "keywords": [
    "grunt",
    "angular",
    "custom",
    "boilerplate",
    "project"
  ],
  "scripts": {
    "start": "grunt",
    "build": "grunt dist",
    "test": "karma start",
    "changelog-pullrequest": "github-changes -o ibbatta -r grunt-frontend-boilerplate -a --only-pulls --use-commit-body",
    "changelog-commit": "github-changes -o ibbatta -r grunt-frontend-boilerplate -a"
  },
  "author": "Maurizio Battaghini",
  "license": "ISC",
  "homepage": "http://ift.tt/2egnul8",
  "devDependencies": {
    "angular-mocks": "^1.5.0",
    "autoprefixer": "^6.3.1",
    "github-changes": "^1.0.4",
    "grunt": "^1.0.1",
    "grunt-bootlint": "^0.10.1",
    "grunt-bower-concat": "^1.0.0",
    "grunt-bower-requirejs": "^2.0.0",
    "grunt-bower-task": "^0.4.0",
    "grunt-browser-sync": "^2.2.0",
    "grunt-contrib-clean": "^1.0.0",
    "grunt-contrib-compress": "^1.3.0",
    "grunt-contrib-concat": "^1.0.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-cssmin": "^1.0.2",
    "grunt-contrib-htmlmin": "^2.0.0",
    "grunt-contrib-imagemin": "^1.0.1",
    "grunt-contrib-jshint": "^1.0.0",
    "grunt-contrib-sass": "^1.0.0",
    "grunt-contrib-uglify": "^2.0.0",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-express": "^1.4.1",
    "grunt-injector": "^1.0.1",
    "grunt-ng-annotate": "^2.0.2",
    "grunt-parallel": "^0.5.1",
    "grunt-postcss": "^0.8.0",
    "grunt-sass": "^1.1.0",
    "grunt-spritesmith": "^6.3.1",
    "grunt-usemin": "^3.1.1",
    "grunt-wiredep": "^3.0.1",
    "jasmine-core": "^2.4.1",
    "jshint-stylish": "^2.1.0",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-firefox-launcher": "^1.0.0",
    "karma-jasmine": "^1.0.2",
    "karma-ng-html2js-preprocessor": "^1.0.0",
    "karma-phantomjs-launcher": "^1.0.0",
    "karma-safari-launcher": "^1.0.0",
    "load-grunt-tasks": "^3.4.0",
    "lodash": "^4.2.0",
    "ng-annotate": "^1.2.1",
    "phantomjs-prebuilt": "^2.1.4"
  }
}

BOWER.JSON

{
  "name": "webapp-boilerplate",
  "description": "Custom webapp boilerplate",
  "authors": [
    "Maurizio Battaghini"
  ],
  "license": "ISC",
  "keywords": [
    "grunt",
    "angular",
    "custom",
    "boilerplate",
    "project"
  ],
  "private": true,
  "dependencies": {
    "angular": "^1.5.8",
    "angular-animate": "^1.5.8",
    "angular-bootstrap": "^2.1.3",
    "angular-mocks": "^1.5.0",
    "angular-ui-router": "^0.3.1",
    "bootstrap-sass": "^3.3.6",
    "ng-lodash": "^0.5.0"
  },
  "exportsOverride": {
    "bootstrap-*": {
      "js": "**/*.js"
    }
  },
  "resolutions": {
    "angular": "^1.5.8"
  }
}

KARMA.CONF.JS

'use strict';

// Karma configuration
// Generated on Wed Feb 17 2016 17:56:06 GMT+0100 (CET)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: http://ift.tt/1ft83uu
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/bower_components/angular-bootstrap/ui-bootstrap.js',
      'app/bower_components/angular-ui-router/release/angular-ui-router.js',
      'app/index.js',
      'app/src/**/*.module.js',
      'app/src/**/*.js',
      'app/src/**/*.html'
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: http://ift.tt/1gyw6MG
    preprocessors: {
      'app/src/**/*.html': ['ng-html2js'],
      'app/src/**/!(*.spec).js': ['coverage'],
      'app/index.js': ['coverage']
    },

    ngHtml2JsPreprocessor: {
      // strip this from the file path
      stripPrefix: 'app/',
      // create a single module that contains templates from all the files
      moduleName: 'templates'
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: http://ift.tt/1ft83KQ
    reporters: ['progress', 'coverage'],

    coverageReporter: {
      type: 'html',
      // output coverage reports
      dir: 'coverage/'
    },


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: http://ift.tt/1ft83KU
    browsers: ['PhantomJS'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  });
};

TRAVIS.YML

language: node_js
node_js:
  - "6"

before_script:
  - sudo npm install -g bower karma
  - npm install
  - bower install


before_script:
  - karma start karma.conf.js --single-run

I am a bit disperate, I don't know how to do it because travis tell me that cannot find "angular" and exit build

Aucun commentaire:

Enregistrer un commentaire