angularjestjsangular-builder

After upgrading to Angular 8 testing with Jest broken


We recently upgraded our Angular version from 7 to 8 and have run into some problems when using Jest as our test runner. The goal is to get our build pipeline running again with our javascript tests. We are getting an error: An unhandled exception occurred: core_1.experimental.workspace.Workspace.fromPath is not a function

I have upgraded both "@angular-builders/jest": "8.0.4" as well as upgraded "jest": "24.8.0" as per the angular-builders README.

I have updated our Jest config property setupTestFrameworkScriptFile to setupFilesAfterEnv

I have tried clearing out my node_modules and reinstalling them as per this issue


Solution

  • I also upgraded to Angular 8, and then tried to switch to using Jest testing instead of Karma. I was getting this error:

    An unhandled exception occurred: architect_1.createBuilder is not a function
    

    It turns out that the ng update command didn't update the versions of some dependencies. In my case, I needed to get a more recent version of @angular-devkit/build-angular (version "^0.801.2"). Try checking all your dependency versions. I have the WebStorm IDE, which nicely suggests the latest version for me.