Adding globals
Closed this issue · 4 comments
TomBarryy commented
Hi, I am coming across the following error: myVar
is not defined.
Here myVar
is a global variable. Is there a way to indicate this in the grunt file?
The relevant part of my gruntfile:
mocha_istanbul: {
coverage: {
src: 'build/**/*.js',
options: {
mask: '**/*.js',
coverage: true,
coverageFolder: "test/coverage",
print: "detail",
reportFormats: ['lcovonly']
}
}
},
Thanks.
pocesar commented
that's a mocha issue, you should try adding:
{
options:{
mochaOptions: ['--globals', 'myVar']
}
}
and see if it works for you.
TomBarryy commented
Do you mean change it to:
mocha_istanbul: {
options: {
mochaOptions: ['--globals', 'myVar']
},
coverage: {
src: 'build/**/*.js',
options: {
mask: '**/*.js',
coverage: true,
coverageFolder: "test/coverage",
print: "detail",
reportFormats: ['lcovonly']
}
}
},
If so, I still get the same issue.
Any other suggestions?
pocesar commented
are your test files in build/**/*.js
? you should be adding only the tests files in src
. also mask
option overrides the src
.
TomBarryy commented
Ah I found my error, the build directory was not complete due to an error elsewhere.
Thanks for the help!