Why does Stryker JS hang when used with angular ng test?

Discussão em 'Angular' iniciado por Sara_N, Outubro 24, 2024.

  1. Sara_N

    Sara_N Guest

    This is my project structure:

    [​IMG]

    stryker.config.json:

    {
    "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
    "_comment": "This config was generated using 'stryker init'. Please see the guide for more information: https://stryker-mutator.io/docs/stryker-js/guides/angular",
    "mutate": [
    "apps/1-web/src/**/*.ts",
    "!apps/1-web/src/**/*.spec.ts",
    "!apps/1-web/src/environments/*.ts",
    "!apps/1-web/src/**/*.html",
    "!apps/1-web/*.yml",
    "!apps/1-web/src/**/*.generated.ts",
    "!apps/1-web/src/test.ts",
    "!apps/1-web/src/**/*.graphql",
    "!apps/1-web/src/**/*.scss"
    ],
    "tsconfigFile": "tsconfig.json",
    "testRunner": "karma",
    "ignorers": ["angular"],
    "karma": {
    "configFile": "apps/1-web/karma.conf.js",
    "projectType": "angular-cli",
    "ngConfig": {
    "testArguments": {
    "project": "1-web"
    }
    },
    "config": {
    "browsers": [
    "ChromeHeadless"
    ]
    }
    },
    "reporters": [
    "progress",
    "clear-text",
    "html"
    ],
    "logLevel": "trace",
    "concurrency": 4,
    "concurrency_comment": "Recommended to use about half of your available cores when running stryker with angular",
    "coverageAnalysis": "perTest",
    "dryRunTimeoutMinutes": 30,
    "karmaConfigFile": "karma.conf.json"
    }


    Package.json:

    "@stryker-mutator/core": "^8.6.0",
    "@stryker-mutator/karma-runner": "^8.6.0"
    "@angular/cdk": "15.2.9",
    "@angular/common": "15.2.10",
    "@angular/compiler": "15.2.10",
    "@angular/core": "15.2.10"
    "karma": "6.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "^2.0.3",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "5.1.0",
    "karma-jasmine-html-reporter": "2.0.0",
    "karma-junit-reporter": "^2.0.1",
    "karma-parallel": "^0.3.1"


    When the stryker command "npx stryker run" is run, source files are instrumented, sandbox folder is created and working directory is changed to the sandbox directory. I see the below output in the terminal and nothing else happens after that. Navigating manually to the karma runner on http://localhost:9876/# shows "localhost refused to connect."

    16:17:47 (28448) DEBUG AngularProjectStarter Starting Angular tests: ng test --progress=false --karma-config=C:\dev\Gizmo\Gizmo.Web\apps\1-web\karma.conf.js --project=1-web
    16:17:47 (28448) DEBUG AngularProjectStarter Starting Angular tests: ng test --progress=false --karma-config=C:\dev\Gizmo\Gizmo.Web\apps\1-web\karma.conf.js --project=1-web


    When I "cd" into the sandbox folder and run the below command manually:

    ng test --progress=true --karma-config=apps/1-web/karma.conf.js --project=1-web

    I see this on http://localhost:9876/# [​IMG]

    The browser just hangs there. No console errors on the debug window either. The debug window is just blank and console shows "Skipped 0 tests"

    I tried removing ngConfig->testArguments-> project and running Stryker, same result.

    But if I run "ng test" in the sandbox folder, all tests are running.

    Continue reading...

Compartilhe esta Página