-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): generate test-main.(js/coffee) for RequireJS projects
- Loading branch information
Showing
5 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
allTestFiles = [] | ||
TEST_REGEXP = /(spec|test)(\.coffee)?(\.js)?$/i | ||
pathToModule = (path) -> | ||
path.replace(/^\/base\//, "").replace(/\.js$/, "").replace(/\.cofee$/, "") | ||
|
||
Object.keys(window.__karma__.files).forEach (file) -> | ||
# Normalize paths to RequireJS module names. | ||
allTestFiles.push pathToModule(file) if TEST_REGEXP.test(file) | ||
return | ||
|
||
require.config | ||
# Karma serves files under /base, which is the basePath from your config file | ||
baseUrl: "/base" | ||
|
||
# dynamically load all test files | ||
deps: allTestFiles | ||
|
||
# we have to kickoff jasmine, as it is asynchronous | ||
callback: window.__karma__.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var allTestFiles = []; | ||
var TEST_REGEXP = /(spec|test)\.js$/i; | ||
|
||
var pathToModule = function(path) { | ||
return path.replace(/^\/base\//, '').replace(/\.js$/, ''); | ||
}; | ||
|
||
Object.keys(window.__karma__.files).forEach(function(file) { | ||
if (TEST_REGEXP.test(file)) { | ||
// Normalize paths to RequireJS module names. | ||
allTestFiles.push(pathToModule(file)); | ||
} | ||
}); | ||
|
||
require.config({ | ||
// Karma serves files under /base, which is the basePath from your config file | ||
baseUrl: '/base', | ||
|
||
// dynamically load all test files | ||
deps: allTestFiles, | ||
|
||
// we have to kickoff jasmine, as it is asynchronous | ||
callback: window.__karma__.start | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters