Skip to content

Commit

Permalink
Fixed --open cli argument wasn't working properly (#3459)
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityvi authored Nov 1, 2022
1 parent f2916a6 commit ab253b9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/runner/test-runners/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DefaultRunner {
this.addtOpts = addtOpts;
this.publishReport = true; // in-case of an uncaught exception, the report will not be published
this.globalReporter = new GlobalReporter(argv.reporter, settings, {
open: argv.open,
openReport: argv.open,
reportFileName: argv['report-filename']
});
}
Expand Down
54 changes: 50 additions & 4 deletions test/src/runner/testReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ describe('testReporter', function() {
if (err) {
return done(err);
}
mockery.enable({useCleanCache: true, warnOnReplace: false, warnOnUnregistered: false});
done();
});
});

// afterEach(function(done) {
// rimraf('output', done);
// });

afterEach(function(done) {
mockery.deregisterAll();
mockery.resetCache();
mockery.disable();
rimraf('output', done);
});


after(function(done) {
this.server.close(function() {
Expand Down Expand Up @@ -94,7 +100,6 @@ describe('testReporter', function() {
});

it('test with valid reporter from NPM', function() {
mockery.enable({useCleanCache: true, warnOnUnregistered: false});
mockery.registerMock('nightwatch_reporter', {
async write(results, options) {

Expand Down Expand Up @@ -174,4 +179,45 @@ describe('testReporter', function() {

assert.strictEqual(possibleError, null);
});

it('test run tests with default reporters - open the html report', async function () {
let htmlFile;

mockery.registerMock('open', function(filename) {
htmlFile = filename;

return Promise.resolve();
});

let possibleError = null;
const testsPath = [path.join(__dirname, '../../sampletests/simple/test/sample.js')];

try {
await runTests({
source: testsPath,
open: true
},
settings({
output_folder: 'output',
globals: {
waitForConditionPollInterval: 20,
waitForConditionTimeout: 50,
retryAssertionTimeout: 50,
reporter: function () {}
},
silent: true,
output: false
}));

await readFilePromise(`output${path.sep}FIREFOX_TEST_firefox__sample.xml`);
await readFilePromise(`output${path.sep}FIREFOX_TEST_firefox__sample.json`);
await readDirPromise(`output${path.sep}nightwatch-html-report`);
} catch (error) {
possibleError = error;
}

assert.strictEqual(possibleError, null);
assert.strictEqual(htmlFile, `output${path.sep}nightwatch-html-report${path.sep}index.html`);

});
});

0 comments on commit ab253b9

Please # to comment.