Skip to content
Merged
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
16 changes: 6 additions & 10 deletions addon/ng2/blueprints/ng2/files/__path__/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ Promise.all([
let testing = providers[0];
let testingBrowser = providers[1];

testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
testing.setBaseTestProviders(
testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
);
});

let testContext = require.context('../src', 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) {
let testContext: any = require.context('../src', true, /\.spec\.ts/);
function requireAll(requireContext: any) {
return requireContext.keys().map(requireContext);
}

Expand Down
7 changes: 1 addition & 6 deletions addon/ng2/blueprints/ng2/files/__path__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@
"rootDir": ".",
"sourceMap": true,
"target": "es5",
"mapRoot": "/",
"inlinesource": true
"mapRoot": "/"
},
"compileOnSave": false,
"buildOnSave": false,
"exclude": [
"node_modules",
"bower_components"
],
"includes": [
"**.d.ts"
]
Expand Down
7 changes: 5 additions & 2 deletions addon/ng2/models/webpack-build-common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as webpack from 'webpack';
import {LoaderConfig} from '../utilities/ts-path-mappings-webpack-plugin';
import {LoaderConfig, PathsPlugin} from '../utilities/ts-path-mappings-webpack-plugin';

const path = require('path');
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
Expand All @@ -18,7 +18,10 @@ export function getWebpackCommonConfig(projectRoot: string) {
resolve: {
extensions: ['', '.ts', '.js'],
root: path.resolve(projectRoot, './src'),
moduleDirectories: ['node_modules']
moduleDirectories: ['node_modules'],
plugins: [
new PathsPlugin(awesomeTypescriptLoaderConfig);
]
},
context: path.resolve(__dirname, './'),
entry: {
Expand Down
3 changes: 1 addition & 2 deletions addon/ng2/models/webpack-build-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const getWebpackTestConfig = function(projectRoot: string) {
query: {
useWebpackText: true,
tsconfig: path.resolve(projectRoot, './src/tsconfig.json'),
// resolveGlobs: false,
module: "commonjs",
target: "es5",
useForkChecker: true,
Expand All @@ -67,7 +66,7 @@ export const getWebpackTestConfig = function(projectRoot: string) {
],
postLoaders: [
{
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader',
test: /\.(js|ts)$/, loader: 'sourcemap-istanbul-instrumenter-loader',
exclude: [
/\.(e2e|spec)\.ts$/,
/node_modules/
Expand Down
2 changes: 1 addition & 1 deletion addon/ng2/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = Task.extend({

// Single test entry file. Will run the test.ts bundle and track it.
options.files = [{ pattern: './src/test.ts', watched: false }];
options.preprocessors = { './src/test.ts': ['coverage','webpack','sourcemap'] };
options.preprocessors = { './src/test.ts': ['webpack','sourcemap'] };
options.webpack = webpackTestConfig(projectRoot);
options.webpackMiddleware = {
noInfo: true, // Hide webpack output because its noisy.
Expand Down
3 changes: 0 additions & 3 deletions addon/ng2/utilities/ts-path-mappings-webpack-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ export class PathsPlugin implements ResolverPlugin {
this.baseUrl
);

console.log("CONFIG FILE AND BASE URL");
console.log(this.configFilePath, this.absoluteBaseUrl);

this.mappings = [];
let paths = this.options.paths || {};
Object.keys(paths).forEach(alias => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"shelljs": "^0.7.0",
"silent-error": "^1.0.0",
"source-map-loader": "^0.1.5",
"sourcemap-istanbul-instrumenter-loader": "^0.2.0",
"style-loader": "^0.13.1",
"stylus": "^0.54.5",
"stylus-loader": "^2.1.0",
Expand All @@ -97,7 +98,7 @@
"typescript": "^2.0.0",
"typings": "^0.8.1",
"url-loader": "^0.5.7",
"webpack": "2.1.0-beta.17",
"webpack": "2.1.0-beta.18",
"webpack-dev-server": "2.1.0-beta.0",
"webpack-md5-hash": "0.0.5",
"webpack-merge": "^0.14.0"
Expand Down
43 changes: 22 additions & 21 deletions tests/e2e/e2e_workflow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Basic end-to-end Workflow', function () {
this.timeout(300000);

sh.exec('npm link', { silent: true });

return tmp.setup('./tmp').then(function () {
process.chdir('./tmp');
expect(existsSync(path.join(process.cwd(), 'bin', 'ng')));
Expand Down Expand Up @@ -446,36 +446,37 @@ describe('Basic end-to-end Workflow', function () {
});
});

xit('Turn on path mapping in tsconfig.json and rebuild', function () {
it('Turn on path mapping in tsconfig.json and rebuild', function () {
this.timeout(420000);

const configFilePath = path.join(process.cwd(), 'src', 'tsconfig.json');
let config = require(configFilePath);

config.compilerOptions.baseUrl = '';

// This should fail.
// #TODO: When https://github.com/Microsoft/TypeScript/issues/9772 is fixed this should fail.
config.compilerOptions.paths = { '@angular/*': [] };
fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2), 'utf8');

return ng(['build'])
.catch(() => {
return true;
})
.then((passed) => {
expect(passed).to.equal(true);
})
.then(() => {
// This should succeed.
config.compilerOptions.paths = {
'@angular/*': [ '*' ]
};
fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2), 'utf8');
})
.then(() => ng(['build']))
.catch(() => {
expect('build failed where it should have succeeded').to.equal('');
});
sh.exec(`${ngBin} build`);
// #TODO: Uncomment these lines when https://github.com/Microsoft/TypeScript/issues/9772 is fixed.
// .catch(() => {
// return true;
// })
// .then((passed) => {
// expect(passed).to.equal(true);
// })

// This should succeed.
config.compilerOptions.paths = {
'@angular/*': [ '../node_modules/@angular/*' ]
};
fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2), 'utf8');
sh.exec(`${ngBin} build`);

expect(existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
const indexHtml = fs.readFileSync(path.join(process.cwd(), 'dist/index.html'), 'utf-8');
expect(indexHtml).to.include('main.bundle.js');
});

it('Serve and run e2e tests after all other commands', function () {
Expand Down