Angular-cli: Possibility to add global styles in karma tests

Created on 22 Jun 2017  路  5Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ x] feature request

Versions.

@angular/cli: 1.1.2
node: 6.9.1
os: darwin x64
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/flex-layout: 2.0.0-beta.8
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/material: 2.0.0-beta.6
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.1.2
@angular/compiler-cli: 4.2.4

Repro steps.

For a normal build all the styles from app.styles are preprocessed and included in the styles bundle. How can this bundle be generated and included also in tests (karma)?
Motivation to use styles in test: angular material requires a theme setup to work correctly/not outputting tons of warnings.

Most helpful comment

Maybe I missed something, but the following works in my case.

karma.conf.js

module.exports = function (config) {
  config.set({
    ...
    files: [
      './tests/misc/styles.css'
    ],
    ...
  });
};

Also, it could be a path similar to './node_modules/.../bootstrap.css'

All 5 comments

I understand the motivation for this feature, but it might be harder than it sounds like due to the way builds are done for tests. I'll look into it if I have the time.

any update on this?

Maybe I missed something, but the following works in my case.

karma.conf.js

module.exports = function (config) {
  config.set({
    ...
    files: [
      './tests/misc/styles.css'
    ],
    ...
  });
};

Also, it could be a path similar to './node_modules/.../bootstrap.css'

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings