| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| var TEST_REGEXP = /(spec|test)\.js$/i; |
| var allTestFiles = []; |
| |
| var pathToRoot = window.__karma__.config.jssrc.replace(/[^\/]+/g,'..') + '\/..\/'; |
| |
| // 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. |
| // 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\//, pathToRoot); |
| normalizedTestModule = normalizedTestModule.replace(/\.js$/g, ''); |
| allTestFiles.push(normalizedTestModule); |
| } |
| }); |
| |
| require.config({ |
| // Karma serves files under /base, which is the basePath from your config file |
| baseUrl: '/base/' + window.__karma__.config.jssrc + '/scripts' |
| }); |
| |
| require(allTestFiles, function(){ |
| //if tests are loaded, start Karma: |
| window.__karma__.start() |
| }); |