使用 jest-circus 后 Jasmine 未定义错误
Posted
技术标签:
【中文标题】使用 jest-circus 后 Jasmine 未定义错误【英文标题】:Jasmine is not define error after using jest-circus 【发布时间】:2020-09-27 04:59:18 【问题描述】:想使用jest.retryTimes()
& 为此我已经安装了 jest-circus 但是在运行测试时得到 jasmine 没有定义错误。
为了实现上述目标,我在 jest.config.js 中添加了 testRunner: "jest-circus/runner"
我正在使用 puppeteer 框架和 jest 测试运行器。
确切的错误: 测试套件无法运行
ReferenceError: 茉莉花未定义
在对象的 registerAllureReporter (node_modules/jest-allure/dist/setup.js:46:5)。 (node_modules/jest-allure/dist/setup.js:49:1)
【问题讨论】:
您能从终端粘贴准确的完整错误消息吗?是ReferenceError: jasmine is not defined
吗?
测试套件无法运行 ReferenceError: jasmine 未在对象的 registerAllureReporter (node_modules/jest-allure/dist/setup.js:46:5) 中定义。 (node_modules/jest-allure /dist/setup.js:49:1)
jest-allure 是您项目的直接依赖项吗?实际上,如果您列出 package.json
和相关的 jest.config.js
条目中的所有依赖项/devDependencies 会有所帮助。似乎 jest-allure 设置不正确,但它的设置可能取决于您的实际 jest 版本。
jsconfig.json 如下 "compilerOptions": "target": "e92017", "allowSyntheticDefaultImports.": false, "baseUrl": "./", "paths":-- -----XYZ------ , "排除": ["node_modules"]
Package.json "dependencies": "babel/core": "7.7.5", "@babel/Plugin-proposal-object-rest-spread": "7.7.4", " @babel/preset-env": "7.7.6", "allure-commandline": "2.13.0", "babel-jest": "24.9.0", "docx": "5.0.2", "dotenv “:“8.2.0”,“eslint”:“6.7.2”,“eslint-config-prettier”:“6.7.0”,“form-data”:“3.0.0”,“Is”:“0.0 .1-security”、“husky”:“3.1.0”、“jest”:“24.9.0”、“jest-allure”:“0.1.1”、“jest-circus”:“*26.0.1” ,“jest-junit”:“10.0.0”,“lint-staged”:“9.0.0”,“node-rest-client”:“3.1.0”,“prettier”:“1.19.1”,“ puppeteer": "2.1.1",
【参考方案1】:
请查看我对使用 jest-circus runner 的未定义茉莉花的类似问题的回答:https://***.com/a/66073466/1445507
【讨论】:
以上是关于使用 jest-circus 后 Jasmine 未定义错误的主要内容,如果未能解决你的问题,请参考以下文章
错误 [ERR_PACKAGE_PATH_NOT_EXPORTED]:包子路径 './build/types' 未由 .../node_modules/jest-circus/package.json
如何在 Jasmine 单元测试中使用 Sinon 对 jQuery 动画进行假时间?