How do I turn off source maps for Angular 6 ng test?
Asked Answered
H

4

30

I am trying to turn off sourcemaps for my tests in Angular 6. I know the sourcemaps switch has been removed, e.g., ng test --sourcemaps=false.

I have tried modifying my tsconfig file:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
  ...
  "sourceMap": false
},

As referenced by the angular.json test -> configuration block:

"test": {
  ...
  "options": {
    ...
    "tsConfig": "src/tsconfig.spec.json",

The source maps are still being generated.

Herrmann answered 8/6, 2018 at 12:59 Comment(1)
A
57

You can use

CLI v6.0.8 and above --source-map=false

CLI v6.x --sourceMap=false

CLI v1.x --sourcemaps=false

Alverson answered 12/6, 2018 at 11:1 Comment(2)
Thanks. Camel case and singular tense sensitive!Herrmann
Please add 'CLI v6.0.8 and above --source-map=false' for people coming here and only reading the accepted answer ;-)Worship
V
11

Angular CLI changing this param from version to version as per this answer:

CLI v6.0.8 and above
--source-map=false

CLI v6.0.x early versions
--sourceMap=false

CLI v1.x
--sourcemaps=false

Shortcut ng test -sm=false might also work

In case if you are on the latest CLI and none of above works you can always check the Options section at https://github.com/angular/angular-cli/blob/master/docs/documentation/test.md for the recent param name

Vaas answered 12/10, 2018 at 1:24 Comment(1)
For the sake of change and breaking changes.Pirri
K
3

Angular CLI v6.x reads --source-map as --sourceMap. So both --source-map and --sourceMap works for me for CLI v6.0.8

Go to package.json Change "test":"ng test" to "test":"ng test --source-map=false" to turn off sourcemaps.

Please note it shoud be --source-map and not --source-maps.

Kabul answered 19/10, 2018 at 8:40 Comment(0)
K
2

For me, I'm using Angular 10 and was able to set sourceMap for test in angular.json:

"test": {
  ...
  "options": {
    ...
    "tsConfig": "src/tsconfig.spec.json",
    "sourceMap": false
Khiva answered 23/11, 2020 at 3:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.