sono stato in grado di ottenere il vostro esempio lavorando bene, e quello che hai qui funziona bene. Ho fatto alcune modifiche ma ottengo lo stesso risultato. Quello che stai usando è connect, che sta generando un server web locale, quindi i test vengono eseguiti nel browser. Quindi, il tuo compito non è sospeso, sta semplicemente eseguendo il sever.
Ma da come sembra, probabilmente vorrai eseguire i test nel terminale? Se è così, ho una soluzione abbastanza decente per voi:
package.json
{
"name": "Jasmine Tests",
"description": "Jasmine Testing",
"version": "0.0.1",
"devDependencies": {
"grunt": "0.4.x",
"grunt-contrib-watch": "~0.2.0",
"grunt-contrib-jshint": "~0.4.3",
"grunt-contrib-jasmine": "~0.4.2",
"phantomjs": "1.8.2-0",
}
}
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
watch: {
grunt: {
files: ["Gruntfile.js", "package.json"],
tasks: "default"
},
javascript: {
files: ["src/client/**/*.js", "specs/**/*Spec.js"],
tasks: "test"
}
},
jasmine: {
src: "src/client/js/*.js",
options: {
specs: "specs/client/*Spec.js"
}
},
jshint: {
all: [
"Gruntfile.js",
"src/**/*.js",
"spec/**/*.js"
],
options: {
jshintrc: ".jshintrc"
}
}
});
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-jasmine");
grunt.registerTask("test", ["jshint", "jasmine"]);
grunt.registerTask("default", ["test"]);
};
È possibile modificare il file stucture a tutto ciò che più vi si addice . Impostazione entrambi questi file eseguire i seguenti comandi:
npm install
e
grunt test
o
grunt watch
Ora ho aggiunto un paio di cose, come jshint, e guardo ... watch è facoltativo, ma è davvero bello avere. jshint è un must nella mia opinione, ma sentitevi liberi di portarlo fuori dalla soluzione.
La chiave in realtà è phantomjs, che consente di eseguire questi test in un browser "fantasma", che viene inviato al terminale.
Sarà inoltre necessario personalizzare le directory in base alle proprie preferenze.
Ho postato un good blog post su questo (vado anche test lato server).
EDIT: Si effettua anche bisogno di un file .jshintrc se si sceglie di seguire questa strada.
.jshintrc
{
"curly" : true,
"eqeqeq" : true,
"immed" : true,
"latedef" : true,
"newcap" : true,
"noarg" : true,
"sub" : true,
"undef" : true,
"boss" : true,
"eqnull" : true,
"node" : true,
"es5" : true,
"globals" : {
"it" : false,
"xit" : false,
"describe" : false,
"xdescribe" : false,
"beforeEach" : false,
"afterEach" : false,
"expect" : false,
"spyOn" : false
}
}
Spero che questo aiuti.
Grazie !! quello ha funzionato per me. – Kianosh