Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was able to get your example working just fine, and what you have here works ok. I did make a few modifications but I get the same result. What you are using is connect, which is spawning a local webserver, then the tests run in the browser. So, your task is not hanging, it's just running the sever. </p> <p>But from what it sounds like, you probably want your tests to run in the terminal? If so, I have a pretty decent solution for you:</p> <p><strong>package.json</strong></p> <pre><code>{ "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", } } </code></pre> <p><strong>Gruntfile.js</strong></p> <pre><code>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"]); }; </code></pre> <p>You can change the file stucture to whatever suits you. Setup both of these files run the following commands:</p> <pre><code>npm install </code></pre> <p>and </p> <pre><code>grunt test </code></pre> <p>or</p> <pre><code>grunt watch </code></pre> <p>Now I did add a few things, like jshint, and watch... watch is optional, but it's really nice to have. jshint is a must have in my opinon, but feel free to take it out of the solution. </p> <p>The key really is <a href="http://phantomjs.org/" rel="nofollow">phantomjs</a>, which enables you to run these tests in a "phantom" browser, which outputs to the terminal. </p> <p>You will also need to customize your directories to your likings.</p> <p>I posted a <a href="http://seesparkbox.com/foundry/grunt_automated_testing" rel="nofollow">good blog post</a> on this (I go server side tests as well).</p> <p><strong>EDIT:</strong> You make also need a <em>.jshintrc</em> file if you opt to go that route.</p> <p><strong>.jshintrc</strong></p> <pre><code>{ "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 } } </code></pre> <p>Hope this helps. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload