Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing coverage object- "No coverage object in the browser." #53

Open
garimamathur16 opened this issue Nov 23, 2015 · 1 comment
Open

Comments

@garimamathur16
Copy link

Hi,

While working on code coverage for protractor e2e cases, using grunt-protractor-coverage, I observed this issue on test execution.

PFB the gruntfile.js

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Before generating any new files, remove any previously-created files.
clean: {
tests: ['coverage', 'coverage_reports'],
},
copy: {
coverageE2E: {
files: [{
expand: true,
dot: true,
cwd: '/path/to/base/directory/',
dest: 'coverage/e2e/instrumented/app',
src: [
'WebContent/resources/css/',
'WebContent/resources/fonts/
',
'WebContent/resources/html/',
'WebContent/resources/images/
',
]
}]
}

    },
    instrument: {
                files: ['../WebContent/resources/js/**/*.js'],
                options: {
                    lazy: true,
                    coverageVariable: '__coverage__',
                    basePath: 'coverage/e2e/instrumented/test/'
                }
    },
    connect: {
      server: {
        options: {
          port: 3000,
          hostname: 'localhost',
        }
      },
    },
    protractor_coverage: {
        options: {
            configFile: "node_modules/protractor/example/conf.js", // Default config file 
            keepAlive: true, // If false, the grunt process stops when the test fails. 
            noColor: false, // If true, protractor will not use colors in its output. 
            //coverageDir: 'coverage/e2e/instrumented/',
            //debug: true,
            args: {
                // Arguments passed to the command 
            }
        },
        custom: {  
            options: {
                configFile: "src/conf.js", // Target-specific config file 
                 //coverageDir: 'coverage',
                 //debug: true,
                args: {
                     baseUrl: 'http://localhost:3000/',
                     // Arguments passed to the command
                    //'browser': 'firefox'
                    },

                run: {}
            }
        }
    },
    makeReport: {
      src: 'coverage/**/*.json',
      options: {
        type: 'html',
        dir: 'coverage_reports',
        print: 'detail'
      }
    }




});

//loading grunt task
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.loadNpmTasks('grunt-protractor-coverage');
grunt.loadNpmTasks('grunt-istanbul');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');


//Registering task to be executed

grunt.registerTask('test', ['clean:tests','copy:coverageE2E', 'instrument' ,'connect','protractor_coverage:custom','makeReport']);

};

I suppose while providing the instrumented code to the test case at http://localhost:3000 , there appears to be some problem, as this is acting like base url, to which I have appended application relative paths when doing a browser.get('/testgui'). however, this throws the error-Angular could not be found on the page.

Is there anything I have misunderstood or missed?

Any suggestions?

@SambitKumarPatra
Copy link

i'm also getting the same error with a similar kind of Grunt file.
Resources followed for this setup : https://dzone.com/articles/measuring-code-coverage
If anyone has any updates or workaround for this, do comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants