Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New build system - support AOT #709

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ dist
docs_generated
src/**/*.js
src/**/*.map
src/**/*.ngfactory.js
.tmp
test-built
typings
npm-debug.log
*.ngfactory.ts
coverage/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
6
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
sudo: false
node_js:
- '5.0.0'
- '6'

env:
global:
Expand All @@ -11,6 +11,8 @@ env:
cache:
directories:
- node_modules
- $HOME/.npm
- $HOME/.yarn-cache

notifications:
webhooks:
Expand All @@ -27,12 +29,10 @@ before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- time npm i -g yarn --cache-min 999999999

install:
- npm install
- time yarn

script:
- npm run ci

after_success:
- ./scripts/npm-publish.sh
- npm run ci
44 changes: 0 additions & 44 deletions karma-systemjs-config.js

This file was deleted.

69 changes: 15 additions & 54 deletions karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,22 @@ Error.stackTraceLimit=Infinity;

jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;

// Cancel Karma's synchronous start,
// we will call `__karma__.start()` later, once all the specs are loaded.
__karma__.loaded = function() {};
require('core-js/client/shim');
require('reflect-metadata');

System.config({
packages: {
'base/src': {
defaultJSExtensions: true
},
'base/test-built/src': {
defaultJSExtensions: true
}
}
});
require('ts-helpers');

//loading systemjs for angular to use in tests
System.import('base/karma-systemjs-config.js').then(function() {
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
]).then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];
require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/proxy');
require('zone.js/dist/sync-test');
require('zone.js/dist/jasmine-patch');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');

testing.TestBed.initTestEnvironment(testingBrowser.BrowserDynamicTestingModule,
testingBrowser.platformBrowserDynamicTesting());
});
}).then(function() {
return Promise.all(
Object.keys(window.__karma__.files) // All files served by Karma.
.filter(onlySpecFiles)
.map(file2moduleName)
.map(function(path) {
return System.import(path).then(function(module) {
if (module.hasOwnProperty('main')) {
module.main();
} else {
throw new Error('Module ' + path + ' does not implement main() method.');
}
});
}));
})
.then(function() {
__karma__.start();
}, function(error) {
console.error(error.stack || error);
__karma__.start();
});
var ctx = require.context('./src', true, /\.spec\.ts/);
ctx.keys().forEach(ctx);


function onlySpecFiles(path) {
return /[\.|_]spec\.js$/.test(path);
}

// Normalize paths to module names.
function file2moduleName(filePath) {
return filePath.replace(/\\/g, '/');
}
var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');
testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());
143 changes: 83 additions & 60 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,95 @@
module.exports = function(config) {
var configuration = {
var path = require('path');

var webpackConfig = require('./webpack.config');
var ENV = process.env.npm_lifecycle_event;
var isTestWatch = ENV === 'test-watch';

module.exports = function (config) {
var _config = {

// 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'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher')

// list of files / patterns to load in the browser
files: [
{ pattern: './karma-test-shim.js', watched: false }
],

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

customLaunchers: {
Chrome_travis: {
base: 'Chrome',
flags: ['--no-sandbox']
}
Chrome_travis: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
files: [
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/core-js/client/core.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',

{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},

{pattern: 'karma-systemjs-config.js', included: true, watched: true},

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

{pattern: 'karma-test-shim.js', included: true, watched: true},

// paths loaded via module imports
{pattern: 'dist/**/*.js', included: false, watched: true},
{pattern: 'test-built/**/*.js', included: false, watched: true},

// paths loaded via Angular's component compiler
// (these paths need to be rewritten, see proxies section)
// {pattern: 'dist/**/*.html', included: false, watched: true},
// {pattern: 'dist/**/*.css', included: false, watched: true},

// paths to support debugging with source maps in dev tools
{pattern: 'dist/**/*.ts', included: false, watched: false},
{pattern: 'dist/**/*.js.map', included: false, watched: false}
],

// proxied base paths
proxies: {
// required for component assests fetched by Angular's compiler
'/dist/': '/base/dist/',
'/base/src/': '/base/dist/',
'/base/test-built/src': '/base/dist'
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./karma-test-shim.js': ['webpack', 'sourcemap']
},
reporters: ['progress'],

webpack: webpackConfig,

webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
stats: 'errors-only'
},

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

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

// 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,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false

// 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: isTestWatch ? ['Chrome'] : [process.env.TRAVIS ? 'Chrome_travis' : 'Chrome'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
};
if (process.env.TRAVIS) {
configuration.browsers = ['Chrome_travis'];



if (!isTestWatch) {
_config.reporters.push("coverage");

_config.coverageReporter = {
dir: 'coverage/',
reporters: [{
type: 'json',
dir: 'coverage',
subdir: 'json',
file: 'coverage-final.json'
}]
};
}
config.set(configuration);
};

config.set(_config);

};
Loading