Skip to content

Running ng test with --include fails for IE11 #21239

Closed
@ayonix

Description

@ayonix

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

No, I don't think so.

Description

ng test --browsers=IE --include=**/*.spec.ts fails to run.

When tsconfig is targeting es5 because of IE11 support, running ng test with the --include flag replaces the const context = require.context... through the single-test-transform-plugin. The replacement is not transpiled further and thus fails to run tests in IE11.
We are using angular11, but this is still the case for angular12.

🔬 Minimal Reproduction

  • ng new test-ie
  • add Angular routing? No
  • Stylesheet? Css
  • npm install karma-ie-launcher --save-dev
  • remove not before IE11 in .browserslistrc
  • add require('karma-ie-launcher'), in karma.conf.js
  • set target to "es5" in tsconfig.json
  • run ng test --browsers=IE --include="**/*.spec.ts"

🔥 Exception or Error

Browser:

SCRIPT1002: Syntaxerror
main.js (132,32)

Console:

IE 11.0 (Windows 10) ERROR
  Syntaxerror
  at http://localhost:9876/_karma_webpack_/main.js:132:32

🌍 Your Environment


$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.0.5
Node: 16.3.0
Package Manager: npm 7.15.1
OS: win32 x64

Angular: 12.0.5
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1200.5
@angular-devkit/build-angular   12.0.5
@angular-devkit/core            12.0.5
@angular-devkit/schematics      12.0.5
@schematics/angular             12.0.5
rxjs                            6.6.7
typescript                      4.2.4

Anything else relevant?

Just happens with IE11.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions