Ionic 3 errors when running Karma unit tests with ng test

Hi all, I’m currently facing an issue with my Ionic project where the unit tests all fail (they used to pass, and still should) because of what looks like an issue with how it interacts with ES2015 syntax. I’ll go into more detail and list my config files below, but first here is the environment information.

cli packages: ({{PROJECT_DIR}}/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.2
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2 
    Node              : v8.9.4
    npm               : 5.6.0 
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : /Users/olly/Library/Android/sdk

Misc:

    backend : legacy

The app itself builds without any issues and runs fine on emulators and devices, but when I try to run the tests by running ng t,I immediately see the below warnings, and then it fails with the errors after them:

/** THE WARNINGS **/

WARNING in ./node_modules/ionic-angular/es2015/util/ng-module-loader.js
25:11-36 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/ionic-angular/es2015/util/ng-module-loader.js
 @ ./node_modules/ionic-angular/es2015/util/module-loader.js
 @ ./node_modules/ionic-angular/es2015/components/popover/popover-component.js
 @ ./node_modules/ionic-angular/es2015/module.js
 @ ./node_modules/ionic-angular/es2015/index.js
 @ ./src/app/app.spec.ts
 @ ./src \.spec\.ts$
 @ ./src/test.ts

WARNING in ./node_modules/ionic-angular/es2015/util/ng-module-loader.js
35:11-36 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/ionic-angular/es2015/util/ng-module-loader.js
 @ ./node_modules/ionic-angular/es2015/util/module-loader.js
 @ ./node_modules/ionic-angular/es2015/components/popover/popover-component.js
 @ ./node_modules/ionic-angular/es2015/module.js
 @ ./node_modules/ionic-angular/es2015/index.js
 @ ./src/app/app.spec.ts
 @ ./src \.spec\.ts$
 @ ./src/test.ts
/** THE ERRORS **/

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  SyntaxError: Use of reserved word 'class'
  at http://localhost:9876/_karma_webpack_/vendor.bundle.js:27164

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  SyntaxError: Use of reserved word 'class'
  at http://localhost:9876/_karma_webpack_/vendor.bundle.js:27164


PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.922 secs / 0 secs)

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  TypeError: undefined is not an object (evaluating 'modules[moduleId].call')
  at http://localhost:9876/_karma_webpack_/inline.bundle.js:55
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  TypeError: undefined is not an object (evaluating 'modules[moduleId].call')
  at http://localhost:9876/_karma_webpack_/inline.bundle.js:55

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  TypeError: undefined is not an object (evaluating 'modules[moduleId].call')
  at http://localhost:9876/_karma_webpack_/inline.bundle.js:55


PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.944 secs / 0 secs)

I’ve even tried changing the browser the tests run in to Chrome, which gets slightly further but Karma then doesn’t seem to create the TestBed fixture instance so we’re unable to actually test anything either way…

Has anybody seen ( and ideally been able to get around or fix ) this before? If so, please advise as this is quite a serious issue.