Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

testem task

  • Loading branch information...
commit 3e977ad577390944e7e67448009341b6abcda2ab 1 parent a94edf0
sideroad authored
Showing with 79 additions and 1 deletion.
  1. +11 −0 .project
  2. +27 −1 README.md
  3. +41 −0 testem.js
11 .project
View
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>grunt-tasks</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
28 README.md
View
@@ -1,4 +1,30 @@
grunt-tasks
===========
-grunt tasks
+Install
+Download grunt-tasks and add path of load task into grunt.js.
+```javascript
+grunt.loadTasks('path/to/grunt-tasks');
+```
+
+testem
+------
+
+
+### All browsers test
+```javascript
+grunt.initConfig({
+ testem : {
+ ci : []
+ }
+});
+```
+
+### Browser selected
+```javascript
+grunt.initConfig({
+ testem : {
+ ci : ['chrome','safari']
+ }
+});
+```
41 testem.js
View
@@ -0,0 +1,41 @@
+/*
+ * grunt
+ * https://github.com/cowboy/grunt
+ *
+ * Copyright (c) 2012 "Cowboy" Ben Alman
+ * Licensed under the MIT license.
+ * http://benalman.com/about/license/
+ */
+
+module.exports = function(grunt) {
+
+ var exec = require('child_process').exec;
+
+ grunt.registerMultiTask( 'testem', 'Execute testem.', function() {
+
+ var done = this.async(),
+ browsers = (this.data.length) ? ' -b ' + this.data.join(',') : '';
+
+ exec( 'testem ci'+browsers, {}, function( code, stdout, stderr ){
+ var tests = +(stdout.match(/\n# tests\s+(\d+)/)||[0])[1],
+ pass = +(stdout.match(/\n# pass\s+(\d+)/)||[0])[1],
+ fail = +(stdout.match(/\n# fail\s+(\d+)/)||[0])[1],
+ not = (stdout.match(/\nnot ([^\n]+)/g)||['']).join('');
+
+ if( tests != pass ||
+ fail ||
+ not ||
+ stderr ) {
+ grunt.log.error(not);
+ grunt.log.error(''+fail+'/'+tests+' assertions failed');
+ done(false);
+ } else {
+ grunt.log.writeln(''+tests+' assertions passed');
+ done(true);
+ }
+ });
+ grunt.log.writeln('Now testing...');
+ });
+
+
+};
Please sign in to comment.
Something went wrong with that request. Please try again.