Permalink
Browse files

Attempt to fix Issue #443

It ensure that:
  - the server:test have visibility on test, temp and app directories
  - the test target is first launching a server dedicated to phantom
  • Loading branch information...
sleeper committed Sep 14, 2012
1 parent 2558702 commit e8704ea150c5abcd1b91920ab6d970846687bbc1
@@ -7,8 +7,8 @@
<script src="lib/jasmine-1.2.0/jasmine-html.js"></script>
<!-- include source files here... -->
- <script src="../js/main.js"></script>
-
+ <!--script src="scripts/main.js"></script-->
+ <script data-main="scripts/main.js" src="scripts/vendor/require.js"></script>
<!-- include spec files here... -->
<!--
the `src/introduction.js` include the Jasmine introduction, with a
View
@@ -217,6 +217,12 @@ module.exports = function(grunt) {
dist: path.resolve('dist'),
test: path.resolve('test'),
+ // phantom target is a special one: it is triggered
+ // before launching the headless tests, and gives
+ // to phantomjs visibility on the same paths a
+ // server:test have.
+ phantom: path.resolve('test'),
+
// reload is a special one, acting like `app` but not opening the HTTP
// server in default browser and forcing the port to LiveReload standard
// port.
@@ -233,6 +239,19 @@ module.exports = function(grunt) {
return false;
}
+ var tasks = {
+ // We do want our coffee, and compass recompiled on change
+ // and our browser opened and refreshed both when developping
+ // (app) and when writing tests (test)
+ app: 'clean coffee compass open-browser watch',
+ test: 'clean coffee compass open-browser watch',
+ // Before our headless tests are run, ensure our coffee
+ // and compass are recompiled
+ phantom: 'clean coffee compass',
+ dist: 'watch',
+ reload: 'watch'
+ };
+
opts = {
// prevent browser opening on `reload` target
open: target !== 'reload',
@@ -252,14 +271,7 @@ module.exports = function(grunt) {
}
});
- if(target === 'app') {
- // when serving app, make sure to delete the temp/ dir from w/e was
- // previously compiled here, and trigger compass / coffee mostly to make
- // sure, those files are compiled and not revved.
- grunt.task.run('clean coffee compass open-browser');
- }
-
- grunt.task.run('watch');
+ grunt.task.run( tasks[target] );
});
grunt.registerHelper('server', function(opts, cb) {
@@ -272,14 +284,22 @@ module.exports = function(grunt) {
middleware.push( grunt.helper('reload:inject', opts) );
}
- middleware = middleware.concat([
- // also serve static files from the temp directory, and before the app
- // one (compiled assets takes precedence over same pathname within app/)
- connect.static(path.join(opts.base, '../temp')),
- // Serve static files.
- connect.static(opts.base),
+ // also serve static files from the temp directory, and before the app
+ // one (compiled assets takes precedence over same pathname within app/)
+ middleware.push(connect.static(path.join(opts.base, '../temp')));
+ // Serve static files.
+ middleware.push(connect.static(opts.base))
+ // Make empty directories browsable.
+ middleware.push(connect.directory(opts.base))
+
+ if ( (opts.target === 'test') || ( opts.target == 'phantom')) {
+ // We need to expose our code as well
+ middleware.push(connect.static(path.resolve('app')));
// Make empty directories browsable.
- connect.directory(opts.base),
+ middleware.push(connect.directory(path.resolve('app')));
+ }
+
+ middleware = middleware.concat([
// Serve the livereload.js script
connect.static(path.join(__dirname, 'livereload')),
// To deal with errors, 404 and alike.
View
@@ -216,4 +216,15 @@ describe('yeoman init && yeoman build', function() {
});
+ describe('And when I launch a test server ', function() {
+ it('should export the needed directories');
+// it('should export the needed directories', function(done) {
+// // setup the runnable, the actual run happens on last step
+// this.yeoman = helpers.run('server:test', opts);
+// this.yeoman
+// .expect(/\/test/)
+// .expect(/\/app/)
+// .end(done);
+// });
+ });
});
@@ -25,7 +25,7 @@ The built-in server also supports serving different profiles of your application
* `yeoman server` and `server:app` compile to and serve `/temp`, an intermediate build of your application.
* `yeoman server:dist` serves up the optimized final version of your application. This will just serve up the `/dist` directory if it exists and you will need to run `yeoman build` in order to generate the production build of your app.
-* `yeoman server:test` serves up the test suite
+* `yeoman server:test` serves up the test suite and your `app`. It also ensure any change to your code or tests will cause the browser to refresh.
* `yeoman server:reload` forces the port to be LiveReload standard port: 35729 and prevents the automatic default browser opening. Handy for those wishing to use livereload extensions with other systems / HTTP servers than the one provided by Yeoman out of the box.
### further notes
@@ -12,6 +12,10 @@ Mocha unit tests that you can continue using to test your application.
Running `yeoman test` allows you to easily check if all of your tests are passing. This also
gets called when running `yeoman build`.
+A dedicated server, with visibility on `app`, `temp` and `test` is
+launched to serve file for PhantomJS.
+
+
Example:
{% highlight sh %}

0 comments on commit e8704ea

Please sign in to comment.