Angular-cli: stylePreprocessorOptions not used for unit tests

Created on 11 Dec 2017  路  6Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 1.6.0
Node: 8.5.0
OS: win32 x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.0
@angular/cli: 1.6.0
@angular/flex-layout: 2.0.0-beta.10
@angular/material: 5.0.0
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • Create a scss-partial in a folder styles, e.g. _variables.scss
  • Add styles to stylePreprocessorOptions.includePaths in .angular-cli.json.
  • Use this scss-partial in any *.component.scss-file, using @import "variables"

Observed behavior

Runing ng serve works as expected, running ng test fils with
File to import not found or unreadable: variables.

Desired behavior

The unit tests (ng test) should also use the setting and therefore be able to resolve the _variables.scss.

Mention any other details that might be useful (optional)

This has already been reported in #4200, but this issue has been closed in favor of #3605.
That issue in turn, has been closed in february, however it does not seem to be fixed or is broken again.

2 (required) broken

Most helpful comment

In Angular CLI 6 you just have to add the stylePreprocessorOptions to the options block of test:

        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            ....
            "stylePreprocessorOptions": {
              "includePaths": [
                "src/styles",
                "libs/ui/styles",
                "libs/ui/styles/abstracts"
              ]
            }
          }
        },

All 6 comments

Hi, any news please ?

I was wondering why stylePreprocessorOptions didn't work on unit tests no matter what path settings I tried...

Angular CLI 1.7.3

Bumping this as I have experienced this issue as well.

We're basically unable to use the includePaths feature at all if it does not work with ng test.

In Angular CLI 6 you just have to add the stylePreprocessorOptions to the options block of test:

        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            ....
            "stylePreprocessorOptions": {
              "includePaths": [
                "src/styles",
                "libs/ui/styles",
                "libs/ui/styles/abstracts"
              ]
            }
          }
        },

Closing as it has been answered above.

Thanks

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

Related issues

hareeshav picture hareeshav  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments