Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed non-generic project dependencies from this grunt plugin + min…

…or refactorings
  • Loading branch information...
commit c7ae2e0033b695f2b836aa5f7a096544a4e70fdf 1 parent 56551f4
Alexander Praetorius authored
View
45 .jshintrc
@@ -1,14 +1,33 @@
{
- "curly": true,
- "eqeqeq": true,
- "immed": true,
- "latedef": true,
- "newcap": true,
- "noarg": true,
- "sub": true,
- "undef": true,
- "boss": true,
- "eqnull": true,
- "node": true,
- "indent": 2
-}
+ "browser": true,
+ "strict": true,
+ "camelcase": false,
+ "newcap": true,
+ "indent": 2,
+ "quotmark": "single",
+ "trailing": true,
+ "undef": true,
+ "eqeqeq": true,
+ "curly": true,
+ "forin": true,
+ "immed": true,
+ "latedef": true,
+ "noarg": true,
+ "scripturl": true,
+ "unused": true,
+
+ "globals": {
+ "define": true,
+ "jasmine": true,
+ "require": true,
+ "$": true,
+ "_": true,
+ "Backbone": true,
+ "Highcharts": true,
+ "google": true,
+ "console": true,
+ "module": true,
+ "process": true,
+ "__dirname": true
+ }
+}
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "grunt-requirejs-testem",
"description": "Be able to use 'testem' (github.com/airportyh/testem) with 'RequireJS' (github.com/requirejs) in your project using this plugin for 'grunt' (github.com/gruntjs/grunt)",
- "version": "0.1.65",
+ "version": "0.2.0",
"homepage": "https://github.com/serapath/grunt-requirejs-testem",
"author": {
"name": "Alexander Praetorius",
View
82 tasks/lib/SuitesRunner.js
@@ -1,82 +0,0 @@
-/*!
- * Datapine
- * FIXTURE - Uses SPEC SUITES which contain a Set of SUITES:
-// - 1. UNIT TESTs (test interface of component)
-// - 2. INTEGRATION TESTs (test combination of tested components)
-// - 3. REGRESSION TESTs (run tests every time the project code changes)
- * Copyright(c) 2013
- */
-(function(){ // SpecRunner.js
- 'use strict';
- require.config({ // CONFIG
-
- baseUrl: '/app/', // Require configuration [requireJS] - SpecRunner.js Config
- paths: {
- // Libraries
- 'text' : '../vendor/require.text-2.0.3',
- 'squire' : '../vendor/squire',
- 'jasq' : '../vendor/jasq'
- },
-
- // Browser Cache Buster - use only where needed, because slows down stuff and also makes
- // (Chrome) debugger forget breakpoints across page reloads
- urlArgs: ''/*'cb=' + Math.random()*/
- });
- // CONFIGURE ENVIRONMENT
-
- // Backbone Layout Manager configuration
- Backbone.LayoutManager.configure({
- // This allows for Underscore templating
- // https://github.com/tbranyen/backbone.layoutmanager#asynchronous--synchronous-fetching
- fetch: function(html) {
- return _.template(html);
- },
- // This allows Views and LayoutViews to be interchangable, avoids much confusion
- // https://github.com/tbranyen/backbone.layoutmanager#structuring-a-view
- manage: true
- });
-
- // EXECUTE JASMINE TEST ENGINE
- require(['parameters'], function(parameters){
- // PARAMETERS - Contains Names of TestSuiteSets to be executed
- console.log('REGRESSION TESTING with named SpecSuiteSets:');
- var SpecSuiteSet, styles, htmlStyles, requiredTestSuites, name, i, j;
- SpecSuiteSet = { };
- for (name in parameters) {
- if(parameters.hasOwnProperty(name)) {
- console.log('- ' + name);
- SpecSuiteSet[name] = { };
- for(i=0; i<parameters[name].length; i++) {
- styles = parameters[name][i].styles;
- htmlStyles = '';
- for(j=0; j<styles.length; j++){
- htmlStyles += '<link name="suite" rel="stylesheet" type="text/css" href="' + styles[j] + '">';
- }
- SpecSuiteSet[name].htmlStyles = htmlStyles;
- }
- for(i=0; i<parameters[name].length; i++) {
- SpecSuiteSet[name].requiredTestSuites = parameters[name][i].suites;;
- }
- }
- }
- var namedSpecSuites, env, htmlReporter;
- for (namedSpecSuites in SpecSuiteSet) {
- if(SpecSuiteSet.hasOwnProperty(namedSpecSuites)) {
- $('head').append(SpecSuiteSet[namedSpecSuites].htmlStyles);
- // LOAD SPEC SUITES
- require(SpecSuiteSet[namedSpecSuites].requiredTestSuites, function() {
- // JASMINE SETUP
- var env = jasmine.getEnv();
- // env.updateInterval = 1000;
- var htmlReporter = new jasmine.HtmlReporter();
- env.addReporter(htmlReporter);
- // env.specFilter = function(SpecSuites) {
- // return htmlReporter.specFilter(SpecSuites);
- // };
- env.execute(); // EXECUTE SPEC SUITES
- });
- $('head > link[name="suite"]').remove();
- }
- }
- });
-})();
View
164 tasks/lib/SuitesRunner.mustache
@@ -3,88 +3,136 @@
<head>
<meta charset="UTF-8">
<title>Datapine Tests - [Require.js with Jasmine]</title>
- <link rel="shortcut icon" type="image/png" href="/vendor/BOWER_INSTALLED/jasmine/images/jasmine_favicon.png">
- <link rel="stylesheet" type="text/css" href="/vendor/BOWER_INSTALLED/jasmine/src/html/jasmine.css">
+ <link rel="shortcut icon" type="image/png" href={{favicon}}>
+ <link rel="stylesheet" type="text/css" href={{cssfile}}>
</head>
<body>
<h1>Datapine Tests</h1>
<h3>Require.js + Jasmine</h3>
- <b>Real Time Testing for: </b>
-
- <br>
- Options:<br>
- Filename: {{test_page}}<br>
- Timeout: {{timeout}} ms<br>
- onStart: {{on_start}}<br>
- beforeTests: {{before_tests}}<br>
- afterTests: {{after_tests}}<br>
- onExit: {{on_exit}}<br>
- Launch_in_dev: {{#launch_in_dev}} {{.}}, {{/launch_in_dev}}<br>
- Launch_in_ci: {{#launch_in_ci}} {{.}}, {{/launch_in_ci}}<br>
- <br>
+ <b>Real Time Testing Options: </b>
+ <table border='1'>
+ <tr>
+ <td>Timeout:</td>
+ <td>onStart:</td>
+ <td>beforeTests:</td>
+ <td>afterTests:</td>
+ <td>onExit:</td>
+ <td>Launch_in_dev:</td>
+ <td>Launch_in_ci:</td>
+ </tr>
+ <tr>
+ <td>{{timeout}} ms</td>
+ <td>{{on_start}}</td>
+ <td>{{before_tests}}</td>
+ <td>{{after_tests}}</td>
+ <td>{{on_exit}}</td>
+ <td>{{#launch_in_dev}} {{.}}, {{/launch_in_dev}}</td>
+ <td>{{#launch_in_ci}} {{.}}, {{/launch_in_ci}}</td>
+ </tr>
+ </table>
<br>
- <u>SPEC_SUITE_SETS:</u><br>
- {{#SSS}}
- - {{name}}<br>
- {{/SSS}}<br>
-
+ <u><b>SPEC_SUITE_SETS:</b></u>
+ {{#usedTestScope}}
+ <br>- {{name}}
+ {{/usedTestScope}}
+ <br>
<!-- ===============================================================
// Sandbox that tests can use for things that require the DOM
- // => If a SpecSuite requires the use of the DOM, make sure it’s done in here and then cleaned up when you’re done.
- // Hidden 'Sandbox' Element for appending SUTs to DOM
- // VIEWs will append themselves to it during Tests
- // VIEWs will remove themselves from the DOM after Tests
+ // => If a SpecSuite requires the use of the DOM, make sure
+ // it’s done in here and then cleaned up when you’re done.
+ // Hidden 'Sandbox' Element for appending SUTs to DOM
+ // VIEWs will append themselves to it during Tests
+ // VIEWs will remove themselves from the DOM after Tests
=============================================================== -->
<div id="sandbox" style="overflow:hidden; height:1px;"></div>
-
-
<!-- ===============================================================
Jasmine SuitesRunner results go here:
=============================================================== -->
- <script type="text/javascript" src="/vendor/BOWER_INSTALLED/jasmine/lib/jasmine-core/jasmine.js"></script>
+
+ <!-- ===============================================================
+ Global Script Tags:
+ =============================================================== -->
+ {{#globalScripts}} <script type="text/javascript" src='{{.}}'></script> {{/globalScripts}}
<script src="/testem.js"></script> <!-- Testem creates 'testem helper file' automatically during runtime -->
- <script type="text/javascript" src="/vendor/BOWER_INSTALLED/jasmine/lib/jasmine-core/jasmine-html.js"></script>
- <script type="text/javascript" src="/vendor/BOWER_INSTALLED/jquery/jquery.js"></script>
- <script type="text/javascript" src="/vendor/BOWER_INSTALLED/underscore/underscore.js"></script>
- <script type="text/javascript" src="/vendor/BOWER_INSTALLED/backbone/backbone.js"></script>
- <script type="text/javascript" src="/vendor/BOWER_INSTALLED/layoutmanager/backbone.layoutmanager.js"></script>
- <script type="text/javascript" src="/vendor/backbone.nested-1.1.2.js"></script>
- <script type="text/javascript" src="/vendor/jasmine-jquery.js"></script>
- <script type="text/javascript" src="/test/helpers/jasmine-matchers.js"></script>
<!-- ===============================================================
Use RequireJS to Start SuitesRunner.js
=============================================================== -->
- <script data-main="SuitesRunner" src="/vendor/BOWER_INSTALLED/requirejs/require.js"></script>
-
+ <script src="/vendor/BOWER_INSTALLED/requirejs/require.js"></script>
<!-- ===============================================================
{{SUD}} is specified in "xyz.json testem config files" as an array of strings representing SpecSuite files
The "xyz.json" config file for testem is specified as a console option for "grunt testem:xyz"
=============================================================== -->
- <script> define('parameters', function() {
- var parameters = { };
- var namedSSS;
- var namedSS;
- '{{#SSS}}';
- namedSSS = [];
- '{{#specSuiteSet}}';
- namedSS = { styles: [], suites: [] };
- '{{#styles}}';
- namedSS.styles.push('{{.}}');
- '{{/styles}}';
- '{{#suites}}';
- namedSS.suites.push('{{.}}');
- '{{/suites}}';
- namedSSS.push(namedSS);
- '{{/specSuiteSet}}';
- parameters['{{name}}'] = namedSSS;
- '{{/SSS}}';
- return parameters;
- });
- </script>
+ <script> require(['{{testemStarter}}'],
+ function(SpecSuitesExecutioner) {
+ 'use strict';
+ if(!SpecSuitesExecutioner) {
+ throw new Error('{{testemStarter}} should define a\n function SpecSuitesExecutioner(SpecRunner) {' +
+ '\n return function executeSpecSuites() {' +
+ '\n // ... configure/setup/execute jasmine/mocha/etc...' +
+ '\n // e.g. SpecRunner is "jasmine"' +
+ '\n SpecRunner.getEnv().addReporter(new HtmlReporter()).execute(); }');
+ }
+ var
+ usedTestScope = [],
+ namedSpecSuitesList = [],
+ namedSpecSuites
+ ;
+ '{{#namedSpecSuitesList}}';
+ namedSpecSuites = { styles: [], suites: [] };
+ '{{#styles}}';
+ namedSpecSuites.styles.push('{{.}}');
+ '{{/styles}}';
+ '{{#suites}}';
+ namedSpecSuites.suites.push('{{.}}');
+ '{{/suites}}';
+ namedSpecSuitesList.push(namedSpecSuites);
+ '{{/namedSpecSuitesList}}';
+ '{{#usedTestScope}}';
+ usedTestScope.push('{{.}}');
+ '{{/usedTestScope}}';
+
+ console.log('RUNS REGRESSION TESTING with given set of named SpecSuitesLists [=TestScope]:');
+ console.log('(each SpecSuites and their stylesheets in the chosen SpecSuitesList in a cleared document)');
+
+ // @TODO: Think about useful naming and use/propagate it through test writers
+
+ // FIXTURE - Uses SPEC SUITES which contain a Set of SUITES:
+ // - 1. UNIT TESTs (test interface of component)
+ // - 2. INTEGRATION TESTs (test combination of tested components)
+ // - 3. REGRESSION TESTs (run tests every time the project code changes)
+ // other words: SPEC RUNNER, TEST HARNESS, SPEC SUITE, SPEC
+ var styles, htmlStyles, i, j;
+ for(i=0; i<usedTestScope.length; i++) {
+ console.log(' - ' + usedTestScope[i]);
+ }
+ for(i=0; i<namedSpecSuitesList.length; i++) {
+ styles = namedSpecSuitesList[i].styles;
+ htmlStyles = '';
+ for(j=0; j<styles.length; j++){
+ // @TODO: enable pre-compilation for less/stylus/sass/etc... files
+ htmlStyles += '<link name="suite" rel="stylesheet" type="text/css" href="' + styles[j] + '">';
+ }
+ namedSpecSuitesList[i].styles = htmlStyles;
+ }
+
+ // EXECUTE SPEC RUNNER ENGINE
+ console.log('================================ START TESTING ================================');
+ console.log('');
+
+ // @TODO: Isolate Suite Execution into iFRAMEs or similar!!!
+ for(var i=0; i<namedSpecSuitesList.length; i++) {
+ $('head').append(namedSpecSuitesList[i].styles);
+ // LOAD & RUN SPEC SUITES
+ require(namedSpecSuitesList[i].suites, SpecSuitesExecutioner(jasmine));
+ $('head > link[name="suite"]').remove();
+ }
+
+ });
+ </script>
</body>
</html>
View
175 tasks/lib/index.js
@@ -32,74 +32,131 @@
* CUSTOMIZE - module interface, internals & initialization
\*----------------------------------------------------------------------*/
var
-
// General Testem config options
options = config.options,
+
+ // test page global script tags
+ globalScripts = config.globalScripts,
+
+ // test page favicon
+ favicon = config.favicon,
+
+ // test page cssfile
+ cssfile = config.cssfile,
+
+ // requirejs environment configuiration file specification Harness Init Script
+ testemStarter = config.testemStarter,
// all available spec suites
- SpecSuiteSets = config.SpecSuiteSets,
+ specSuitesListsSet = config.specSuitesListsSet,
+
+ // chosen TestScope
+ adaptedTestScope = config.TestScope.length ? config.TestScope : specSuitesListsSet.DEFAULT || [],
// currently used subset of spec suites
- TestScope = config.TestScope.length ? config.TestScope : SpecSuiteSets.Default,
+ specSuitesList = (function buildSpecSuitesList (adaptedTestScope) {
+ function errorMissingSpec(name) {
+ throw new Error('\n namedSpecSuitesList: "' + name + '" is not specified in "Gruntfile.js".\n' +
+ ' Please specify it, if you want to use it.\n For help, type in: "grunt --help"\n');
+ }
+ function errorBadSpec(name) {
+ throw new Error('\n namedSpecSuitesList: "' + name + '" is wrongly specified.\n Please use "grunt --help" for help.\n');
+ }
+ function isValidSpecSuites(parentScopeName, content) {
+ var j, tmp;
+ if( typeof content.styles !== 'undefined' &&
+ typeof content.suites !== 'undefined' &&
+ content.styles instanceof Array &&
+ content.suites instanceof Array ) {
+ for(j=0, tmp = content.styles; j<tmp.length; j++) {
+ if(typeof tmp[j] !== 'string') { errorBadSpec(parentScopeName); }
+ }
+ for(j=0, tmp = content.suites; j<tmp.length; j++) {
+ if(typeof tmp[j] !== 'string') { errorBadSpec(parentScopeName); }
+ }
+ } else {
+ errorBadSpec(parentScopeName);
+ }
+ return true;
+ }
+ return (function validateAndBuild (specSuitesList, processedTestScope, parenScopeName, TestScope) {
+ for(var k=0, content; k<TestScope.length; k++) {
+ content = TestScope[k];
+ if(typeof content === 'string') {
+ var scopeName = content;
+ if(!processedTestScope[scopeName]) {
+ var subTestScope;
+ processedTestScope[scopeName] = true;
+ subTestScope = specSuitesListsSet[scopeName];
+ if(typeof subTestScope === 'undefined') {
+ errorMissingSpec(scopeName);
+ } else if(subTestScope instanceof Array) {
+ validateAndBuild(specSuitesList, processedTestScope, scopeName, subTestScope);
+ } else {
+ errorBadSpec(scopeName);
+ }
+ }
+ } else if (isValidSpecSuites(parenScopeName, content)) {
+ var SpecSuites = content;
+ specSuitesList.push(SpecSuites);
+ } else {
+ throw new Error('Unexpected Error - Please contact package owner' + JSON.stringify(content));
+ }
+ }
+ return specSuitesList;
+ })([], {}, 'Given TestScope', adaptedTestScope);
+ })(adaptedTestScope),
+
+
// temp storage for testem config file
_tmpTestemConfDir = _path.join(__dirname, '/_tmpTestemConfDir'),
- // path to testem executable
+ // name of testem executable
testemEXE = 'testem',
- //
- testemPATH = (function () {
+ // path to testem executable
+ testemPATH = (function calculatePath () {
var baseDir = _path.join(process.cwd(), '/node_modules/');
-
if (_fs.existsSync(_path.join(baseDir, '.bin/testem'))) {
return _path.join(baseDir, '.bin/');
- }
-
- if (_fs.existsSync(_path.join(baseDir, 'grunt-requirejs-testem/node_modules/.bin/testem'))) {
+ } else if (_fs.existsSync(_path.join(baseDir, 'grunt-requirejs-testem/node_modules/.bin/testem'))) {
return _path.join(baseDir, 'grunt-requirejs-testem/node_modules/.bin/');
+ } else {
+ throw 'Could not locate testem executable';
}
-
- throw 'Could not locate testem executable';
})(),
+ // command to start "testem"
testemCMD = _path.join(testemPATH, testemEXE),
// dynamically generated testem config file
testemJSON = {
- test_page: 'SuitesRunner.mustache',
- routes: {
+ test_page : 'SuitesRunner.mustache',
+ routes : {
'/SuitesRunner.mustache' : _path.join(__dirname, '/SuitesRunner.mustache'),
'/SuitesRunner.js' : _path.join(__dirname, '/SuitesRunner.js')
},
- SSS: (function () {
- var i, j, k, results = [];
-
- for (i = 0; i < TestScope.length; ++i) {
- var tmp = { };
- tmp.name = TestScope[i];
- tmp.specSuiteSet = [];
- var tempSSS = SpecSuiteSets[tmp.name];
-
- for(j = 0; j < tempSSS.length; ++j) {
- var tempSS = tempSSS[j];
- var SpecSuite = { styles: [], suites: [] };
-
- for(k = 0; k < tempSS.styles.length; ++k) {
- SpecSuite.styles.push(_path.join(options.baseUrl, tempSS.styles[k]));
- }
-
- for(k = 0; k < tempSS.suites.length; ++k) {
- SpecSuite.suites.push(_path.join(options.baseUrl, tempSS.suites[k]));
- }
-
- tmp.specSuiteSet.push(SpecSuite);
+ favicon : favicon,
+ cssfile : cssfile,
+ globalScripts : globalScripts,
+ testemStarter : testemStarter,
+ usedTestScope : adaptedTestScope,
+ namedSpecSuitesList : (function (namedSpecSuitesList) {
+ var j, k, adaptedNamedSpecSuitesList = [];
+ for(j = 0; j < namedSpecSuitesList.length; ++j) {
+ var namedSpecSuites = namedSpecSuitesList[j];
+ var ADAPTEDnamedSpecSuites = { styles: [], suites: [] };
+ for(k = 0; k < namedSpecSuites.styles.length; ++k) {
+ ADAPTEDnamedSpecSuites.styles.push(_path.join(options.baseUrl, namedSpecSuites.styles[k]));
}
- results.push(tmp);
+ for(k = 0; k < namedSpecSuites.suites.length; ++k) {
+ ADAPTEDnamedSpecSuites.suites.push(_path.join(options.baseUrl, namedSpecSuites.suites[k]));
+ }
+ adaptedNamedSpecSuitesList.push(ADAPTEDnamedSpecSuites);
}
- return results;
- }()),
-
+ return adaptedNamedSpecSuitesList;
+ })(specSuitesList),
launch_in_dev : options.launchDev,
launch_in_ci : options.launchCI,
timeout : options.timeout,
@@ -116,33 +173,31 @@
testemConfig = ' -f ' + _path.join(_tmpTestemConfDir, '/testem.json'),
// specify operating system related command to start TEST'EM in a new terminal window
- // , commands = { // 'terminal' command used with 'options' which will start testem in a new window
- // // 'linux' : {terminal:'gnome-terminal', options: ['-e', 'node '+testemCMD+' '+testemConfig]},
- // 'linux': {terminal: testemCMD , options: [testemConfig]},
- // // 'linux' : {terminal:'gnome-terminal', options: ['-e', 'node '+testemCMD+' '+testemConfig]},
- // // 'darwin': {terminal:'open' , options: ['-a', 'Terminal.app', testemCMD, '--args', testemConfig]},
- // 'darwin': {terminal: testemCMD , options: [testemConfig]},
- // 'win32' : {terminal:'start' , options: ['cmd','/c', 'node '+testemCMD+' '+testemConfig]}
- // }
-
- /*
- #!/bin/sh
- /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal ~/termfiles/foo.term 2>/dev/null
-
- open -a Terminal.app /opt/local/bin/node --args /home/testuser/workspace/testproject/bin/testem.js -f /home/testuser/workspace/testproject/testem.json"
-
- */
commands = { // 'terminal' command used with 'options' which will start testem in a new window
'linux' : 'gnome-terminal -e "' + testemCMD + testemConfig + '"',
'darwin': 'open -a Terminal.app ' + testemCMD + ' --args' + testemConfig,
'win32' : 'start /D "' + testemPATH + '" cmd /c "' + testemEXE + testemConfig + '"'
// 'win32' : 'start cmd /C "' + testemCMD + testemConfig + '"'
+ // // 'linux' : {terminal:'gnome-terminal', options: ['-e', 'node '+testemCMD+' '+testemConfig]},
+ // 'linux': {terminal: testemCMD , options: [testemConfig]},
+ // // 'linux' : {terminal:'gnome-terminal', options: ['-e', 'node '+testemCMD+' '+testemConfig]},
+ // // 'darwin': {terminal:'open' , options: ['-a', 'Terminal.app', testemCMD, '--args', testemConfig]},
+ // 'darwin': {terminal: testemCMD , options: [testemConfig]},
+ // 'win32' : {terminal:'start' , options: ['cmd','/c', 'node '+testemCMD+' '+testemConfig]}
},
+ // @TODO: Get WINDOWS and MAC OSX commands right!
+ /*
+ #!/bin/sh
+ /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal ~/termfiles/foo.term 2>/dev/null
+ open -a Terminal.app /opt/local/bin/node --args /home/testuser/workspace/testproject/bin/testem.js -f /home/testuser/workspace/testproject/testem.json"
+ i have a problem with running a command: "open -a Terminal.app /opt/local/bin/node --args /home/testuser/workspace/testproject/bin/testem.js -f /home/testuser/workspace/testproject/testem.json"
+ */
+
// Testem Launcher
run = function (command) {
if (command) {
- var child = _childProcess.exec(command);
+ _childProcess.exec(command);
} else {
console.log('TESTEM Launcher hasn\'t yet been fully implemented for ' + os + '/' + _os.type());
}
@@ -153,8 +208,8 @@
var files = [];
if( _fs.existsSync(path) ) {
files = _fs.readdirSync(path);
- files.forEach(function(file,index){
- var curPath = _path.join(path, "/", file);
+ files.forEach(function(file/*,index*/){
+ var curPath = _path.join(path, '/', file);
if(_fs.statSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
@@ -175,7 +230,7 @@
return ['(Running TEST\'EM on "' + os + '")', 'TEST\'EM Executable not found.', 'Please report bug.'];
}
var command = commands[os];
- return ['(Running TEST\'EM on "' + os + '")', 'System under Development [SUD]', TestScope, command];
+ return ['(Running TEST\'EM on "' + os + '")', 'System under Development [SUD]', adaptedTestScope, command];
};
/*--------------------------------------------------------------------------*\
View
75 tasks/requirejs_testem.js
@@ -6,60 +6,57 @@
* Licensed under the MIT license.
*/
-'use strict';
-
-module.exports = function(grunt) {
-
- var description = 'Be able to run "grunt testem:NamedSpecSuiteSet" in order to have regression testing while you develop.' +
+(function() {
+ 'use strict';
+ module.exports = function(grunt) {
+ // @TODO: adapt help to current state of this grunt plugin
+ var description = 'Be able to run "grunt testem:NamedSpecSuitesList2:NamedSpecSuitesList1" or just "grunt testem:NamedSpecSuitesList2"' +
+ '\nin order to have regression testing while you develop.' +
'\n\nThis task starts TEST\'EM in new console window for realtime testing.' +
- '\nAvailable "NamedSpecSuiteSets" are those, which are configured in the options for "requirejs_testem", ' +
+ '\nAvailable "NamedSpecSuitesLists" are those, which are configured in the options for "requirejs_testem", ' +
'as defined in the "grunt.initConfig(object)"' +
'\n\nEXAMPLE:' +
'\n--------' +
'\n grunt.initConfig({ ...' +
- '\n requirejs_testem: { SpecSuiteSets: {' +
- '\n mySpecSuiteSet1: [{ styles: [ ... ], suites: [...]}, {styles: [...], suites: [...]}, ...],' +
- '\n mySpecSuiteSet2: [{ styles: [ ... ], suites: [...]}, {styles: [...], suites: [...]}, ...],' +
- '\n Default: [mySpecSuiteSet1, mySpecSuiteSet2]' +
+ '\n requirejs_testem: { NamedSpecSuitesListsSet: {' +
+ '\n NamedSpecSuitesList1: [{ styles: [ ... ], suites: [...]}, {styles: [...], suites: [...]}, ...],' +
+ '\n NamedSpecSuitesList2: [{ styles: [ ... ], suites: [...]}, {styles: [...], suites: [...]}, ...],' +
+ '\n Default: [NamedSpecSuitesList1, NamedSpecSuitesList2]' +
'\n } ...' +
'\n\nUSAGE:' +
'\n------' +
- '\n - "grunt requirejs_testem" (same as "grunt requirejs_testem:Default" and will run all listed "NamedSpecSuiteSets")\n' +
- '\n - "grunt requirejs_testem:mySpecSuiteSet2" (will run the named SpecSuite Set "mySpecSuiteSet2")\n';
+ '\n - "grunt requirejs_testem" (same as "grunt requirejs_testem:Default" and will run all listed "NamedSpecSuitesLists")\n' +
+ '\n - "grunt requirejs_testem:NamedSpecSuitesList2"' +
+ '\n (will run the named collection "NamedSpecSuitesList2", where each SpecSuites in that collection and their stylesheets will run in a clean document)\n';
grunt.task.registerTask('requirejs_testem', description, function () {
- // Merge task-specific and/or target-specific options with these defaults.
- // => thus, set these optnpmions as defaults, if projects Gruntfile.js doesnt provide values for them.
- // var options = this.options({
- // testPage : 'fixture123/SuitesRunner.mustache',
- // SUTroot : '../app2/', // relative to "testPage"
- // launchDev : [],
- // launchCI : ['Chrome', 'Firefox'],
- // timeout : 1000,
- // onStart : '', // setUp TestEnvironment
- // beforeTests : '',
- // afterTests : '',
- // onExit : '' // cleanUp TestEnvironment
- // });
+
+ var // SET DEFAULTS
+ // @TODO: think about useful defaults
+ options = grunt.config(this.name).options || 800,
+ favicon = grunt.config(this.name).favicon,
+ cssfile = grunt.config(this.name).cssfile,
+ globalScripts = grunt.config(this.name).globalScripts,
+ testemStarter = grunt.config(this.name).testemStarter,
+ specSuitesListsSet = grunt.config(this.name).specSuitesListsSet,
+ TestScope = Array.prototype.slice.call(arguments, 0)
+ ;
var TestemLauncher = require('./lib');
var msg = TestemLauncher.init({
- 'options' : grunt.config(this.name).options,
- 'SpecSuiteSets' : grunt.config(this.name).SpecSuiteSets,
- 'TestScope' : Array.prototype.slice.call(arguments, 0)
+ 'options' : options,
+ 'favicon' : favicon,
+ 'cssfile' : cssfile,
+ 'globalScripts' : globalScripts,
+ 'testemStarter' : testemStarter,
+ 'specSuitesListsSet' : specSuitesListsSet,
+ 'TestScope' : TestScope
});
grunt.log.writeln(msg[0]);
// grunt.task.run('bar', 'baz');
grunt.log.subhead(msg[1]);
grunt.log.ok(JSON.stringify(msg[2]));
- grunt.log.writeln('\nrunning:\n' + msg[3] + "\n...\n");
- });
-};
-
-/*
-#!/bin/sh
-/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal ~/termfiles/foo.term 2>/dev/null
-
-i have a problem with running a command: "open -a Terminal.app /opt/local/bin/node --args /home/testuser/workspace/testproject/bin/testem.js -f /home/testuser/workspace/testproject/testem.json"
-
-*/
+ grunt.log.writeln('\nrunning:\n' + msg[3] + '\n...\n');
+ });
+ };
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.