2017-02-24 3 views
0

Ich bin neu in einem Winkeltest Testen, so dass ich die Hand für eine professionelle müssen da draußenPhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR Syntaxerror: ungültiges Zeichen: '#'

i Karma verwenden, Jasmin und PhantomJS i folgen Sie einfach dem Video tuts

i die Config so fertig und ich versuche, meinen Test

hier mein Karma congif

// Karma configuration 
// Generated on Fri Feb 24 2017 09:59:10 GMT+0800 (PHT) 

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: https://npmjs.org/browse/keyword/karma-adapter 
frameworks: ['jasmine'], 


// list of files/patterns to load in the browser 
files: [ 
    '../../bower_components/angular/angular.js', 
    '../../bower_components/angular-mocks/angular-mocks.js', 
    '../app/caes/controllers/positions/PositionIndexCtrl.coffee', 
    'unit/*.js' 
], 


// list of files to exclude 
exclude: [ 
], 


// preprocess matching files before serving them to the browser 
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 
preprocessors: { 
}, 


// test results reporter to use 
// possible values: 'dots', 'progress' 
// available reporters: https://npmjs.org/browse/keyword/karma-reporter 
reporters: ['progress'], 


// 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: https://npmjs.org/browse/keyword/karma-launcher 
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 
}) 
} 

meines Unit-Test testingPositionCtrlSpec.js

describe('Testing Position Suite', function() { 
describe('Testing Position Controller',function() { 

    it('Should initialize the position in the scope ', function() { 
     module('CaesApp'); 

     var scope = {}; 
     var ctrl; 
     inject(function ($controller) { 
      ctrl = $controller('PositionIndexCtrl', {$scope:scope}) 
     }); 

     expect($scope.position).toBeDefine(); 

    }); 
    }); 
}); 

dies ist die Controller i PositionIndexCtrl.coffee testen

#= require ./../../module 

PositionIndexCtrl = ($scope, $resource, $route, $mdDialog, Position)-> 


@positions = Position::list.query() 


@showNew = (ev)-> 
    position = new Position() 
    $mdDialog.show 
    controller: "PositionNewDialogCtrl" 
    templateUrl: '/templates/positions/new' 
    parent: angular.element(document.body) 
    targetEvent: ev 
    clickOutsideToClose:true 
    fullscreen: @customFullscreen 
    locals: 
    position: position 

$scope.edit = (rowId) -> 
    position = Position.get(id: rowId) 
    $mdDialog.show 
    controller: "PositionEditDialogCtrl" 
    templateUrl: '/templates/positions/edit' 
    parent: angular.element(document.body) 
    clickOutsideToClose:true 
    fullscreen: @customFullscreen 
    locals: 
     position: position 

$scope.delete = (rowId) -> 
    Position.get { id: rowId }, (position) -> 
    confirm = $mdDialog.confirm().title('Would you like to delete '+  position.name + ' Position').targetEvent(rowId).ok('Yes!').cancel('Cancel') 
    $mdDialog.show(confirm).then (-> 
    position.$remove -> 
     console.log('Deleted Success!') 
     $route.reload() 
) 
return 


PositionIndexCtrl.$inject = ["$scope", "$resource", "$route", "$mdDialog", "Position"] 

angular 
.module "CaesApp" 
.controller "PositionIndexCtrl", PositionIndexCtrl 

mein Fehler in Terminal

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR SyntaxError: Invalid character: '#' at /Users/cdasia-tsd/Desktop/revampCAES/app/assets/javascripts/app/caes/controllers/positions/PositionIndexCtrl.coffee:1

Ich weiß nicht, warum er '#' ein Fehler in Betracht ziehen?

meine Hypothese

  • er kann nicht lesen ?? Coffee
  • ich muss # zu meinem Komponententest erklären?

wenn jemand Erfahrung dieses bitte teilen Sie Ihr Wissen

Antwort

1

Sie haben Ihr Coffeescript in JavaScript, bevor Karma kompilieren kann es laufen. Karma kann kein Coffescript ausführen, nichts läuft direkt in Coffescript, es wird immer in JavaScript kompiliert.

Sie https://github.com/karma-runner/karma-coffee-preprocessor

+0

verwenden kann, werde ich diese Lösung versuche ich bei der Prüfung und Konfiguration neu bin so wird es wirklich schwer für mich – wiwit

+0

immer noch das gleiche bro – wiwit

+0

Dieser Kommentar sagen uns nichts über das, was Sie versucht haben, Was war der Fehler, wie können wir möglicherweise helfen? –