Skip to content

Commit 72b67cc

Browse files
test(*): Switch karma from SystemJS to webpack
1 parent 10fb103 commit 72b67cc

25 files changed

+123
-97
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ node_js:
55
before_script:
66
- export DISPLAY=:99.0
77
- sh -e /etc/init.d/xvfb start
8-
- npm install -g karma
9-
- npm install -g typescript
10-
- npm install -g yarn
8+
- npm install -g yarn karma typescript
119
- ./nodeserver.sh > /dev/null &
1210

1311
matrix:
@@ -26,6 +24,7 @@ env:
2624

2725
script:
2826
- echo "CORE_BRANCH = x${CORE_BRANCH}x";
27+
# Fetch and build the ui-router-core branch from github, then install it
2928
- >
3029
if [ "x${CORE_BRANCH}x" != "xx" ] ; then
3130
git clone --depth=10 --branch="${CORE_BRANCH}" https://github.com/ui-router/core.git ui-router-core && pushd ui-router-core && yarn && popd && npm install ./ui-router-core ;
@@ -35,7 +34,7 @@ script:
3534
sudo: false
3635

3736
git:
38-
depth: 10
37+
depth: 3
3938

4039
notifications:
4140
slack: angularbuddies:b6leQM9gkBCW0S7MNDsELpqU

karma.conf.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,20 @@ function karmaServedFiles(ngVersion) {
1919
'test/angular/' + version + '/angular.js',
2020
'test/angular/' + version + '/angular-mocks.js',
2121
'test/angular/' + version + '/angular-animate.js',
22-
'test/util/ng1.systemjs.adapter.js'
2322
];
2423
}
2524

2625
var angularFiles = angular(ngVersion).map(function (pattern) {
2726
return { watched: false, included: true, nocache: true, pattern: pattern };
2827
});
2928

30-
var srcFiles = [
31-
{ watched: true, included: false, nocache: true, pattern: 'src/**/*.ts' },
32-
];
33-
34-
var testFiles = [
35-
{ watched: true, included: false, nocache: true, pattern: 'test/**/*.ts' },
36-
{ watched: true, included: false, nocache: true, pattern: 'test/**/*.js' }
37-
];
38-
39-
return [].concat(angularFiles).concat(srcFiles).concat(testFiles);
29+
return angularFiles.concat('test/index.js');
4030
}
4131

32+
var webpackConfig = require('./webpack.config.js');
33+
webpackConfig.entry = {};
34+
webpackConfig.plugins = [];
35+
4236
module.exports = function(config) {
4337
var ngVersion = config.ngversion || "1.5.0";
4438

@@ -63,29 +57,25 @@ module.exports = function(config) {
6357
// Chrome, ChromeCanary, Firefox, Opera, Safari, PhantomJS
6458
browsers: ['PhantomJS'],
6559

66-
frameworks: ['systemjs', 'jasmine'],
60+
frameworks: ['jasmine'],
6761

6862
plugins: [
69-
require('karma-systemjs'),
63+
require('karma-webpack'),
64+
require('karma-sourcemap-loader'),
7065
require('karma-jasmine'),
7166
require('karma-phantomjs-launcher'),
7267
require('karma-chrome-launcher')
7368
],
7469

70+
webpack: webpackConfig,
71+
7572
/* Files *available to be served* by karma, i.e., anything that will be require()'d */
7673
files: karmaServedFiles(ngVersion),
77-
exclude: [],
78-
systemjs: {
79-
// Set up systemjs paths
80-
configFile: 'karma.system.config.js',
81-
82-
files: [
83-
'src/**/*.ts',
84-
'node_modules/ui-router-core/lib/**/*'
85-
],
86-
87-
// karma-systemjs kludge: This is turned into a regexp and is the actual specs that are loaded
88-
testFileSuffix: "/test/\\S+Spec.[tj]s"
74+
75+
preprocessors: {
76+
'test/index.js': ['webpack', 'sourcemap'],
77+
'../src/ng1': ['webpack', 'sourcemap'],
8978
},
79+
9080
});
9181
};

