rschuft / karma-sharding

Karma plugin to allow tests to be distributed across multiple browsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

karma-sharding seems to not run with angular cli

guilhermejcgois opened this issue · comments

commented

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • I'm submitting a ...

    • bug report
    • feature request
    • support request => Please do not submit support request here, see note at the top of this template.
  • Do you want to request a feature or report a bug?

  • What is the current behavior?
    Split my tests on multiple browsers

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
    https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli', 'sharding'],
    browserDisconnectTimeout : 10000,
    browserDisconnectTolerance : 3,
    browserNoActivityTimeout:60000,
    plugins: [
      require('karma-jasmine'),
      require('karma-sharding'),
      require('karma-chrome-launcher'),
      require('karma-mocha-reporter'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    files: [
      { pattern: './src/test.ts', watched: false },
      { pattern: './node_modules/TimelineJS3/compiled/js/timeline.js', watched: false },
      { pattern: './node_modules/TimelineJS3/compiled/css/timeline.css', watched: false },
      { pattern: './node_modules/amcharts3/amcharts/amcharts.js', watched: false },
      { pattern: './node_modules/amcharts3/amcharts/pie.js', watched: false },
      { pattern: './node_modules/amcharts3/amcharts/gauge.js', watched: false },
      { pattern: './node_modules/amcharts3/amcharts/themes/light.js', watched: false }
    ],
    reporters: ['mocha', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome','ChromeNoSandbox'],
    customLaunchers: {
      ChromeNoSandbox: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },
    singleRun: false
  });
};
  • What is the expected behavior?
    That the test was splitted in multiples browsers

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

  • version: 4.3.0
  • Browser: Chrome 62.0.3202.94
  • Language: TypeScript 2.3
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
    Also, running with ['Chrome', 'Chrome'] doesn't launch two browsers.

I am also experiencing this. I was wondering if I had it misconfigured but perhaps it is just not working?
I am also trying to run with ['Chrome', 'Chrome'] and it doesn't seem to be working.

This would be an amazing tool to have, if it were working!

Has there been any update with this? I'm still hoping to some day make use of this

I spent some time looking into the issue. I created a vanilla project using the @angular/cli module. I then generated an additional component so there would be at least two specs. I ran the tests with ng test --single-run after adding enough configuration to load the karma-sharding framework.

Here are my findings:

  • Sharding relies on middleware to divide up spec files that match a file naming convention
  • Webpack is configured to produce one file: main.bundle.js
  • Sharding then doesn't engage because of the name and the count so all tests fire on all browsers

Unfortunately this isn't something sharding is designed to work with. You could try the code splitting feature to produce multiple bundles and override the sharding config for the spec matcher to divide them up but the side effect is that it doesn't know what to do without manual intervention and you're left in the same position you would be if you split them by hand defeating most of the convenience of karma-sharding.

I don't have a good approach for getting around this currently.

You could try karma-parallel which was just released to see if the approach of dividing up the describe blocks themselves works for you.

I looked at it and it looks promising. Thank you very much for your help and effort!