问题
In my MEAN project directory, I am trying to run Jasmine unit tests on my express controller. I was initially running node-jasmine however for added functionality I am changing to Jasmine 2.4. However I am running into problems with the location of the jasmine.json, and when I try and workaround, I run into errors in the jasmine source code.
My jasmine.json currently reads:
{
"spec_dir": "spec",
"spec_files": "**/*[sS]pec.js"
}
My file structure is: http://imgur.com/WHg0u8M
my jasmine.json is within support, my model unit tests are in server/controllers/notesSpec.js. If I try to change this with:
jasmine JASMINE_CONFIG_PATH=test/spec/support/jasmine.json
I have tried console logging the source code, some of which you can see below. However, I am still getting the following error:
config file path is: /Users/matthewbridges/Projects/markpad/spec/support/jasmine.json
config file is: [object Object]
the spec directory is: undefined
files are: **/*[sS]pec.js
/usr/local/lib/node_modules/jasmine/lib/jasmine.js:116
files.forEach(function(specFile) {
^
TypeError: files.forEach is not a function
pulling the jasmine.json into the default file path still brings up the same errors.
I'll also add the potentially relevant bits of my package.json
scripts: "test-jasmine": "jasmine test/server/controllers/notesSpec.js"
dev-dependencies:
"devDependencies": {
"autoprefixer-core": "^5.2.1",
"frisby": "^0.8.5",
"grunt": "^0.4.5",
"grunt-angular-templates": "^0.5.7",
"grunt-concurrent": "^1.0.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-copy": "^0.7.0",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-sass": "^1.0.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-express": "^1.4.1",
"grunt-filerev": "^2.1.2",
"grunt-google-cdn": "^0.4.3",
"grunt-jscs": "^1.8.0",
"grunt-karma": "^0.12.2",
"grunt-mongo-bin": "^0.1.0",
"grunt-newer": "^1.1.0",
"grunt-ng-annotate": "^0.9.2",
"grunt-parallel": "^0.4.1",
"grunt-postcss": "^0.5.5",
"grunt-protractor-runner": "^3.1.0",
"grunt-protractor-webdriver": "^0.2.5",
"grunt-svgmin": "^2.0.0",
"grunt-usemin": "^3.0.0",
"grunt-wiredep": "^2.0.0",
"jasmine": "^2.4.1",
"jit-grunt": "^0.9.1",
"jshint-stylish": "^1.0.0",
"karma": "^0.13.22",
"karma-jasmine": "^0.3.8",
"karma-phantomjs-launcher": "^1.0.0",
"method-override": "^2.3.5",
"mocha": "^2.4.5",
"mongoose": "^4.4.9",
"node-mocks-http": "^1.5.2",
"phantomjs-prebuilt": "^2.1.6",
"prettyjson": "^1.1.3",
"protractor": "^3.2.1",
"should": "^8.2.2",
"time-grunt": "^1.0.0",
"webdriver-manager": "^8.0.0"
}
I'll post any other relevant information, Thanks.
回答1:
Your jasmine.json
is invalid; it should look like this instead:
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
]
}
来源:https://stackoverflow.com/questions/36208555/jasmine-unable-to-find-spec-files