gpt4 book ai didi

Jasmine 找不到 Spec 文件

转载 作者:行者123 更新时间:2023-12-02 14:09:39 25 4
gpt4 key购买 nike

在我的 MEAN 项目目录中,我尝试在我的 Express Controller 上运行 Jasmine 单元测试。我最初运行的是node-jasmine,但是为了增加功能,我更改为Jasmine 2.4。但是,我遇到了 jasmine.json 位置的问题,当我尝试解决方法时,我在 jasmine 源代码中遇到了错误。

我的 jasmine.json 当前内容为:

{
"spec_dir": "spec",
"spec_files": "**/*[sS]pec.js"
}

我的文件结构是:/image/umQ1w.jpg

我的 jasmine.json 在支持范围内,我的模型单元测试位于 server/controllers/notesSpec.js 中。如果我尝试用以下方法更改此设置:

jasmine JASMINE_CONFIG_PATH=test/spec/support/jasmine.json

我尝试通过控制台记录源代码,其中一些您可以在下面看到。但是,我仍然收到以下错误:

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

将 jasmine.json 拉入默认文件路径仍然会出现相同的错误。

我还将添加 package.json 中可能相关的部分

脚本: "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"
}

我会发布任何其他相关信息,谢谢。

最佳答案

您的 jasmine.json 无效;它应该看起来像这样:

{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
]
}

关于Jasmine 找不到 Spec 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36208555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com