Skip to content

Commit a8cf78d

Browse files
authored
Merge pull request #341 from jakerella/fix-browserstack-testing
Fix browserstack testing
2 parents fe5c125 + 941db29 commit a8cf78d

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

browserstack-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
var config = require('./grunt-config-options');
33
config.onlyPaths = true;
4-
var urls = require('./test/build-version-urls')(config, 'latestInBranch', 'all');
4+
var urls = require('./test/build-version-urls')(config, 'latestInBranch', 'all', 'logging');
55

66
module.exports = {
77
"username": "jordankasper2",

test/add-tests.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
var i, l,
66
parts = document.location.search.match( /testFiles=([^&]+)/ ),
7+
ignore = document.location.search.match( /ignoreFiles=([^&]+)/ ),
78
testFiles = [
89
'core', // This will become: <script src='test-core.js'></script>
910
'data-match',
@@ -23,13 +24,29 @@
2324

2425
if ( parts && parts[1] ) {
2526
try {
26-
testFiles = JSON.parse( decodeURIComponent(parts[ 1 ]) ) || testFiles;
27+
var inputFiles = JSON.parse( decodeURIComponent(parts[ 1 ]) ) || null;
28+
if (inputFiles && inputFiles.length && inputFiles[0] !== 'all') {
29+
testFiles = inputFiles;
30+
}
2731
} catch(err) {
2832
console.warn('\n WARNING: Unable to parse the test modules you wanted:', err);
2933
testFiles = [];
3034
}
3135
}
3236

37+
if ( ignore && ignore[1] ) {
38+
try {
39+
var ignoreFiles = JSON.parse( decodeURIComponent(ignore[ 1 ]) ) || null;
40+
if (ignoreFiles && ignoreFiles.length) {
41+
testFiles = testFiles.filter(function(file) {
42+
return ignoreFiles.indexOf(file) === -1;
43+
});
44+
}
45+
} catch(err) {
46+
console.warn('\n WARNING: Unable to parse the test modules you wanted to ignore:', err);
47+
}
48+
}
49+
3350
for ( i=0, l = testFiles.length; i<l; i++ ) {
3451
document.write( '<script src="test-' + testFiles[ i ] + '.js"></script>' );
3552
}

test/build-version-urls.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11

22
var PORT = 4000;
33

4-
module.exports = function buildVersionURLs(config, arg1, arg2, arg3) {
4+
module.exports = function buildVersionURLs(config, arg1, arg2, arg3, arg4) {
55

66
var gruntConfig = (config.get && config.get()) || config;
77

88
var i, l, url,
99
baseURL = 'http://localhost:' + PORT,
1010
versionUrls = [],
1111
testFiles = arg2 || null,
12+
ignoreFiles = arg3 || null,
1213
source = arg1 || 'all',
1314
versions = (gruntConfig.test[source] && gruntConfig.test[source].jQueryVersions) || [],
1415
file = (gruntConfig.test[source] && gruntConfig.test[source].file) || 'index.html';
1516

1617
if (arg1 === 'version' && arg2) {
1718
versions = [arg2];
1819
testFiles = (arg3) ? arg3 : null;
20+
ignoreFiles = (arg4) ? arg4 : null;
1921
}
2022

2123
if (testFiles) {
2224
testFiles = JSON.stringify(testFiles.split(/\,/));
2325
}
26+
if (ignoreFiles) {
27+
ignoreFiles = JSON.stringify(ignoreFiles.split(/\,/));
28+
}
2429

2530
for (i=0, l=versions.length; i<l; ++i) {
2631
if (arg1 === 'requirejs') {
27-
url = 'test/requirejs/' + file + '?jquery=' + versions[i] + '&testFiles=' + testFiles;
32+
url = 'test/requirejs/' + file + '?jquery=' + versions[i] + '&testFiles=' + testFiles + '&ignoreFiles=' + ignoreFiles;
2833
versionUrls.push( url );
2934
if (!config.onlyPaths) { url = baseURL + '/' + url; }
3035
} else {
31-
url = 'test/' + file + '?jquery=' + versions[i] + '&testFiles=' + testFiles;
36+
url = 'test/' + file + '?jquery=' + versions[i] + '&testFiles=' + testFiles + '&ignoreFiles=' + ignoreFiles;
3237
if (!config.onlyPaths) { url = baseURL + '/' + url; }
3338
versionUrls.push( url );
3439
}

0 commit comments

Comments
 (0)