Add ability to run only a specific module from CLI.

This commit is contained in:
Aiosa 2024-11-01 22:06:18 +01:00
parent f127014f0f
commit cf65f1a4f4
2 changed files with 17 additions and 2 deletions

View File

@ -61,6 +61,10 @@ Our tests are based on [QUnit](https://qunitjs.com/) and [Puppeteer](https://git
grunt test grunt test
To test a specific module (`navigator` here) only:
grunt test --module="navigator"
If you wish to work interactively with the tests or test your changes: If you wish to work interactively with the tests or test your changes:
grunt connect watch grunt connect watch
@ -69,6 +73,12 @@ and open `http://localhost:8000/test/test.html` in your browser.
Another good page, if you want to interactively test out your changes, is `http://localhost:8000/test/demo/basic.html`. Another good page, if you want to interactively test out your changes, is `http://localhost:8000/test/demo/basic.html`.
> Note: corresponding npm commands for the above are:
> - npm run test
> - npm run test -- --module="navigator"
> - npm run dev
You can also get a report of the tests' code coverage: You can also get a report of the tests' code coverage:
grunt coverage grunt coverage

View File

@ -81,6 +81,11 @@ module.exports = function(grunt) {
grunt.config.set('gitInfo', rev); grunt.config.set('gitInfo', rev);
}); });
let moduleFilter = '';
if (grunt.option('module')) {
moduleFilter = '?module=' + grunt.option('module')
}
// ---------- // ----------
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
@ -166,7 +171,7 @@ module.exports = function(grunt) {
qunit: { qunit: {
normal: { normal: {
options: { options: {
urls: [ "http://localhost:8000/test/test.html" ], urls: [ "http://localhost:8000/test/test.html" + moduleFilter ],
timeout: 10000, timeout: 10000,
puppeteer: { puppeteer: {
headless: 'new' headless: 'new'
@ -175,7 +180,7 @@ module.exports = function(grunt) {
}, },
coverage: { coverage: {
options: { options: {
urls: [ "http://localhost:8000/test/coverage.html" ], urls: [ "http://localhost:8000/test/coverage.html" + moduleFilter ],
coverage: { coverage: {
src: ['src/*.js'], src: ['src/*.js'],
htmlReport: coverageDir + '/html/', htmlReport: coverageDir + '/html/',