Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Adding glob matching to the spec files from the config. Closes #29.
Browse files Browse the repository at this point in the history
  • Loading branch information
juliemr committed Aug 8, 2013
1 parent eb67a10 commit cb373c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 1 addition & 5 deletions conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ exports.config = {
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: [
'spec/findelements_spec.js',
'spec/lib_spec.js',
'spec/mockmodule_spec.js',
'spec/synchronize_spec.js',
'spec/testapp_spec.js'
'spec/*_spec.js',
],

// ----- Capabilities to be passed to the webdriver instance.
Expand Down
17 changes: 13 additions & 4 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var remote = require('selenium-webdriver/remote');
var minijn = require('minijasminenode');
var protractor = require('./protractor.js');
var SauceLabs = require('saucelabs');
var glob = require('glob');

var args = process.argv.slice(2);

Expand Down Expand Up @@ -69,13 +70,21 @@ var run = function() {
// 'specs/*.js'
// Probably want to use 'glob' for this, but consider the extra dependency.
var specs = config.specs;
var resolvedSpecs = [];
for (var i = 0; i < specs.length; ++i) {
specs[i] = path.resolve(process.cwd(), specs[i]);
if (!fs.existsSync(specs[i])) {
throw new Error('Test file ' + specs[i] + ' not found.');
var matches = glob.sync(specs[i]);
if (!matches.length) {
throw new Error('Test file ' + specs[i] + ' did not match any files.');
}
for (var j = 0; j < matches.length; ++j) {
resolvedSpecs.push(matches[j]);
}
// specs[i] = path.resolve(process.cwd(), specs[i]);
// if (!fs.existsSync(specs[i])) {
// throw new Error('Test file ' + specs[i] + ' not found.');
// }
}
minijn.addSpecs(specs);
minijn.addSpecs(resolvedSpecs);

if (config.sauceUser && config.sauceKey) {
config.capabilities.username = config.sauceUser;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"selenium-webdriver": ">2.32.1",
"minijasminenode": "~0.2.0",
"saucelabs": "~0.1.0",
"glob": ">=3.1.14",
"adm-zip": ">=0.4.2"
},
"devDependencies": {
Expand All @@ -32,5 +33,5 @@
"scripts": {
"test": "node lib/cli.js conf.js"
},
"version": "0.6.1"
"version": "0.6.2"
}

0 comments on commit cb373c9

Please sign in to comment.