├── .gitignore ├── .npmignore ├── .jscsrc ├── lib ├── index.js ├── adapter.js └── framework.js ├── test ├── systemWithBaseURL.conf.js ├── systemWithAbsolutePath.conf.js ├── system.conf.js ├── adapter.spec.js └── framework.spec.js ├── .travis.yml ├── .jshintrc ├── karma.conf.js ├── LICENSE ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .* 2 | test 3 | examples 4 | 5 | karma.conf.js 6 | TODO.md -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "google", 3 | "maximumLineLength": 120, 4 | "esnext": true 5 | } -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'framework:systemjs': ['factory', require('./framework.js')] 3 | }; -------------------------------------------------------------------------------- /test/systemWithBaseURL.conf.js: -------------------------------------------------------------------------------- 1 | // Used for testing config loading 2 | System.config({ 3 | baseURL: "lib", 4 | transpiler: 'plugin-babel' 5 | }); -------------------------------------------------------------------------------- /test/systemWithAbsolutePath.conf.js: -------------------------------------------------------------------------------- 1 | System.config({ 2 | baseURL: '/app', 3 | map: { 4 | 'module-a': 'to-actual-src.js', 5 | 'jquery': '/thirdparty/jquery.js', 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | sudo: false 4 | 5 | node_js: 6 | - "0.12" 7 | - "0.10" 8 | - "iojs" 9 | 10 | before_script: 11 | - export DISPLAY=:99.0 12 | - sh -e /etc/init.d/xvfb start -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "globals": { 6 | "jasmine": false, 7 | "describe": false, 8 | "it": false, 9 | "beforeEach": false, 10 | "expect": false, 11 | "spyOn": false 12 | } 13 | } -------------------------------------------------------------------------------- /test/system.conf.js: -------------------------------------------------------------------------------- 1 | // Used for testing config loading 2 | System.config({ 3 | transpiler: 'plugin-babel', 4 | paths: { 5 | 'module-a': 'to-actual-src.js' 6 | }, 7 | meta: { 8 | 'module-b': { 9 | deps: ['fromConfigFile'] 10 | } 11 | } 12 | }); -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = function(config) { 3 | config.set({ 4 | plugins: ['karma-firefox-launcher', 'karma-phantomjs-launcher', 'karma-jasmine'], 5 | 6 | frameworks: ['jasmine'], 7 | 8 | files: ['lib/adapter.js', 'test/adapter.spec.js'], 9 | 10 | browsers: ['Firefox', 'PhantomJS'], 11 | 12 | autoWatch: true 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jason Stone (rolaveric@gmail.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "karma-systemjs", 3 | "version": "0.16.0", 4 | "description": "A Karma plugin. Adapter for SystemJS module loader.", 5 | "main": "lib/index.js", 6 | "scripts": { 7 | "test": "jasmine-node ./test/framework.spec.js && karma start karma.conf.js --single-run" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/rolaveric/karma-systemjs.git" 12 | }, 13 | "keywords": [ 14 | "karma-plugin", 15 | "karma-adapter", 16 | "systemjs" 17 | ], 18 | "author": "Jason Stone ", 19 | "contributors": "Kendrick Burson ", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/rolaveric/karma-systemjs/issues" 23 | }, 24 | "homepage": "https://github.com/rolaveric/karma-systemjs", 25 | "dependencies": { 26 | "lodash": "^4.16.2", 27 | "minimatch": "^3.0.0" 28 | }, 29 | "devDependencies": { 30 | "es6-module-loader": "^0.17.11", 31 | "jasmine-core": "^2.3.4", 32 | "jasmine-node": "^1.14.5", 33 | "karma": "^1.3.0", 34 | "karma-firefox-launcher": "^1.0.0", 35 | "karma-jasmine": "^1.0.2", 36 | "karma-phantomjs-launcher": "^1.0.0", 37 | "phantomjs-polyfill": "0.0.2", 38 | "phantomjs-prebuilt": "2.1.12", 39 | "plugin-typescript": "^5.1.2", 40 | "systemjs": "^0.19.27", 41 | "systemjs-plugin-babel": "0.0.15", 42 | "traceur": "^0.0.111" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/adapter.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /* jscs: disable disallowMultipleVarDecl */ 3 | describe('karmaSystemjsAdapter()', function() { 4 | var karma, System, Promise, promiseSpy, adapter; 5 | beforeEach(function() { 6 | karma = { 7 | start: jasmine.createSpy('start'), 8 | config: { 9 | systemjs: { 10 | importPatterns: [] 11 | } 12 | }, 13 | files: {} 14 | }; 15 | promiseSpy = { 16 | then: jasmine.createSpy('then').and.callFake(function() { 17 | return promiseSpy; 18 | }) 19 | }; 20 | System = { 21 | baseURL: '/base/app/', 22 | 'import': jasmine.createSpy('import').and.returnValue(promiseSpy), 23 | config: jasmine.createSpy('config') 24 | }; 25 | Promise = { 26 | all: jasmine.createSpy('all').and.returnValue(promiseSpy), 27 | resolve: jasmine.createSpy('resolve').and.returnValue(promiseSpy) 28 | }; 29 | adapter = window.karmaSystemjsAdapter; 30 | }); 31 | 32 | describe('getModuleNameFromPath()', function() { 33 | 34 | it('Removes baseURL prefix', function() { 35 | expect(adapter.getModuleNameFromPath('/base/app/lib/include.js', System.baseURL, System)).toBe('lib/include.js'); 36 | }); 37 | 38 | it('Removes .js extension if System.defaultJSExtensions is true', function() { 39 | System.defaultJSExtensions = true; 40 | expect(adapter.getModuleNameFromPath('/base/app/lib/include.js', System.baseURL, System)).toBe('lib/include'); 41 | }); 42 | }); 43 | 44 | describe('getMatchingModulesToImport()', function() { 45 | 46 | it('Filters out filepaths which match a given regexp and returns their moduleName', function() { 47 | var files = { 48 | '/base/app/lib/include.js': 1, 49 | '/base/app/src/thing.js': 1, 50 | '/base/app/src/thing.spec.js': 1 51 | }; 52 | var testFileRegexp = /^\/base\/.*\.spec\.js/; 53 | expect(adapter.getMatchingModulesToImport(files, testFileRegexp, System)).toEqual([ 54 | 'src/thing.spec.js' 55 | ]); 56 | }); 57 | }); 58 | 59 | describe('parallelImportFiles()', function() { 60 | 61 | it('Imports all matching files in parallel', function() { 62 | var files = {}; 63 | var testFileRegexps = [/^\/base\/.*\.spec\.js/]; 64 | spyOn(adapter, 'getMatchingModulesToImport').and.returnValue([ 65 | 'src/first.spec.js', 66 | 'src/second.spec.js' 67 | ]); 68 | expect(adapter.parallelImportFiles(System, Promise, files, testFileRegexps)).toBe(promiseSpy); 69 | expect(Promise.all).toHaveBeenCalledWith([promiseSpy, promiseSpy]); 70 | expect(System.import).toHaveBeenCalledWith('src/first.spec.js'); 71 | expect(System.import).toHaveBeenCalledWith('src/second.spec.js'); 72 | }); 73 | }); 74 | 75 | describe('chainImport()', function() { 76 | 77 | it('Chains System.import() to a promise when it resolves', function() { 78 | expect(adapter.chainImport(promiseSpy, 'moduleName', System)).toBe(promiseSpy); 79 | expect(promiseSpy.then.calls.argsFor(0)[0]()).toBe(promiseSpy); 80 | expect(System.import).toHaveBeenCalledWith('moduleName'); 81 | }); 82 | }); 83 | 84 | describe('sequentialImportFiles()', function() { 85 | 86 | it('Imports all matching files in sequence', function() { 87 | var files = {}; 88 | var testFileRegexps = [/^\/base\/.*\.spec\.js/]; 89 | spyOn(adapter, 'getMatchingModulesToImport').and.returnValue([ 90 | 'src/first.spec.js', 91 | 'src/second.spec.js' 92 | ]); 93 | expect(adapter.sequentialImportFiles(System, Promise, files, testFileRegexps)).toBe(promiseSpy); 94 | 95 | // Initial State: System.import has not yet been called until the first promise resolves 96 | expect(System.import).not.toHaveBeenCalled(); 97 | 98 | // First promise resolves: Only first module imported 99 | expect(promiseSpy.then.calls.argsFor(0)[0]()).toBe(promiseSpy); 100 | expect(System.import).toHaveBeenCalledWith('src/first.spec.js'); 101 | expect(System.import).not.toHaveBeenCalledWith('src/second.spec.js'); 102 | 103 | // Second promise resolves: Second module imported 104 | expect(promiseSpy.then.calls.argsFor(1)[0]()).toBe(promiseSpy); 105 | expect(System.import).toHaveBeenCalledWith('src/second.spec.js'); 106 | }); 107 | }); 108 | 109 | describe('importFiles()', function() { 110 | 111 | it('Calls sequentialImportFiles() if strictImportSequence is true', function() { 112 | spyOn(adapter, 'sequentialImportFiles'); 113 | adapter.importFiles(System, Promise, {}, [], true); 114 | expect(adapter.sequentialImportFiles).toHaveBeenCalledWith(System, Promise, {}, []); 115 | }); 116 | 117 | it('Calls parallelImportFiles() if strictImportSequence is false', function() { 118 | spyOn(adapter, 'parallelImportFiles'); 119 | adapter.importFiles(System, Promise, {}, [], false); 120 | expect(adapter.parallelImportFiles).toHaveBeenCalledWith(System, Promise, {}, []); 121 | }); 122 | }); 123 | 124 | describe('updateBaseURL()', function() { 125 | it('Adds "/base" to the start of System.baseURL, after calling System.config()', function() { 126 | expect(adapter.updateBaseURL('app')).toBe('/base/app'); 127 | }); 128 | 129 | it('Adds "/base" to the start of System.baseURL, after calling System.config()', function() { 130 | expect(adapter.updateBaseURL('/app/')).toBe('/base/app/'); 131 | }); 132 | 133 | it('Replaces "./" with "/base/"', function() { 134 | expect(adapter.updateBaseURL('./')).toBe('/base/'); 135 | expect(adapter.updateBaseURL('./app/')).toBe('/base/app/'); 136 | }); 137 | }); 138 | 139 | describe('run()', function() { 140 | 141 | it('Stops karma from loading automatically by defining karma.loaded', function() { 142 | karma.loaded = 123; 143 | adapter.run(karma, System, Promise); 144 | expect(typeof karma.loaded).toBe('function'); 145 | }); 146 | 147 | it('Passes in systemjs config to System.config(), if set', function() { 148 | karma.config.systemjs.config = '{"key": "value"}'; 149 | adapter.run(karma, System, Promise); 150 | karma.loaded(); 151 | expect(System.config).toHaveBeenCalledWith({key: 'value', baseURL: '/base/'}); 152 | }); 153 | 154 | it('Only calls System.config() to set baseURL, if no config set', function() { 155 | karma.config.systemjs.config = null; 156 | adapter.run(karma, System, Promise); 157 | karma.loaded(); 158 | expect(System.config).toHaveBeenCalledWith({baseURL: '/base/'}); 159 | }); 160 | 161 | it('Adds "/base" to the start of System.baseURL, after calling System.config()', function() { 162 | System.config.and.callFake(function(config) { 163 | System.baseURL = config.baseURL; 164 | }); 165 | karma.config.systemjs.config = JSON.stringify({baseURL: '/app/'}); 166 | adapter.run(karma, System, Promise); 167 | karma.loaded(); 168 | expect(System.baseURL).toBe('/base/app/'); 169 | }); 170 | 171 | it('Imports karma.files that match one of the importPatterns', function() { 172 | karma.config.systemjs.importPatterns = ['test']; 173 | karma.config.systemjs.strictImportSequence = true; 174 | karma.files = {a: true, b: true, c: true}; 175 | spyOn(adapter, 'importFiles').and.returnValue(promiseSpy); 176 | adapter.run(karma, System, Promise); 177 | karma.loaded(); 178 | expect(adapter.importFiles).toHaveBeenCalledWith(System, Promise, karma.files, [/test/], true); 179 | expect(promiseSpy.then).toHaveBeenCalled(); 180 | }); 181 | 182 | it('Starts karma once all import promises have resolved', function() { 183 | adapter.run(karma, System, Promise); 184 | karma.loaded(); 185 | expect(karma.start).not.toHaveBeenCalled(); 186 | promiseSpy.then.calls.argsFor(0)[0](); 187 | expect(karma.start).toHaveBeenCalled(); 188 | }); 189 | }); 190 | 191 | describe('decorateErrorWithHints()', function() { 192 | 193 | it('Converts error objects to strings', function() { 194 | expect(typeof adapter.decorateErrorWithHints(new Error('test'), System)).toBe('string'); 195 | }); 196 | 197 | it('Adds hints for Not Found .es6 files', function() { 198 | var err = 'Error loading "app/module.es6" at /base/app/module.es6.js'; 199 | expect(adapter.decorateErrorWithHints(err, System)).toBe( 200 | 'Error loading "app/module.es6" at /base/app/module.es6.js' + 201 | '\nHint: If you use ".es6" as an extension, add this to your SystemJS paths config: {"*.es6": "*.es6"}' 202 | ); 203 | }); 204 | 205 | it('Adds hints for Illegal module names starting with /base/', function() { 206 | var err = new TypeError('Illegal module name "/base/lib/module"'); 207 | expect(adapter.decorateErrorWithHints(err, System)).toBe( 208 | 'TypeError: Illegal module name "/base/lib/module"' + 209 | '\nHint: Is the working directory different when you run karma?' + 210 | '\nYou may need to change the baseURL of your SystemJS config inside your karma config.' + 211 | '\nIt\'s currently checking "/base/app/"' + 212 | '\nNote: "/base/" is where karma serves files from.' 213 | ); 214 | }); 215 | }); 216 | }); -------------------------------------------------------------------------------- /lib/adapter.js: -------------------------------------------------------------------------------- 1 | (function(window) { 2 | 'use strict'; 3 | var adapter = { 4 | /** 5 | * Takes a file path and the baseURL and returns the module name 6 | * to pass to System.import() 7 | * @param filePath {string} 8 | * @param baseURL {string} 9 | * @param System {object} 10 | * @returns {string} 11 | */ 12 | getModuleNameFromPath: function(filePath, baseURL, System) { 13 | // Convert file paths to module name by stripping the baseURL and the ".js" extension 14 | if (System.defaultJSExtensions) { 15 | filePath = filePath.replace(/\.js$/, ''); 16 | } 17 | return filePath 18 | .replace(new RegExp('^' + baseURL.replace('/', '\/')), ''); 19 | }, 20 | 21 | /** 22 | * Returns the modules names for files that match a given import RegExp. 23 | * @param filePaths {object} 24 | * @param importRegexp {object} 25 | * @param System {object} 26 | * @returns {string[]} 27 | */ 28 | getMatchingModulesToImport: function(filePaths, importRegexp, System) { 29 | var moduleNames = []; 30 | for (var filePath in filePaths) { 31 | if (filePaths.hasOwnProperty(filePath) && importRegexp.test(filePath)) { 32 | moduleNames.push(adapter.getModuleNameFromPath(filePath, System.baseURL, System)); 33 | } 34 | } 35 | return moduleNames; 36 | }, 37 | 38 | /** 39 | * Handles calling System.import() for files where each import is made in parallel, returning a single promise 40 | * that resolves once all imports have completed. 41 | * @param System {object} 42 | * @param Promise {object} 43 | * @param files {object} 44 | * @param importRegexps {object[]} 45 | * @returns {promise} 46 | */ 47 | parallelImportFiles: function(System, Promise, files, importRegexps) { 48 | // Run all imports in parallel 49 | var importPromises = []; 50 | for (var x = 0; x < importRegexps.length; x++) { 51 | var moduleNames = adapter.getMatchingModulesToImport(files, importRegexps[x], System); 52 | for (var i = 0; i < moduleNames.length; i++) { 53 | importPromises.push(System.import(moduleNames[i])); 54 | } 55 | } 56 | return Promise.all(importPromises); 57 | }, 58 | 59 | /** 60 | * Chains a System.import() call onto an existing promise, returning the new promise. 61 | * @param promise {promise} 62 | * @param moduleName {string} 63 | * @param System {object} 64 | * @returns {promise} 65 | */ 66 | chainImport: function(promise, moduleName, System) { 67 | return promise.then(function() { 68 | return System.import(moduleName); 69 | }); 70 | }, 71 | 72 | /** 73 | * Handles calling System.import() for files where each import promise is chained into the next import promise, 74 | * returning a promise that resolves once the last import has completed. 75 | * @param System {object} 76 | * @param Promise {object} 77 | * @param files {object} 78 | * @param importRegexps {object[]} 79 | * @returns {promise} 80 | */ 81 | sequentialImportFiles: function(System, Promise, files, importRegexps) { 82 | // Chain import promises to maintain sequence 83 | var promise = Promise.resolve(); 84 | for (var x = 0; x < importRegexps.length; x++) { 85 | var moduleNames = adapter.getMatchingModulesToImport(files, importRegexps[x], System); 86 | for (var i = 0; i < moduleNames.length; i++) { 87 | promise = adapter.chainImport(promise, moduleNames[i], System); 88 | } 89 | } 90 | return promise; 91 | }, 92 | 93 | /** 94 | * Calls System.import on all the files that match one of the importPatterns. 95 | * Returns a single promise which resolves once all imports are complete. 96 | * @param System {object} 97 | * @param Promise {object} 98 | * @param files {object} key/value map of filePaths to change counters 99 | * @param importRegexps {RegExp[]} 100 | * @param [strictImportSequence=false] {boolean} If true, System.import calls are chained to preserve sequence. 101 | * @returns {promise} 102 | */ 103 | importFiles: function(System, Promise, files, importRegexps, strictImportSequence) { 104 | if (strictImportSequence) { 105 | return adapter.sequentialImportFiles(System, Promise, files, importRegexps) 106 | } else { 107 | return adapter.parallelImportFiles(System, Promise, files, importRegexps) 108 | } 109 | }, 110 | 111 | /** 112 | * Changes the 'baseURL' to include the '/base/' path that karma 113 | * serves files from. 114 | * @param originalBaseURL {string} 115 | * @returns {string} 116 | */ 117 | updateBaseURL: function(originalBaseURL) { 118 | if (!originalBaseURL) { 119 | return '/base/'; 120 | } else if (originalBaseURL.indexOf('./') === 0) { 121 | return originalBaseURL.replace('./', '/base/'); 122 | } else if (originalBaseURL.indexOf('/') !== 0) { 123 | return '/base/' + originalBaseURL; 124 | } else { 125 | return '/base' + originalBaseURL; 126 | } 127 | }, 128 | 129 | /** 130 | * Has SystemJS load each test suite, then starts Karma 131 | * @param karma {object} 132 | * @param System {object} 133 | * @param Promise {object} 134 | */ 135 | run: function(karma, System, Promise) { 136 | // Fail fast if any of the dependencies are undefined 137 | if (!karma) { 138 | (console.error || console.log)('Error: Not setup properly. window.__karma__ is undefined'); 139 | return; 140 | } 141 | if (!System) { 142 | (console.error || console.log)('Error: Not setup properly. window.System is undefined'); 143 | return; 144 | } 145 | if (!Promise) { 146 | (console.error || console.log)('Error: Not setup properly. window.Promise is undefined'); 147 | return; 148 | } 149 | 150 | // Stop karma from starting automatically on load 151 | karma.loaded = function() { 152 | 153 | // Load SystemJS configuration from karma config 154 | // And update baseURL with '/base', where Karma serves files from 155 | if (karma.config.systemjs.config) { 156 | // SystemJS config is converted to a JSON string by the framework 157 | // https://github.com/rolaveric/karma-systemjs/issues/44 158 | karma.config.systemjs.config = JSON.parse(karma.config.systemjs.config); 159 | 160 | karma.config.systemjs.config.baseURL = adapter.updateBaseURL(karma.config.systemjs.config.baseURL); 161 | System.config(karma.config.systemjs.config); 162 | 163 | // Exclude bundle configurations if useBundles option is not specified 164 | if (!karma.config.systemjs.useBundles) { 165 | System.bundles = []; 166 | } 167 | 168 | } else { 169 | System.config({baseURL: '/base/'}); 170 | } 171 | 172 | // Convert the 'importPatterns' into 'importRegexps' 173 | var importPatterns = karma.config.systemjs.importPatterns; 174 | var importRegexps = []; 175 | for (var x = 0; x < importPatterns.length; x++) { 176 | importRegexps.push(new RegExp(importPatterns[x])); 177 | } 178 | 179 | // Import each test suite using SystemJS 180 | var testSuitePromise; 181 | try { 182 | testSuitePromise = adapter.importFiles(System, Promise, karma.files, importRegexps, karma.config.systemjs.strictImportSequence); 183 | } catch (e) { 184 | karma.error(adapter.decorateErrorWithHints(e, System)); 185 | return; 186 | } 187 | 188 | // Once all imports are complete... 189 | testSuitePromise.then(function () { 190 | karma.start(); 191 | }, function (e) { 192 | karma.error(adapter.decorateErrorWithHints(e, System)); 193 | }); 194 | }; 195 | }, 196 | 197 | /** 198 | * Checks errors to see if they match known issues, and tries to decorate them 199 | * with hints on how to resolve them. 200 | * @param err {string} 201 | * @param System {object} 202 | * @returns {string} 203 | */ 204 | decorateErrorWithHints: function(err, System) { 205 | err = String(err); 206 | // Look for common issues in the error message, and try to add hints to them 207 | switch (true) { 208 | // Some people use ".es6" instead of ".js" for ES6 code 209 | case /^Error loading ".*\.es6" at .*\.es6\.js/.test(err): 210 | return err + '\nHint: If you use ".es6" as an extension, ' + 211 | 'add this to your SystemJS paths config: {"*.es6": "*.es6"}'; 212 | case /^TypeError: Illegal module name "\/base\//.test(err): 213 | return err + '\nHint: Is the working directory different when you run karma?' + 214 | '\nYou may need to change the baseURL of your SystemJS config inside your karma config.' + 215 | '\nIt\'s currently checking "' + System.baseURL + '"' + 216 | '\nNote: "/base/" is where karma serves files from.'; 217 | } 218 | 219 | return err; 220 | } 221 | }; 222 | 223 | if (window.System) { 224 | adapter.run(window.__karma__, window.System, window.Promise); 225 | } else { 226 | //if no System global, expose global for unit testing 227 | window.karmaSystemjsAdapter = adapter; 228 | } 229 | })(window); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/rolaveric/karma-systemjs.png?branch=master)](https://travis-ci.org/rolaveric/karma-systemjs) 2 | [![GitHub version](http://img.shields.io/github/tag/rolaveric/karma-systemjs.svg)](https://github.com/rolaveric/karma-systemjs) 3 | [![NPM version](http://img.shields.io/npm/v/karma-systemjs.svg)](https://npmjs.org/package/karma-systemjs) 4 | [![Downloads](http://img.shields.io/npm/dm/karma-systemjs.svg)](https://npmjs.org/package/karma-systemjs) 5 | # karma-systemjs 6 | [Karma](http://karma-runner.github.io/) plugin for using [SystemJS](https://github.com/systemjs/systemjs) as a module loader. 7 | 8 | `karma-systemjs` works by loading files with `System.import()` instead of including them with `