docs(webpack): update testing for RC5

closes #2133
This commit is contained in:
Jesús Rodríguez 2016-08-17 20:52:25 +02:00 committed by Ward Bell
parent 37847f83e3
commit 66a36bea05
4 changed files with 19 additions and 19 deletions

View File

@ -5,10 +5,10 @@ require('core-js/es6');
require('reflect-metadata'); require('reflect-metadata');
require('zone.js/dist/zone'); require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/jasmine-patch');
require('zone.js/dist/async-test'); require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test'); require('zone.js/dist/fake-async-test');
require('zone.js/dist/sync-test');
require('zone.js/dist/proxy-zone');
var appContext = require.context('../src', true, /\.spec\.ts/); var appContext = require.context('../src', true, /\.spec\.ts/);
@ -17,7 +17,4 @@ appContext.keys().forEach(appContext);
var testing = require('@angular/core/testing'); var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing'); var browser = require('@angular/platform-browser-dynamic/testing');
testing.setBaseTestProviders( testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());
browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
);

View File

@ -1,4 +1,6 @@
// #docregion // #docregion
var helpers = require('./helpers');
module.exports = { module.exports = {
devtool: 'inline-source-map', devtool: 'inline-source-map',
@ -23,7 +25,13 @@ module.exports = {
}, },
{ {
test: /\.css$/, test: /\.css$/,
exclude: helpers.root('src', 'app'),
loader: 'null' loader: 'null'
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw'
} }
] ]
} }

View File

@ -1,21 +1,16 @@
// #docregion // #docregion
import { import { TestBed } from '@angular/core/testing';
addProviders,
inject,
} from '@angular/core/testing';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
describe('App', () => { describe('App', () => {
beforeEach(() => { beforeEach(() => {
addProviders([ TestBed.configureTestingModule({ declarations: [AppComponent]});
AppComponent
]);
}); });
it ('should work', inject([AppComponent], (app: AppComponent) => { it ('should work', () => {
// Add real test here let fixture = TestBed.createComponent(AppComponent);
expect(2).toBe(2); expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
})); });
}); });
// #enddocregion // #enddocregion

View File

@ -360,8 +360,8 @@ a(id="test-configuration")
We don't need much configuration to run unit tests. We don't need much configuration to run unit tests.
We don't need the loaders and plugins that we declared for our development and production builds. We don't need the loaders and plugins that we declared for our development and production builds.
We probably don't need to load and process `css` files for unit tests and doing so would slow us down; We probably don't need to load and process the application-wide styles files for unit tests and doing so would slow us down;
we'll use the `null` loader for all CSS. we'll use the `null` loader for those CSS.
We could merge our test configuration into the `webpack.common` configuration and override the parts we don't want or need. We could merge our test configuration into the `webpack.common` configuration and override the parts we don't want or need.
But it might be simpler to start over with a completely fresh configuration. But it might be simpler to start over with a completely fresh configuration.