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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<script type="text/javascript" src="_karma_webpack_/polyfills.js" crossorigin="anonymous"></script>
<!-- Dynamically replaced with <script> tags -->
%SCRIPTS%
<script type="text/javascript" src="_karma_webpack_/styles.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="_karma_webpack_/scripts.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="_karma_webpack_/vendor.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="_karma_webpack_/main.js" crossorigin="anonymous"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<script type="text/javascript" src="_karma_webpack_/polyfills.js" crossorigin="anonymous"></script>
<!-- Dynamically replaced with <script> tags -->
%SCRIPTS%
<script type="text/javascript" src="_karma_webpack_/styles.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="_karma_webpack_/scripts.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="_karma_webpack_/vendor.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="_karma_webpack_/main.js" crossorigin="anonymous"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
config.middleware = config.middleware || [];
config.middleware.push('@angular-devkit/build-angular--fallback');

// Delete global styles entry, we don't want to load them.
delete webpackConfig.entry.styles;

// The webpack tier owns the watch behavior so we want to force it in the config.
webpackConfig.watch = !config.singleRun;
if (config.singleRun) {
Expand Down Expand Up @@ -198,6 +195,7 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
'/_karma_webpack_/runtime.js',
'/_karma_webpack_/polyfills.js',
'/_karma_webpack_/scripts.js',
'/_karma_webpack_/styles.js',
'/_karma_webpack_/vendor.js',
];
if (alwaysServe.indexOf(req.url) != -1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import { runTargetSpec } from '@angular-devkit/architect/testing';
import { tap } from 'rxjs/operators';
import { host, karmaTargetSpec } from '../utils';


describe('Karma Builder global styles', () => {
beforeEach(done => host.initialize().toPromise().then(done, done.fail));
afterEach(done => host.restore().toPromise().then(done, done.fail));

it('works', (done) => {
host.writeMultipleFiles({
'src/styles.css': 'p {display: none}',
'src/app/app.component.ts': `
import { Component } from '@angular/core';

@Component({
selector: 'app-root',
template: '<p>Hello World</p>'
})
export class AppComponent {
}
`,
'src/app/app.component.spec.ts': `
import { TestBed, async } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpModule
],
declarations: [
AppComponent
]
}).compileComponents();
}));

it('should not contain text that is hidden via css', async(() => {
const fixture = TestBed.createComponent(AppComponent);
expect(fixture.nativeElement.innerText).not.toContain('Hello World');
}));
});`,
});

runTargetSpec(host, karmaTargetSpec).pipe(
tap(buildEvent => expect(buildEvent.success).toBe(true)),
).toPromise().then(done, done.fail);
});
});