Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 75db343

Browse files
committed
docs(webpack): update testing for RC5
1 parent 35b5438 commit 75db343

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

public/docs/_examples/webpack/ts/config/karma-test-shim.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ require('reflect-metadata');
66

77
require('zone.js/dist/zone');
88
require('zone.js/dist/long-stack-trace-zone');
9-
require('zone.js/dist/jasmine-patch');
109
require('zone.js/dist/async-test');
1110
require('zone.js/dist/fake-async-test');
11+
require('zone.js/dist/sync-test');
12+
require('zone.js/dist/proxy-zone');
13+
require('zone.js/dist/jasmine-patch');
1214

1315
var appContext = require.context('../src', true, /\.spec\.ts/);
1416

@@ -17,7 +19,4 @@ appContext.keys().forEach(appContext);
1719
var testing = require('@angular/core/testing');
1820
var browser = require('@angular/platform-browser-dynamic/testing');
1921

20-
testing.setBaseTestProviders(
21-
browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
22-
browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
23-
);
22+
testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());

public/docs/_examples/webpack/ts/config/webpack.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// #docregion
2+
var helpers = require('./helpers');
3+
24
module.exports = {
35
devtool: 'inline-source-map',
46

@@ -23,7 +25,13 @@ module.exports = {
2325
},
2426
{
2527
test: /\.css$/,
28+
exclude: helpers.root('src', 'app'),
2629
loader: 'null'
30+
},
31+
{
32+
test: /\.css$/,
33+
include: helpers.root('src', 'app'),
34+
loader: 'raw'
2735
}
2836
]
2937
}
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
// #docregion
2-
import {
3-
addProviders,
4-
inject,
5-
} from '@angular/core/testing';
2+
import { TestBed } from '@angular/core/testing';
63

74
import { AppComponent } from './app.component';
85

96
describe('App', () => {
107
beforeEach(() => {
11-
addProviders([
12-
AppComponent
13-
]);
8+
TestBed.configureTestingModule({ declarations: [AppComponent]});
149
});
1510

16-
it ('should work', inject([AppComponent], (app: AppComponent) => {
17-
// Add real test here
18-
expect(2).toBe(2);
19-
}));
11+
it ('should work', () => {
12+
let fixture = TestBed.createComponent(AppComponent);
13+
expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
14+
});
2015
});
2116
// #enddocregion

public/docs/ts/latest/guide/webpack.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ a(id="test-configuration")
360360

361361
We don't need much configuration to run unit tests.
362362
We don't need the loaders and plugins that we declared for our development and production builds.
363-
We probably don't need to load and process `css` files for unit tests and doing so would slow us down;
364-
we'll use the `null` loader for all CSS.
363+
We probably don't need to load and process the application-wide styles files for unit tests and doing so would slow us down;
364+
we'll use the `null` loader for those CSS.
365365

366366
We could merge our test configuration into the `webpack.common` configuration and override the parts we don't want or need.
367367
But it might be simpler to start over with a completely fresh configuration.

0 commit comments

Comments
 (0)