Skip to content

Commit

Permalink
chore(tests): switch to webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBGod committed Sep 15, 2016
1 parent d3e4049 commit 590eb20
Show file tree
Hide file tree
Showing 23 changed files with 1,554 additions and 1,465 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Expand Up @@ -10,13 +10,12 @@ npm-debug.log
coverage
*.js
!karma.conf.js
!karma-test-shim.js
!webpack.test.js
!helpers.js
!spec-bundle.js
*.map
*.d.ts
typings
./providers
./core
./index.js

#################
## JetBrains
Expand All @@ -43,3 +42,4 @@ Desktop.ini

# Mac crap
.DS_Store

32 changes: 32 additions & 0 deletions helpers.js
@@ -0,0 +1,32 @@
/**
* taken from angular2-webpack-starter
*/
var path = require('path');

// Helper functions
var ROOT = path.resolve(__dirname, './');

function hasProcessFlag(flag) {
return process.argv.join('').indexOf(flag) > -1;
}

function isWebpackDevServer() {
return process.argv[1] && !! (/webpack-dev-server$/.exec(process.argv[1]));
}

function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [ROOT].concat(args));
}

function checkNodeImport(context, request, cb) {
if (!path.isAbsolute(request) && request.charAt(0) !== '.') {
cb(null, 'commonjs ' + request); return;
}
cb();
}

exports.hasProcessFlag = hasProcessFlag;
exports.isWebpackDevServer = isWebpackDevServer;
exports.root = root;
exports.checkNodeImport = checkNodeImport;
2 changes: 1 addition & 1 deletion index.ts
Expand Up @@ -15,7 +15,7 @@ export default {
exports: [ Angulartics2On ]
})
export class Angulartics2Module {
constructor(@Optional() @SkipSelf() parentModule: Angulartics2Module) {
constructor(@Optional() @SkipSelf() parentModule: Angulartics2Module) {
if (parentModule) {
throw new Error('Angulartics2Module already loaded; Import in root module only.');
}
Expand Down
113 changes: 0 additions & 113 deletions karma-test-shim.js

This file was deleted.

165 changes: 69 additions & 96 deletions karma.conf.js 100644 → 100755
@@ -1,97 +1,70 @@
// Karma configuration
// Generated on Wed Dec 02 2015 22:57:01 GMT+0100 (Paris, Madrid)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
// System.js for module loading
'node_modules/systemjs/dist/system.src.js',

// Polyfills
'node_modules/core-js/client/shim.js',

// Reflect and Zone.js
'node_modules/reflect-metadata/Reflect.js',
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/zone.js/dist/proxy.js',
'node_modules/zone.js/dist/sync-test.js',
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',

// RxJs.
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

// Angular 2 itself and the testing library
{ pattern: 'node_modules/@angular/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false },

'karma-test-shim.js',

{ pattern: '*.ts', included: false, watched: true },
{ pattern: 'src/**/*.ts', included: false, watched: true },
],

// list of files to exclude
exclude: [
'src/**/*.d.ts'
],

preprocessors: {
'**/*.ts': ['typescript']
},

typescriptPreprocessor: {
options: require('./tsconfig.json').compilerOptions,
},

customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],


// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: process.env.TRAVIS ? ['Chrome_travis_ci'] : ['Chrome'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// Concurrency level
// how many browser should be started simultanous
concurrency: Infinity
});
};
var testWebpackConfig = require('./webpack.test.js');

var configuration = {
basePath: '',

frameworks: ['jasmine'],

// list of files to exclude
exclude: [ ],

/*
* list of files / patterns to load in the browser
*
* we are building the test environment in ./spec-bundle.js
*/
files: [ { pattern: './spec-bundle.js', watched: false } ],

preprocessors: { './spec-bundle.js': ['coverage', 'webpack', 'sourcemap'] },

// Webpack Config at ./webpack.test.js
webpack: testWebpackConfig,

coverageReporter: {
dir : 'coverage/',
reporters: [
{ type: 'text-summary' },
{ type: 'json' },
{ type: 'html' }
]
},

// Webpack please don't spam the console when running in karma!
webpackServer: { noInfo: true },

reporters: [ 'mocha', 'coverage' ],

// web server port
port: 9876,

colors: true,

/*
* level of logging
* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
*/
logLevel: config.LOG_INFO,

autoWatch: false,

browsers: [
'Chrome'
],

customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},

singleRun: true
};

if(process.env.TRAVIS){
configuration.browsers = ['Chrome_travis_ci'];
}

config.set(configuration);
};
28 changes: 20 additions & 8 deletions package.json
Expand Up @@ -44,28 +44,40 @@
"@types/core-js": "^0.9.32",
"@types/jasmine": "^2.2.29",
"@types/node": "6.0.38",
"commitizen": "^2.8.1",
"awesome-typescript-loader": "^2.2.4",
"codelyzer": "0.0.28",
"commitizen": "^2.8.6",
"concurrently": "^2.2.0",
"core-js": "^2.4.1",
"cz-conventional-changelog": "^1.1.6",
"cz-conventional-changelog": "^1.2.0",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine-core": "^2.5.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^1.0.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-typescript-preprocessor": "0.0.21",
"reflect-metadata": "0.1.3",
"karma-mocha-reporter": "^2.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"reflect-metadata": "0.1.8",
"rxjs": "5.0.0-beta.12",
"semantic-release": "^4.3.5",
"source-map-loader": "^0.1.5",
"systemjs": "^0.19.38",
"tslint": "^3.6.0",
"ts-helpers": "^1.1.1",
"tslint": "^3.15.1",
"tslint-loader": "^2.1.5",
"typescript": "2.0.2",
"webpack": "^1.13.2",
"zone.js": "0.6.21"
},
"bugs": {
"url": "http://github.com/angulartics/angulartics2/issues"
},
"scripts": {
"lint": "tslint ./*.ts ./src/{,*/}*.ts",
"test": "karma start",
"test": "tsc && karma start",
"test-watch": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"commit": "git-cz",
"build": "tsc -d",
"semantic-release": "semantic-release pre && npm run build && npm publish && semantic-release post"
Expand Down

0 comments on commit 590eb20

Please sign in to comment.