karma.system.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
"karma-jasmine": "^1.0.2",
8383
"karma-phantomjs-launcher": "^1.0.2",
8484
"karma-script-launcher": "~0.1.0",
85+
"karma-sourcemap-loader": "^0.3.7",
8586
"karma-systemjs": "^0.7.2",
87+
"karma-webpack": "^1.8.0",
8688
"lodash": "^4.5.1",
8789
"remap-istanbul": "^0.6.3",
8890
"shelljs": "^0.7.0",

test/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// require all source files ending in "Spec" from the
2+
// current directory and all subdirectories
3+
4+
require('./util');
5+
6+
require('../src/ng1');
7+
8+
var testsContext = require.context(".", true, /Spec$/);
9+
testsContext.keys().forEach(testsContext);

test/ng1StateBuilderSpec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
/// <reference path='../node_modules/@types/angular/index.d.ts' />
2+
/// <reference path='../node_modules/@types/angular-mocks/index.d.ts' />
3+
/// <reference path='../node_modules/@types/jasmine/index.d.ts' />
4+
15
import {StateBuilder, StateMatcher, ng1ViewsBuilder} from "../src/ng1";
26
import {Resolvable} from "ui-router-core";
7+
declare var inject;
38

49
describe('Ng1 StateBuilder', function() {
510
var builder, matcher, urlMatcherFactoryProvider: any = {

test/resolveSpec.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import "./util/testUtilsNg1.js";
2-
declare var resolvedValue, resolvedError, caught;
1+
/// <reference path='../node_modules/@types/angular/index.d.ts' />
2+
/// <reference path='../node_modules/@types/angular-mocks/index.d.ts' />
3+
/// <reference path='../node_modules/@types/jasmine/index.d.ts' />
4+
/// <reference path='./util/matchers.types.d.ts' />
35

4-
import "./util/matchers.ts";
5-
6-
import {
7-
ResolveContext, State, PathNode, omit, pick, extend, forEach
8-
} from "../src/ng1";
6+
import * as angular from "angular";
7+
import "./util/matchers";
8+
import "./util/testUtilsNg1";
99

10+
declare var inject;
1011
import Spy = jasmine.Spy;
11-
import {Resolvable, services} from "ui-router-core";
12+
import "./util/matchers.ts";
13+
import { resolvedValue, resolvedError, caught } from './util/testUtilsNg1';
14+
import { ResolveContext, State, PathNode, omit, pick, extend, forEach } from "../src/ng1";
15+
import {Resolvable, services, StateDeclaration} from "ui-router-core";
1216

13-
let module = angular.mock.module;
17+
let module = angular['mock'].module;
1418
///////////////////////////////////////////////
1519

1620
var states, statesTree, statesMap: { [key:string]: State } = {};
@@ -433,7 +437,7 @@ describe("Integration: Resolvables system", () => {
433437
copy[name] = extend({}, stateDef);
434438
});
435439

436-
angular.forEach(copy, stateDef => {
440+
angular.forEach(copy, (stateDef: StateDeclaration) => {
437441
if (stateDef.name) $stateProvider.state(stateDef);
438442
});
439443
}));

test/stateDirectivesSpec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var module = angular.mock.module;
2-
var uiRouter = require("angular-ui-router");
2+
var uiRouter = require("../src/ng1");
3+
var obj = require('./util/testUtilsNg1').obj;
34

45
describe('uiStateRef', function() {
56

test/stateEventsSpec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
var module = angular.mock.module;
2-
var uiRouter = require("angular-ui-router");
2+
var uiRouter = require("../src/ng1");
33
var stateEvents = require("../src/ng1/legacy/stateEvents.ts");
4+
var decorateExceptionHandler = require("./util/testUtilsNg1").decorateExceptionHandler;
5+
var obj = require('./util/testUtilsNg1').obj;
6+
7+
var resolvedValue = require('./util/testUtilsNg1').resolvedValue;
8+
var resolvedError = require('./util/testUtilsNg1').resolvedError;
9+
var caught = require('./util/testUtilsNg1').caught;
410

511
describe('UI-Router v0.2.x $state events', function () {
612
var $injector, stateProvider;

test/stateFiltersSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var module = angular.mock.module;
2-
var uiRouter = require("angular-ui-router");
2+
var uiRouter = require("../src/ng1");
33

44
describe('isState filter', function() {
55
beforeEach(module('ui.router'));

0 commit comments

Comments
 (0)