karma-runner / karma-jasmine

A Karma plugin - adapter for Jasmine testing framework.
MIT License
542 stars 162 forks source link

Sends report before tests finish running #292

Open contd opened 3 years ago

contd commented 3 years ago

I'm trying to use the ReportPortal agent for Jasmine and its posting the results (which are empty) before the tests are even run. Here is my karma.conf.js

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
const ReportportalAgent = require('@reportportal/agent-js-jasmine');
const agent = new ReportportalAgent({
  // client settings
  token: process.env.REPORTPORTAL_TOKEN,
  endpoint: process.env.REPORTPORTAL_ENDPOINT,
  launch: "Aragorn_Frontend_Karma",
  project: process.env.REPORTPORTAL_PROJECT || "default_personal",
  // agent settings
  debug: true,
  attributes: [
      {
          "key": "CI_PIPELINE_ID",
          "value": process.env.CI_PIPELINE_ID
      },
      {
          "key": "CI_JOB_ID",
          "value": process.env.CI_JOB_ID
      },
  ]
});

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      clearContext: false
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, './coverage/frontend'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    restartOnFileChange: true,
    onPrepare() {
      jasmine.getEnv().addReporter(agent.getJasmineReporter());
    }
  });
};

agent.getExitPromise().then(() => {
  console.log('finished work!');
});

my package.json

{
  "name": "frontend",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --host 0.0.0.0",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ngcc"
  },
  "private": true,
  "dependencies": {
    "@angular-material-components/datetime-picker": "^4.0.7",
    "@angular-material-components/moment-adapter": "^6.0.0",
    "@angular/animations": "~10.1.6",
    "@angular/cdk": "^10.2.5",
    "@angular/common": "~10.1.6",
    "@angular/compiler": "~10.1.6",
    "@angular/core": "~10.1.6",
    "@angular/forms": "~10.1.6",
    "@angular/google-maps": "^11.0.4",
    "@angular/material": "^10.2.5",
    "@angular/platform-browser": "~10.1.6",
    "@angular/platform-browser-dynamic": "~10.1.6",
    "@angular/router": "~10.1.6",
    "@apollo/client": "^3.3.19",
    "@apollo/link-context": "^2.0.0-beta.3",
    "@apollo/link-error": "^2.0.0-beta.3",
    "@apollo/link-ws": "^2.0.0-beta.3",
    "@ngrx/effects": "^10.1.1",
    "@ngrx/store": "^10.1.1",
    "@ngrx/store-devtools": "^10.1.1",
    "@swimlane/ngx-charts": "^16.0.0",
    "@types/apollo-upload-client": "^14.1.0",
    "@types/googlemaps": "^3.43.2",
    "@xstate/graph": "^1.3.0",
    "angular-oauth2-oidc": "^10.0.3",
    "apollo-angular": "^2.0.4",
    "apollo-angular-link-http": "^1.11.0",
    "apollo-cache-inmemory": "^1.6.6",
    "apollo-link": "^1.2.14",
    "apollo-link-context": "^1.0.20",
    "apollo-link-ws": "^1.0.20",
    "graphql": "^15.0.0",
    "lodash": "^4.17.21",
    "moment": "^2.29.1",
    "ngrx-graphql": "^1.1.2",
    "ngx-color-picker": "^11.0.0",
    "rxjs": "~6.5.4",
    "subscriptions-transport-ws": "^0.9.18",
    "tslib": "^2.0.0",
    "xstate": "^4.20.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1001.7",
    "@angular/cli": "~10.1.7",
    "@angular/compiler-cli": "~10.1.6",
    "@reportportal/agent-js-jasmine": "^5.0.0",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/lodash": "^4.14.170",
    "@types/node": "^12.11.1",
    "@types/react": "^17.0.0",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.3"
  }
}

The report portal agent finish uploading the results before even the Karma start running the tests.

Here is the output:

Start launch iigetnktydso0o
11% building 9/10 modules 1 active /home/jason.kumpf/Documents/citadel/packages/aragorn/frontend/src sync /\.spec\.ts$/Finish launch iigetnktydso0o
30% building 13/13 modules 0 active24 09 2021 09:10:11.198:WARN [karma]: No captured browser, open http://localhost:9876/
24 09 2021 09:10:11.204:INFO [karma-server]: Karma v5.0.9 server started at http://0.0.0.0:9876/
24 09 2021 09:10:11.204:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
30% building 49/49 modules 0 active24 09 2021 09:10:11.394:INFO [launcher]: Starting browser Chrome
30% building 100/100 modules 0 activeSuccess finish launch iigetnktydso0o
finished work!
24 09 2021 09:10:48.910:WARN [karma]: No captured browser, open http://localhost:9876/
24 09 2021 09:10:48.980:INFO [Chrome 94.0.4606.54 (Linux x86_64)]: Connected on socket ei8jThQqm3gmem4IAAAA with id 85348113
...cut...
DavidCirlanaru1 commented 1 year ago

@contd did you manage to find a fix for this issue?