Skip to content

Commit

Permalink
fix(init): Make the requirejs config template normalize paths
Browse files Browse the repository at this point in the history
By removing the base path and file extension of files, this normalizes
files to be in a standard requirejs format and means mean sub dependencies
of the test files will not be loaded as-is. See
#513 (comment)
  • Loading branch information
lukeapage committed Jun 18, 2015
1 parent d83fab9 commit 54dcce3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions requirejs.config.tpl.coffee
@@ -1,9 +1,14 @@
allTestFiles = []
TEST_REGEXP = /(spec|test)(\.coffee)?(\.js)?$/i

# Get a list of all the test files to include
Object.keys(window.__karma__.files).forEach (file) ->
# Normalize paths to RequireJS module names.
allTestFiles.push file if TEST_REGEXP.test(file)

if TEST_REGEXP.test(file)
# Normalize paths to RequireJS module names.
# If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
# then do not normalize the paths
allTestFiles.push file.replace(/^\/base\/|\.js$/g, '')
return

require.config
Expand Down
6 changes: 5 additions & 1 deletion requirejs.config.tpl.js
@@ -1,10 +1,14 @@
var allTestFiles = [];
var TEST_REGEXP = /(spec|test)\.js$/i;

// Get a list of all the test files to include
Object.keys(window.__karma__.files).forEach(function(file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
allTestFiles.push(file);
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
// then do not normalize the paths
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '');
allTestFiles.push(normalizedTestModule);
}
});

Expand Down

0 comments on commit 54dcce3

Please sign in to comment.