-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
HTML reporter used on CLI gets ReferenceError: document is not defined #1906
Comments
This sounds like the same issue as #1816 |
I'm getting the same error with gulp-mocha 2.2.0 and mocha 2.1.0. My gulpfile: var gulp = require('gulp');
var mocha = require('gulp-mocha');
gulp.task('tests', function() {
return gulp.src('./test/**/*.js', {read: false})
.pipe(mocha({reporter: 'html', timeout: 2000}));
}); The error: vagrant@vagrant-ubuntu-trusty-64:/home/app/app-api$ gulp tests
[14:48:47] Warning: gulp version mismatch:
[14:48:47] Global gulp is 3.9.1
[14:48:47] Local gulp is 3.9.0
[14:48:52] Using gulpfile /home/app/app-api/gulpfile.js
[14:48:52] Starting 'tests'...
starting api...
finished loading api...
reading config: development
[14:48:58] 'tests' errored after 6.41 s
[14:48:58] ReferenceError in plugin 'gulp-mocha'
Message:
document is not defined
Stack:
ReferenceError: document is not defined
at fragment (/home/app/app-api/node_modules/mocha/lib/reporters/html.js:228:13)
at new HTML (/home/app/app-api/node_modules/mocha/lib/reporters/html.js:50:14)
at Mocha.run (/home/app/app-api/node_modules/mocha/lib/mocha.js:427:18)
at Domain.<anonymous> (/home/app/app-api/node_modules/gulp-mocha/index.js:56:20)
at Domain.run (domain.js:228:14)
at Stream.<anonymous> (/home/app/app-api/node_modules/gulp-mocha/index.js:54:5)
at _end (/home/app/app-api/node_modules/through/index.js:65:9)
at Stream.stream.end (/home/app/app-api/node_modules/through/index.js:74:5)
at DestroyableTransform.onend (/home/app/app-api/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:523:10)
at DestroyableTransform.g (events.js:260:16)
at emitNone (events.js:72:20)
at DestroyableTransform.emit (events.js:166:7)
at /home/app/app-api/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickDomainCallback (node.js:390:13) |
hi any update on this issue is it fixed yet. I am getting this issue when working with abao and using --reporter as html |
I'm getting this as well, when testing a angular2 app in a meteor app
|
The HTML reporter is not currently intended to be used on the CLI, but rather is Mocha's browser reporter. We need to improve the documentation on the site concerning this, and/or remove this reporter's availability from the CLI (it isn't immediately obvious why Users who want HTML-formatted output but not necessarily the same interface as the browser usage may also be interested in the |
Hi, |
@kunjarani You could use JSDOM so it can run the html reporter from CLI with-out a failure about a missing document. I've created a basic script to start Mocha.js with that reporter here. It's creating two globals (document & window) and also a mock of Not perfect because just the html structure of the main file is rendered. So no working links and no JavaScript or CSS in the generated html file. Maybe I'll check later if it's possible to improve these points. |
@AWolf81 Tq for the response. The issue got resolved in another way. Actually gulp-spawn-mocha-nyc is internally using mocha to execute the unit tests and nyc to create a code coverage report. var gulp = require('gulp'); gulp.task('tests', function() { here we are sending params reporter:'html' which internally accepted by Mocha and as mocha is not able to create browser dependent report hence throwing the error. gulp.task('tests', () =>{ Try this out to execute unit tests and generate a code coverage report in html format using |
I am using mocha testing framework to test Http rest-api. I want to generate test-report for all test case, but when I ran mocha --reporter html > report.html
Getting following error
/usr/local/lib/node_modules/mocha/lib/reporters/html.js:263
var div = document.createElement('div');
^
ReferenceError: document is not defined
at fragment (/usr/local/lib/node_modules/mocha/lib/reporters/html.js:263:13)
at new HTML (/usr/local/lib/node_modules/mocha/lib/reporters/html.js:53:14)
at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:459:18)
at Object. (/usr/local/lib/node_modules/mocha/bin/_mocha:393:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:
The text was updated successfully, but these errors were encountered: