Loading GoogleMaps API in Angular 20 Karma unit tests

Discussão em 'Angular' iniciado por Winthorpe, Junho 1, 2025.

  1. Winthorpe

    Winthorpe Guest

    Having updated an Angular v19 app to Angular v20, the Google Maps API is not loaded in the Karma unit tests. All unit tests on components which serve Google Maps API fail with the following message:


    Error: Namespace google not found, cannot construct embedded google map. Please install the Google Maps JavaScript API: https://developers.google.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API
    ​

    In my Karma test setup I load the Google Maps API in the configuration (karma.config.js) file like this:

    module.exports = function (config) {
    config.set({
    basePath: "",
    frameworks: ["jasmine", "@angular-devkit/build-angular"],
    files: ["src/assets/google-maps-api.js"],


    The files property refers to a minified JavaScript file with Google Maps API.

    The above setup continues to work in Angular v19, but not in Angular v20.

    Does the Google Maps API need to be loaded differently in Angular v20 Karma unit tests?

    Continue reading...

Compartilhe esta Página