Git Product home page Git Product logo

Comments (14)

glenjamin avatar glenjamin commented on September 25, 2024

What do you have so far? What isn't working?

from mocha-multi.

DeChrish avatar DeChrish commented on September 25, 2024

Currently i am using the below code,

var config = {
mochaTest: {}
};
config.mochaTest[name] = {
options: {
reporter: 'mocha-allure-reporter',
reporterOptions: {
targetDir: allureReportFolderName
},
timeout: 60000,
logErrors: true,
captureFile: directories.target + '/' + name + '/test-results.txt'
},
src: grunt.option("mochatestspecs").split(",")
};

from mocha-multi.

glenjamin avatar glenjamin commented on September 25, 2024

You should be able to use something like this https://github.com/glenjamin/mocha-multi#using-mocha-multi-programmatically

reporter: "mocha-multi",
reporterOptions: {
  "mocha-allure-reporter": {
    options: { "targetDir": allureReportFolderName }
  }
  "xml": {
  // ...
  }
}

from mocha-multi.

DeChrish avatar DeChrish commented on September 25, 2024

how to use other reporter, example i need BOTH allure reporter and tap reporter:

reporter: "mocha-multi",
reporterOptions: {
"mocha-allure-reporter": {
options: { "targetDir": allureReportFolderName }
}
"tap": {
// ...
}
"nyan" :{
// ..
}
}

from mocha-multi.

glenjamin avatar glenjamin commented on September 25, 2024

that example looks right to me, each key in the reporterOptions names another reporter to use.

from mocha-multi.

DeChrish avatar DeChrish commented on September 25, 2024

Error :
Running "mochaTest:endtoend" (mochaTest) task

Mocha exploded!
TypeError: path must be a string
at TypeError (native)
at Object.fs.openSync (fs.js:584:18)****

from mocha-multi.

glenjamin avatar glenjamin commented on September 25, 2024

Sounds like you need to pass a filename to one of your reporters using its reporter options - as it doesn't write to stdout the file handling code from this lib won't affect its destination.

from mocha-multi.

DeChrish avatar DeChrish commented on September 25, 2024

can you explain ?

This is my Grunt file:

module.exports = function webdriverTestSuite(name, grunt, directories) {
    'use-strict';
    require('grunt-mocha-test/tasks/mocha-test')(grunt);
    process.env.BROWSER = grunt.option("browser") || "phantomjs";
    process.env.ENVIRONMENT = grunt.option("environment") || "dev1";
    process.env.PLATFORM = grunt.option("platform") || "desktop"
    process.env.RESULTSDIRSUFFIX = grunt.option("resultsdirsuffix") || "gird"; 

    var tasks = process.env.ENVIRONMENT === "local-unknown" ? ["copy:dist", "build:app-config", "connect:dist"] : ["mochaTest:" + name];
    var d = new Date();
    var allureReportFolderName = 'allure-results' + grunt.option("resultsdirsuffix"); 
    var config = {
        mochaTest: {}
    };
    config.mochaTest[name] = {
        options: {
            reporter: 'mocha-multi',

            reporterOptions: {
                "mocha-allure-reporter": {
                    options: { "targetDir": allureReportFolderName }
                }
            },
          timeout: 60000,
            logErrors: true,
            captureFile: directories.target + '/' + name + '/test-results.txt'
        },
       src: grunt.option("mochatestspecs").split(",")
    };
    console.log("mocha grep config=" + config.mochaTest[name]['options']['grep']);
    grunt.event.once("connect.dist.listening", function() {
        grunt.task.run("mochaTest:" + name);
    });
    grunt.registerTask('test:' + name, 'runs the ' + name + ' selenium tests', tasks);
    grunt.config.merge(config);
}

from mocha-multi.

glenjamin avatar glenjamin commented on September 25, 2024

I can see nothing obviously wrong with that, although it looks like you're only actually doing one output format, so mocha-multi isn't really doing anything useful for you there.

Is that stack trace you provided the full one? it would be helpful to know exactly what was passed to that openSync call which failed.

from mocha-multi.

DeChrish avatar DeChrish commented on September 25, 2024

@glenjamin

Running "mochaTest:endtoend" (mochaTest) task
>> Mocha exploded!
>> TypeError: path must be a string
>>     at TypeError (native)
>>     at Object.fs.openSync (fs.js:584:18)
>>     at Object.fs.writeFileSync (fs.js:1224:33)

>>     at resolveStream (/../node_modules/mocha-multi/mocha-multi.js:162:6)
>>     at /../node_modules/mocha-multi/mocha-multi.js:91:18
>>     at Array.map (native)
>>     at initReportersAndStreams (/../node_modules/mocha-multi/mocha-multi.js:86:16)
>>     at new MochaMulti (/../node_modules/mocha-multi/mocha-multi.js:42:17)
>>     at MochaWrapper.run (/../node_modules/grunt-mocha-test/tasks/lib/MochaWrapper.js:56:27)
>>     at /../node_modules/grunt-mocha-test/tasks/mocha-test.js:86:20
Warning: Task "mochaTest:endtoend" failed. Use --force to continue.

Aborted due to warnings.
Generating Allure Report at location './allure-reports'...
allure generate allure-results-firefox/
cp: allure-results-firefox: No such file or directory
ERROR: Report directory <allure-results-firefox/> is missing.
./runtestsuite: line 9: /../allure-commandline/bin/allure.bat: No such file or directory

from mocha-multi.

glenjamin avatar glenjamin commented on September 25, 2024

Ah ok, you have to specify a target for the reporter being passed to multi, even though allure won't use it:

Try this

                "mocha-allure-reporter": {
                    stdout: "-",
                    options: { "targetDir": allureReportFolderName }
                }

from mocha-multi.

DeChrish avatar DeChrish commented on September 25, 2024

@glenjamin Like a Boss 👏 👏 👏

from mocha-multi.

DeChrish avatar DeChrish commented on September 25, 2024

Hey quick info :

"mocha-allure-reporter": {
                    stdout: "-",
                    options: { "targetDir": allureReportFolderName }
                }

targetDir is not working,
the reports is generated in one particular location: it dont care about the path we are providing ;allureReportFolderName;

from mocha-multi.

glenjamin avatar glenjamin commented on September 25, 2024

That looks like a bug in mocha-allure-reporter, I think this line https://github.com/allure-framework/mocha-allure-reporter/blob/master/index.js#L18 should just be opts.

You can work around it for now by doing:

"mocha-allure-reporter": {
    stdout: "-",
    options: {
        reporterOptions: {
            "targetDir": allureReportFolderName
        }
    }
}

from mocha-multi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.