Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
juristr committed Dec 15, 2016
2 parents 8e00d56 + e1956ba commit c7cc948
Show file tree
Hide file tree
Showing 18 changed files with 554 additions and 222 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# 2 space indentation
[**.*]
indent_style = space
indent_size = 2
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
dist/
*.log
coverage/
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/
test/
src/
src/
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ notifications:
node_js:
- '4.1'
before_install:
- export CHROME_BIN=chromium-browser
- npm i -g npm@^2.0.0
- npm install -g gulp
- npm install
before_script:
- npm prune
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
after_success:
- npm run semantic-release
- npm run semantic-release
32 changes: 32 additions & 0 deletions config/helpers.js
Original file line number Diff line number Diff line change
@@ -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;
78 changes: 78 additions & 0 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
module.exports = function(config) {
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: './config/spec-bundle.js', watched: false } ],

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

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

coverageReporter: {
type: 'in-memory'
},

remapCoverageReporter: {
'text-summary': null,
json: './coverage/coverage.json',
html: './coverage/html'
},

// Webpack please don't spam the console when running in karma!
webpackMiddleware: { stats: 'errors-only'},

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

mochaReporter: {
ignoreSkipped: true
},

// 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: {
ChromeTravisCi: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},

singleRun: true
};

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

config.set(configuration);
};
28 changes: 28 additions & 0 deletions config/spec-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Error.stackTraceLimit = Infinity;

// Typescript emit helpers polyfill
require('angular');
require('angular-mocks/ngMock');
require('angular-translate');
require('angular-translate-loader-partial');

var testContext = require.context('../tests', true, /\.spec\.ts/);

/*
* get all the files, for each file, call the context function
* that will require the file and load it up here. Context will
* loop and require those spec files here
*/
function requireAll( requireContext ) {
return requireContext.keys().map(function( path ) {
try {
return requireContext( path );
} catch ( err ) {
console.error( '[ERROR] WITH SPEC FILE: ', path );
console.error( err );
}
} );
}

// requires and returns all modules that match
var modules = requireAll(testContext);
46 changes: 46 additions & 0 deletions config/testing-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/// <reference path="../node_modules/@types/jasmine/index.d.ts" />

/*
Temporary fiile for referencing the TypeScript defs for Jasmine + some potentially
utils for testing. Will change/adjust this once I find a better way of doing
*/

declare module jasmine {
interface Matchers {
toHaveText(text: string): boolean;
toContainText(text: string): boolean;
}
}

beforeEach(() => {
jasmine.addMatchers({

toHaveText: function() {
return {
compare: function(actual, expectedText) {
var actualText = actual.textContent;
return {
pass: actualText === expectedText,
get message() {
return 'Expected ' + actualText + ' to equal ' + expectedText;
}
};
}
};
},

toContainText: function() {
return {
compare: function(actual, expectedText) {
var actualText = actual.textContent;
return {
pass: actualText.indexOf(expectedText) > -1,
get message() {
return 'Expected ' + actualText + ' to contain ' + expectedText;
}
};
}
};
}
});
});
85 changes: 85 additions & 0 deletions config/webpack.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Adapted from angular2-webpack-starter
*/

const helpers = require('./helpers'),
webpack = require('webpack'),
LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');

/**
* Webpack Plugins
*/

module.exports = {

/**
* Source map for Karma from the help of karma-sourcemap-loader & karma-webpack
*
* Do not change, leave as is or it wont work.
* See: https://github.com/webpack/karma-webpack#source-maps
*/
devtool: 'inline-source-map',

resolve: {
extensions: ['.ts', '.js'],
modules: [helpers.root('src'), 'node_modules']
},

module: {
rules: [{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
exclude: [helpers.root('node_modules')]
}, {
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
exclude: []
}, {
test: /\.ts$/,
loader: 'awesome-typescript-loader',
query: {
// use inline sourcemaps for "karma-remap-coverage" reporter
sourceMap: false,
inlineSourceMap: true,
module: "commonjs",
removeComments: true
},
exclude: [/\.e2e\.ts$/]
}, {
enforce: 'post',
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
include: helpers.root('src'),
exclude: [/\.spec\.ts$/, /\.e2e\.ts$/, /node_modules/]
}],
},

plugins: [
// fix the warning in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src')
),

new LoaderOptionsPlugin({
debug: true,
options: {

/**
* Static analysis linter for TypeScript advanced options configuration
* Description: An extensible linter for the TypeScript language.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
tslint: {
emitErrors: false,
failOnHint: false,
resourcePath: 'src'
},

}
})
]
};
Loading

0 comments on commit c7cc948

Please sign in to comment.