fix: throw useful error on missing platform module.
This commit is contained in:
parent
8c8754e573
commit
73f02c7861
|
@ -684,7 +684,7 @@ export function main() {
|
||||||
expect(elAst.providers[0].providers).toEqual([dirProvider]);
|
expect(elAst.providers[0].providers).toEqual([dirProvider]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if mixing multi and non multi providers', () => {
|
it('if mixing multi and non multi providers', () => {
|
||||||
var provider0 = createProvider('service0');
|
var provider0 = createProvider('service0');
|
||||||
var provider1 = createProvider('service0', {multi: true});
|
var provider1 = createProvider('service0', {multi: true});
|
||||||
var dirA = createDir('[dirA]', {providers: [provider0]});
|
var dirA = createDir('[dirA]', {providers: [provider0]});
|
||||||
|
|
|
@ -313,7 +313,10 @@ export class PlatformRef_ extends PlatformRef {
|
||||||
const ngZoneInjector =
|
const ngZoneInjector =
|
||||||
ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], this.injector);
|
ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], this.injector);
|
||||||
const moduleRef = moduleFactory.create(ngZoneInjector);
|
const moduleRef = moduleFactory.create(ngZoneInjector);
|
||||||
const exceptionHandler: ExceptionHandler = moduleRef.injector.get(ExceptionHandler);
|
const exceptionHandler: ExceptionHandler = moduleRef.injector.get(ExceptionHandler, null);
|
||||||
|
if (!exceptionHandler) {
|
||||||
|
throw new Error('No ExceptionHandler. Is platform module (BrowserModule) included?');
|
||||||
|
}
|
||||||
ObservableWrapper.subscribe(ngZone.onError, (error: NgZoneError) => {
|
ObservableWrapper.subscribe(ngZone.onError, (error: NgZoneError) => {
|
||||||
exceptionHandler.call(error.error, error.stackTrace);
|
exceptionHandler.call(error.error, error.stackTrace);
|
||||||
});
|
});
|
||||||
|
|
|
@ -141,6 +141,18 @@ export function main() {
|
||||||
expect(errorLogger.res).toEqual(['EXCEPTION: Test']);
|
expect(errorLogger.res).toEqual(['EXCEPTION: Test']);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should throw useful error when ApplicationRef is not configured', async(() => {
|
||||||
|
@NgModule()
|
||||||
|
class EmptyModule {
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultPlatform.bootstrapModule(EmptyModule)
|
||||||
|
.then(() => fail('expecting error'), (error) => {
|
||||||
|
expect(error.message)
|
||||||
|
.toEqual('No ExceptionHandler. Is platform module (BrowserModule) included?');
|
||||||
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('bootstrapModuleFactory', () => {
|
describe('bootstrapModuleFactory', () => {
|
||||||
|
|
|
@ -65,7 +65,8 @@ const BaseConfig = {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (platform == 'node') {
|
if (platform == 'node') {
|
||||||
tscWatch = new TscWatch(Object.assign({
|
tscWatch = new TscWatch(Object.assign(
|
||||||
|
{
|
||||||
tsconfig: 'modules/tsconfig.json',
|
tsconfig: 'modules/tsconfig.json',
|
||||||
onChangeCmds: [
|
onChangeCmds: [
|
||||||
processOutputEmitterCodeGen,
|
processOutputEmitterCodeGen,
|
||||||
|
@ -74,9 +75,11 @@ if (platform == 'node') {
|
||||||
'@angular/compiler-cli/test/**/*_spec.js'
|
'@angular/compiler-cli/test/**/*_spec.js'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}, BaseConfig));
|
},
|
||||||
|
BaseConfig));
|
||||||
} else if (platform == 'browser') {
|
} else if (platform == 'browser') {
|
||||||
tscWatch = new TscWatch(Object.assign({
|
tscWatch = new TscWatch(Object.assign(
|
||||||
|
{
|
||||||
tsconfig: 'modules/tsconfig.json',
|
tsconfig: 'modules/tsconfig.json',
|
||||||
onStartCmds: [
|
onStartCmds: [
|
||||||
[
|
[
|
||||||
|
@ -92,27 +95,31 @@ if (platform == 'node') {
|
||||||
['node', 'node_modules/karma/bin/karma', 'run', 'karma-js.conf.js', '--port=9876'],
|
['node', 'node_modules/karma/bin/karma', 'run', 'karma-js.conf.js', '--port=9876'],
|
||||||
['node', 'node_modules/karma/bin/karma', 'run', '--port=9877'],
|
['node', 'node_modules/karma/bin/karma', 'run', '--port=9877'],
|
||||||
]
|
]
|
||||||
}, BaseConfig));
|
},
|
||||||
|
BaseConfig));
|
||||||
} else if (platform == 'browserNoRouter') {
|
} else if (platform == 'browserNoRouter') {
|
||||||
tscWatch = new TscWatch(Object.assign({
|
tscWatch = new TscWatch(Object.assign(
|
||||||
|
{
|
||||||
tsconfig: 'modules/tsconfig.json',
|
tsconfig: 'modules/tsconfig.json',
|
||||||
onStartCmds: [
|
onStartCmds: [[
|
||||||
[
|
|
||||||
'node', 'node_modules/karma/bin/karma', 'start', '--no-auto-watch', '--port=9876',
|
'node', 'node_modules/karma/bin/karma', 'start', '--no-auto-watch', '--port=9876',
|
||||||
'karma-js.conf.js'
|
'karma-js.conf.js'
|
||||||
]
|
]],
|
||||||
],
|
|
||||||
onChangeCmds: [
|
onChangeCmds: [
|
||||||
['node', 'node_modules/karma/bin/karma', 'run', 'karma-js.conf.js', '--port=9876'],
|
['node', 'node_modules/karma/bin/karma', 'run', 'karma-js.conf.js', '--port=9876'],
|
||||||
]
|
]
|
||||||
}, BaseConfig));
|
},
|
||||||
|
BaseConfig));
|
||||||
} else if (platform == 'tools') {
|
} else if (platform == 'tools') {
|
||||||
tscWatch = new TscWatch(Object.assign({
|
tscWatch = new TscWatch(Object.assign(
|
||||||
|
{
|
||||||
tsconfig: 'tools/tsconfig.json',
|
tsconfig: 'tools/tsconfig.json',
|
||||||
onChangeCmds: [[
|
onChangeCmds: [[
|
||||||
'node', 'dist/tools/cjs-jasmine/index-tools', '--', '@angular/tsc-wrapped/**/*{_,.}spec.js'
|
'node', 'dist/tools/cjs-jasmine/index-tools', '--',
|
||||||
|
'@angular/tsc-wrapped/**/*{_,.}spec.js'
|
||||||
]]
|
]]
|
||||||
}, BaseConfig));
|
},
|
||||||
|
BaseConfig));
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`unknown platform: ${platform}`);
|
throw new Error(`unknown platform: ${platform}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue