I've found Jasmine 2.4's page on testing node.js files, and it even mentions setting the spec and source files in the spec/support/jasmine.json file. But neither the online examples nor the jasmine examples
show anything on how to tell jasmine where to find the source files.
So I keep getting ReferenceErrors because it doesn't seem to be reading in my source files. It should be noted that for now I'm just using this to teach some students about testing, and using their single-file toy projects for practice. (Like a CLI Hangman Game, that sort of thing.) So for now there's no module.exports going on, although some of their projects to use require()
to bring in third-party modules. I was using Karma until I realized that's only supposed to be for browser JavaScript, and require
kept failing.
Edit: I just found this post that is asking basically the same thing, but I don't want to use grunt just to make Jasmine read in a source file. Seems like something that should be built in, like how Karma asks for where your source and spec files are.
Second Edit: I shouldn't have to put this here, but Emarco marked my question as a duplicate of the one I linked in my first edit above, even though I very specifically explained why that other post doesn't answer my question.
FWIW I've found that listing my source files in the helpers
list works..
{
"spec_dir": "spec",
"spec_files": [
"fooSpec.js",
"barSpec.js"
],
"helpers": [
"../src/foo.js",
"../src/bar.js"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With