grunt-contrib-qunit | Run QUnit tests in Headless Chrome | Content Management System library

 by   gruntjs JavaScript Version: 7.0.0 License: MIT

kandi X-RAY | grunt-contrib-qunit Summary

grunt-contrib-qunit is a JavaScript library typically used in Web Site, Content Management System applications. grunt-contrib-qunit has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub, Maven.
Run QUnit unit tests in a headless Chrome instance.
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        grunt-contrib-qunit has a low active ecosystem.
                        summary
                        It has 212 star(s) with 112 fork(s). There are 18 watchers for this library.
                        summary
                        There were 2 major release(s) in the last 6 months.
                        summary
                        There are 6 open issues and 91 have been closed. On average issues are closed in 159 days. There are 1 open pull requests and 0 closed requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of grunt-contrib-qunit is 7.0.0
                        grunt-contrib-qunit Support
                          Best in #Content Management System
                            Average in #Content Management System
                            grunt-contrib-qunit Support
                              Best in #Content Management System
                                Average in #Content Management System

                                  kandi-Quality Quality

                                    summary
                                    grunt-contrib-qunit has 0 bugs and 0 code smells.
                                    grunt-contrib-qunit Quality
                                      Best in #Content Management System
                                        Average in #Content Management System
                                        grunt-contrib-qunit Quality
                                          Best in #Content Management System
                                            Average in #Content Management System

                                              kandi-Security Security

                                                summary
                                                grunt-contrib-qunit has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                grunt-contrib-qunit code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                grunt-contrib-qunit Security
                                                  Best in #Content Management System
                                                    Average in #Content Management System
                                                    grunt-contrib-qunit Security
                                                      Best in #Content Management System
                                                        Average in #Content Management System

                                                          kandi-License License

                                                            summary
                                                            grunt-contrib-qunit is licensed under the MIT License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            grunt-contrib-qunit License
                                                              Best in #Content Management System
                                                                Average in #Content Management System
                                                                grunt-contrib-qunit License
                                                                  Best in #Content Management System
                                                                    Average in #Content Management System

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        grunt-contrib-qunit releases are available to install and integrate.
                                                                        summary
                                                                        Deployable package is available in Maven.
                                                                        summary
                                                                        Installation instructions, examples and code snippets are available.
                                                                        grunt-contrib-qunit Reuse
                                                                          Best in #Content Management System
                                                                            Average in #Content Management System
                                                                            grunt-contrib-qunit Reuse
                                                                              Best in #Content Management System
                                                                                Average in #Content Management System
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi has reviewed grunt-contrib-qunit and discovered the below as its top functions. This is intended to give you an instant insight into grunt-contrib-qunit implemented functionality, and help decide if they suit your requirements.
                                                                                  • generates the summary
                                                                                    • Combines a result object and returns the combined data .
                                                                                      • Formats an error .
                                                                                        • Finish the browser
                                                                                          • Format a message .
                                                                                            • Resolves a relative URL to the current working directory .
                                                                                              • send the current message
                                                                                                Get all kandi verified functions for this library.
                                                                                                Get all kandi verified functions for this library.

                                                                                                grunt-contrib-qunit Key Features

                                                                                                Run QUnit tests in Headless Chrome.

                                                                                                grunt-contrib-qunit Examples and Code Snippets

                                                                                                No Code Snippets are available at this moment for grunt-contrib-qunit.
                                                                                                Community Discussions

                                                                                                Trending Discussions on grunt-contrib-qunit

                                                                                                Cannot Read Property 'start' of undefined using gulp.js
                                                                                                chevron right

                                                                                                Trending Discussions on grunt-contrib-qunit

                                                                                                QUESTION

                                                                                                Cannot Read Property 'start' of undefined using gulp.js
                                                                                                Asked 2021-Aug-04 at 13:43

                                                                                                So, I have 1 error in my GULP when I use the following:

                                                                                                node ./node_modules/gulp/bin/gulp.js test
                                                                                                

                                                                                                Here's the error I'm getting when I run: node ./node_modules/gulp/bin/gulp.js test

                                                                                                PS C:\Users\myuser\repos\wwwroot\acqustn-aem-global-comps\ui.apps> node 
                                                                                                ./node_modules/gulp/bin/gulp.js test
                                                                                                [09:41:14] Using gulpfile ~\repos\wwwroot\global-comps\ui.apps\gulpfile.js
                                                                                                [09:41:14] Starting 'test'...
                                                                                                [09:41:14] 'test' errored after 4.45 ms
                                                                                                [09:41:14] TypeError: Cannot read property 'start' of undefined
                                                                                                at C:\Users\myuser\repos\wwwroot\global-comps\ui.apps\gulpfile.js:12:11
                                                                                                at test (C:\Users\myuser\repos\wwwroot\global-comps\ui.apps\node_modules\undertaker\lib\set-task.js:13:15)     
                                                                                                at bound (domain.js:426:14)
                                                                                                at runBound (domain.js:439:12)
                                                                                                at asyncRunner (C:\Users\myuser\repos\wwwroot\global-comps\ui.apps\node_modules\async-done\index.js:55:18)     
                                                                                                at processTicksAndRejections (internal/process/task_queues.js:79:11)
                                                                                                

                                                                                                Here is my karma.conf.js file that's formatted in the following manner. I'm adding more text here because I have to as I cannot post unless I describe more information

                                                                                                module.exports = function (config) {
                                                                                                  const process = require('process');
                                                                                                  process.env.CHROME_BIN = require('puppeteer').executablePath();
                                                                                                  config.set({
                                                                                                
                                                                                                    // base path that will be used to resolve all patterns (eg. files, exclude)
                                                                                                    basePath: '',
                                                                                                
                                                                                                
                                                                                                    // frameworks to use
                                                                                                    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
                                                                                                    frameworks: ['jasmine-jquery', 'jasmine'],
                                                                                                
                                                                                                    plugins: [
                                                                                                      require('jquery'),
                                                                                                      require('karma-junit-reporter'),
                                                                                                      require('karma-coverage'),
                                                                                                      require('karma-jasmine-jquery-2'),
                                                                                                      require('karma-jasmine'),
                                                                                                      require('karma-chrome-launcher'),
                                                                                                      require('karma-jasmine-html-reporter'),
                                                                                                      require('karma-phantomjs-launcher'),
                                                                                                      require('karma-coverage-istanbul-reporter'),
                                                                                                      require('@angular-devkit/build-angular/plugins/karma'),
                                                                                                      require('karma-sonarqube-unit-reporter')
                                                                                                    ],
                                                                                                    client: {
                                                                                                      clearContext: false // leave Jasmine Spec Runner output visible in browser
                                                                                                    },
                                                                                                    coverageIstanbulReporter: {
                                                                                                      dir: require('path').join(__dirname, './coverage/global-comps'),
                                                                                                      reports: ['lcovonly', 'text-summary'],
                                                                                                      fixWebpackSourcePaths: true
                                                                                                    },
                                                                                                    // list of files / patterns to load in the browser
                                                                                                    files: [
                                                                                                      './src/main/content/jcr_root/etc/designs/global-components/footer/**/*.js',
                                                                                                      './src/main/content/jcr_root/etc/designs/global-components/header/**/*.js',
                                                                                                      './src/main/content/jcr_root/etc/designs/global-components/action/**/*.js'
                                                                                                    ],
                                                                                                
                                                                                                
                                                                                                    // list of files / patterns to exclude
                                                                                                    exclude: [
                                                                                                    ],
                                                                                                
                                                                                                
                                                                                                    // preprocess matching files before serving them to the browser
                                                                                                    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
                                                                                                    preprocessors: {
                                                                                                      './test/navigationClientLibs/js/header.spec.js': ['coverage']
                                                                                                    },
                                                                                                
                                                                                                
                                                                                                    // test results reporter to use
                                                                                                    // possible values: 'dots', 'progress'
                                                                                                    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
                                                                                                    reporters: ['junit', 'progress', 'kjhtml', 'coverage-istanbul', 'sonarqubeUnit', 'coverage'],
                                                                                                    sonarQubeUnitReporter: {
                                                                                                      sonarQubeVersion: 'LATEST',
                                                                                                      outputFile: 'reports/ut_report.xml',
                                                                                                      overrideTestDescription: true,
                                                                                                      testPaths: ['./test/navigationClientLibs/'],
                                                                                                      testFilePattern: '.js',
                                                                                                      useBrowserName: false
                                                                                                    },
                                                                                                
                                                                                                    // web server port
                                                                                                    port: 9876,
                                                                                                
                                                                                                
                                                                                                    // enable / disable colors in the output (reporters and logs)
                                                                                                    colors: true,
                                                                                                
                                                                                                
                                                                                                    // level of logging
                                                                                                    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
                                                                                                    logLevel: config.LOG_INFO,
                                                                                                
                                                                                                
                                                                                                    // enable / disable watching file and executing tests whenever any file changes
                                                                                                    autoWatch: false,
                                                                                                
                                                                                                
                                                                                                    // start these browsers
                                                                                                    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
                                                                                                    browsers: ['PhantomJS'],
                                                                                                
                                                                                                    // Continuous Integration mode
                                                                                                    // if true, Karma captures browsers, runs the tests and exits
                                                                                                    singleRun: true,
                                                                                                
                                                                                                    // Concurrency level
                                                                                                    // how many browser should be started simultaneous
                                                                                                    concurrency: Infinity,
                                                                                                
                                                                                                    junitReporter: {
                                                                                                      outputFile: 'reports/junit/TESTS-xunit.xml'
                                                                                                    },
                                                                                                
                                                                                                    coverageReporter: {
                                                                                                      type: 'lcov',
                                                                                                      dir: 'reports',
                                                                                                      subdir: 'coverage'
                                                                                                    }
                                                                                                  })
                                                                                                }
                                                                                                

                                                                                                Now my GULP FILE which is failing with karma.start() whenever I run the following node ./node_modules/gulp/bin/gulp.js test at the command prompt in VS Code Terminal

                                                                                                    var gulp = require('gulp');
                                                                                                    var karma = require('karma').server;
                                                                                                    var replace = require('gulp-replace');
                                                                                                
                                                                                                    var postprocessLCOV = function() {
                                                                                                        return gulp.src('reports/coverage/lcov.info')
                                                                                                            .pipe(replace('SF:.', 'SF:frontend-project'))
                                                                                                            .pipe(gulp.dest('reports/coverage'));
                                                                                                    };
                                                                                                
                                                                                                    gulp.task('test', function () {
                                                                                                        karma.start({
                                                                                                            configFile: __dirname + '/src/test/js/karma.conf.ci.js'
                                                                                                        }, postprocessLCOV);
                                                                                                    });
                                                                                                

                                                                                                Of Note: My karma.conf.js and .ci.js are exactly the same so I don't have to post both files here.

                                                                                                Finally, my package.json which shows everything I'm using. Whenever I added an new library, I have to delete the package.lock.json, after the new library is installed then re-run npm install.

                                                                                                {
                                                                                                  "name": "global-comps",
                                                                                                  "version": "1.0.0",
                                                                                                  "description": "This is for the Navigator",
                                                                                                  "main": "qunit.js",
                                                                                                  "scripts": {
                                                                                                    "lint": "eslint '**/*.js'",
                                                                                                    "test": "qunit",
                                                                                                    "compodoc": "npx compodoc -p tsconfig.doc.json",
                                                                                                    "ng": "ng",
                                                                                                    "clean": "rm -rf node*",
                                                                                                    "ng-cli": "npm install --no-optional @angular/cli",
                                                                                                    "start": "ng serve --proxy-config proxy.config.json",
                                                                                                    "build": "ng build",
                                                                                                    "prod": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod --output-hashing none && npm run test && npm run clean",
                                                                                                    "e2e": "ng e2e",
                                                                                                    "sonar": "sonar-scanner"
                                                                                                  },
                                                                                                  "repository": {
                                                                                                    "type": "git",
                                                                                                    "url": "somerepo.git"
                                                                                                  },
                                                                                                  "author": "Some Author",
                                                                                                  "license": "MIT",
                                                                                                  "dependencies": {
                                                                                                    "@angular/common": "~9.0.2",
                                                                                                    "@angular/compiler": "~9.0.2",
                                                                                                    "@angular/core": "~9.0.2",
                                                                                                    "@angular/platform-browser": "~9.0.2",
                                                                                                    "@angular/platform-browser-dynamic": "~9.0.2",
                                                                                                    "@angular/router": "~9.0.2",
                                                                                                    "@types/mocha": "^9.0.0",
                                                                                                    "JSONPath": "^0.11.2",
                                                                                                    "browserify": "^17.0.0",
                                                                                                    "common-js": "^0.3.8",
                                                                                                    "eslint-plugin-qunit": "^6.1.1",
                                                                                                    "jquery": "^3.4.1",
                                                                                                    "jquery-browserify": "^1.8.1",
                                                                                                    "jsdom": "^16.5.3",
                                                                                                    "junit": "^1.4.9",
                                                                                                    "karma-junit-reporter": "^2.0.1",
                                                                                                    "ng-mocks": "^11.10.1",
                                                                                                    "node": "^15.12.0",
                                                                                                    "npm-check-updates": "^11.5.13",
                                                                                                    "phantomjs": "^2.1.7",
                                                                                                    "qunit-reporter-junit": "^1.1.1",
                                                                                                    "qunit-reporter-lcov": "^1.0.2",
                                                                                                    "require": "^2.4.20",
                                                                                                    "rxjs": "~6.5.4",
                                                                                                    "tslib": "^1.10.0"
                                                                                                  },
                                                                                                  "devDependencies": {
                                                                                                    "@angular-devkit/build-angular": "^12.1.3",
                                                                                                    "@angular-devkit/build-webpack": "^0.1201.3",
                                                                                                    "@angular/compiler-cli": "~9.0.2",
                                                                                                    "@types/jasmine": "~3.5.0",
                                                                                                    "@types/jasminewd2": "~2.0.3",
                                                                                                    "@types/jsdom": "^16.2.13",
                                                                                                    "@types/node": "^12.11.1",
                                                                                                    "codelyzer": "^5.1.2",
                                                                                                    "grunt": "^1.3.0",
                                                                                                    "grunt-contrib-connect": "^3.0.0",
                                                                                                    "grunt-contrib-copy": "^1.0.0",
                                                                                                    "grunt-contrib-qunit": "^4.0.0",
                                                                                                    "grunt-git-authors": "^3.2.0",
                                                                                                    "grunt-search": "^0.1.8",
                                                                                                    "gulp": "^4.0.2",
                                                                                                    "gulp-replace": "^1.1.3",
                                                                                                    "jasmine-core": "~3.5.0",
                                                                                                    "jasmine-spec-reporter": "~4.2.1",
                                                                                                    "karma": "^6.3.2",
                                                                                                    "karma-chrome-launcher": "^3.1.0",
                                                                                                    "karma-coverage": "^2.0.3",
                                                                                                    "karma-coverage-istanbul-reporter": "^3.0.3",
                                                                                                    "karma-jasmine": "^4.0.1",
                                                                                                    "karma-jasmine-html-reporter": "^1.7.0",
                                                                                                    "karma-jasmine-jquery-2": "^0.1.1",
                                                                                                    "karma-mocha-reporter": "^2.2.5",
                                                                                                    "karma-phantomjs-launcher": "^1.0.4",
                                                                                                    "karma-qunit": "^4.1.2",
                                                                                                    "karma-sonarqube-unit-reporter": "0.0.23",
                                                                                                    "karma-webpack": "^5.0.0",
                                                                                                    "protractor": "~5.4.3",
                                                                                                    "puppeteer": "^1.20.0",
                                                                                                    "sonar-scanner": "^3.1.0",
                                                                                                    "sonarqube-scanner": "~2.7.0",
                                                                                                    "ts-node": "~8.3.0",
                                                                                                    "typescript": "~3.7.5"
                                                                                                  },
                                                                                                  "global": "window"
                                                                                                }
                                                                                                

                                                                                                So, that's where I'm at.

                                                                                                UPDATE!

                                                                                                So, I've abandoned GULP and got Karma to work.

                                                                                                But in SONARQUBE, what I'm getting is 0% coverage because Karma is NOT creating the lcov.info file even though it's creating the coverage directory and subsequent files.

                                                                                                OF NOTE: I can run my tests in the browser in QUNIT and see them succeed or fail in either case.

                                                                                                BUT I need KARMA to create the lcov.info file with the tests I've created in my .js file. Since this is not Angular but just pure JavaScript, that's where I'm stuck.

                                                                                                Here's a screen shot of my SONARQUBE Coverage to show you what I'm getting.

                                                                                                I'd really like some help here.

                                                                                                Again, here are the Two SIMPLE test files that I'm running using QUNIT that work but are NOT when I run them in KARMA.

                                                                                                Thank you everyone for your continued support.

                                                                                                    describe('A Suite for a simple test', () => {
                                                                                                
                                                                                                        var a;
                                                                                                
                                                                                                        it('and so it is a spec', () => {
                                                                                                            a = true;
                                                                                                            expect(a).toBe(true);
                                                                                                        });
                                                                                                
                                                                                                        it('2 plus 2 should be 4', () => {
                                                                                                            const result = add(2, 2);
                                                                                                
                                                                                                            expect(result).toBe(4);
                                                                                                
                                                                                                        });
                                                                                                
                                                                                                    });
                                                                                                
                                                                                                    describe('Test case 1', () => {
                                                                                                        var zipcodevalue = '';
                                                                                                
                                                                                                        const test1 = sendToTest1;
                                                                                                
                                                                                                        console.log('Test 1 is: ', test1);
                                                                                                
                                                                                                        beforeEach(function () {
                                                                                                            zipToTestCase.call(this, {
                                                                                                                assert: assert,
                                                                                                                zipcodevalue: '98237',
                                                                                                                expected: "Success"
                                                                                                            });
                                                                                                        });
                                                                                                
                                                                                                        function zipToTestCase() {
                                                                                                
                                                                                                            if (isNaN(zipcodevalue === false)) {
                                                                                                                expect(zipcodevalue, '98237', 'string value and hard code value are NOT equal', function (callback) {
                                                                                                                    callback(zipcodevalue);
                                                                                                                });
                                                                                                            } else {
                                                                                                                expect(zipcodevalue, '98237', 'string value and hard code value are equal', function (callback) {
                                                                                                                    callback(zipcodevalue);
                                                                                                                });
                                                                                                            }
                                                                                                
                                                                                                        }
                                                                                                
                                                                                                        it('test for Valid ZipCode', () => {
                                                                                                            expect(zipcodevalue).toBeTruthy();
                                                                                                        })
                                                                                                
                                                                                                        it('test for INValid ZipCode', () => {
                                                                                                            expect(zipcodevalue).toBeFalsy();
                                                                                                        })
                                                                                                
                                                                                                    });
                                                                                                

                                                                                                ANSWER

                                                                                                Answered 2021-Aug-04 at 13:43

                                                                                                I found the answer here with this article!

                                                                                                https://sourcedcode.com/blog/aem/how-to-write-javascript-unit-tests-for-aem-client-libraries-with-jest

                                                                                                This is EXACTLY what I needed and the results are PERFECT!

                                                                                                Source https://stackoverflow.com/questions/68594875

                                                                                                Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                                Vulnerabilities

                                                                                                No vulnerabilities reported

                                                                                                Install grunt-contrib-qunit

                                                                                                If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:.

                                                                                                Support

                                                                                                For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
                                                                                                Find more information at:
                                                                                                Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                Find more libraries
                                                                                                Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                Save this library and start creating your kit
                                                                                                Install
                                                                                              • npm

                                                                                                npm i grunt-contrib-qunit

                                                                                              • CLONE
                                                                                              • HTTPS

                                                                                                https://github.com/gruntjs/grunt-contrib-qunit.git

                                                                                              • CLI

                                                                                                gh repo clone gruntjs/grunt-contrib-qunit

                                                                                              • sshUrl

                                                                                                git@github.com:gruntjs/grunt-contrib-qunit.git

                                                                                              • Share this Page

                                                                                                share link

                                                                                                Explore Related Topics

                                                                                                Reuse Pre-built Kits with grunt-contrib-qunit

                                                                                                Consider Popular Content Management System Libraries

                                                                                                Try Top Libraries by gruntjs

                                                                                                grunt

                                                                                                by gruntjsJavaScript

                                                                                                grunt-contrib-watch

                                                                                                by gruntjsJavaScript

                                                                                                grunt-contrib-uglify

                                                                                                by gruntjsJavaScript

                                                                                                grunt-contrib-imagemin

                                                                                                by gruntjsJavaScript

                                                                                                grunt-contrib-sass

                                                                                                by gruntjsJavaScript

                                                                                                Compare Content Management System Libraries with Highest Support

                                                                                                Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                Find more libraries
                                                                                                Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                Save this library and start creating your kit