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?