最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - Trying to run some slow tests concurrently - Stack Overflow

programmeradmin3浏览0评论

I'm testing a date/time UI widget that lets you roll individual digits up or down by using either arrow keys or by clicking on graphical up/down arrows. If you press a key and hold it, or click/tap an arrow without immediately letting go, you get an auto-repeating effect until the key/mouse button/tap is released.

In testing this I'm simulating letting the auto-repeat run for two seconds each time – which takes two seconds of real time to do. Before I add more tests of this nature, however, I'd love to figure out how to make such tests run concurrently rather than consecutively.

I've followed all the instructions I could find online for getting this to work, but no change yet in how long it takes for the complete set of tests to run. Execution remains consecutive rather than parallel.

Here's my karma.conf.js:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-parallel'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    parallelOptions: {
      executors: (require('os').cpus().length),
      shardStrategy: 'round-robin'
    },
    client: {
      jasmine: {},
    },
    jasmineHtmlReporter: {
      suppressAll: true
    },
    coverageReporter: {
      dir: require('path').join(__dirname, './coverage/temp'),
      subdir: '.',
      reporters: [
        { type: 'html' },
        { type: 'text-summary' }
      ]
    },
    reporters: ['progress', 'kjhtml'],
    browsers: ['Chrome'],
    restartOnFileChange: true
  });
};

The relevant portion of my angular.json:

        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "tsConfig": "projects/tubular-ng-widgets/tsconfig.spec.json",
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "karmaConfig": "karma.conf.js"
          }
        }

And the tests themselves:

  it('should do upward auto-repeated digit rolling', async () => {
    await clickDigit(digits.length - 1); // Roll one second forward repeatedly
    await sendKey('ArrowUp', 2000);
    expect(timeEditor.value - (sampleTimeMs + 17000)).toBeLessThan(3000);
  });

  it('should do downward auto-repeated digit rolling', async () => {
    await clickDigit(digits.length - 2); // Roll ten seconds backward repeatedly
    await sendKey('ArrowDown', 2000);
    expect(timeEditor.value - (sampleTimeMs - 170000)).toBeLessThan(30000);
  });

  it('should do upward auto-repeated digit rolling via up-arrow icon', async () => {
    await clickDigit(digits.length - 1); // Roll one second forward repeatedly
    await sendTestClick(upArrow, fixture, 2000);
    expect(timeEditor.value - (sampleTimeMs + 17000)).toBeLessThan(3000);
  });

Can anyone see anything obvious I'm missing?

发布评论

评论列表(0)

  1. 暂无评论