我正在使用赛普拉斯开发E2E测试框架,并希望导入赛普拉斯目录(包含dir的目录),该目录用于:固定装置,集成,插件,支持。当我开始一些初始测试以验证它是否可以按预期运行时,我收到这些错误消息,指出该错误源自我的测试代码,而不是赛普拉斯。错误的原因是TypeError指出:Cannot read property 'includes' of undefined
。
有关此问题的Internet搜索并没有真正的帮助,因为似乎没有其他行为可以解决此问题(至少在我看来)。即使将我选择作为导入的规格文件移动到cypress/integration/
中,同样的问题也会出现。
在这一点上,我很困惑这个问题的起因是什么以及如何解决它。有什么我想念的吗?
这是我在package.json(devDependencies和main的字段)中得到的:
"main":"index.js",
"devDependencies": {
"@cypress/webpack-preprocessor": "^5.4.1",
"cypress": "^4.9.0",
"selenium-webdriver": "^4.0.0-alpha.7",
"webpack": "^4.43.0"
}
我的规格将规格文件导入赛普拉斯目录(cypress / integration / RunE2ETest.spec.js):
import '../../Cypress_E2E_Example/SteamHeader.spec';
Cypress文件夹(SteamHeader.spec)外部的spec文件仅显示了如何设置导入,导出:
import '../Cypress-E2E/BaseTest';
export default describe('Test Suite for ....' () => {
it('test example'), () => {
}
}
BaseTest的文件:
import default before('BaseSetup', () => {
cy.visit('/');
}
有关错误的详细信息: 导致错误的行(node_modules / global-dirs / index.js:28:1):
26 |
27 | // Homebrew special case: `$(brew --prefix)/lib/node_modules/npm/npmrc`
> 28 | if (process.execPath.includes('/Cellar/node')) {
| ^
29 | const homebrewPrefix = process.execPath.slice(0, process.execPath.indexOf('/Cellar/node'));
30 | return path.join(homebrewPrefix, '/lib/node_modules/npm/npmrc');
31 | }
Stacktrace:
We dynamically generated a new test to display this failure.
at getGlobalNpmrc (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86028:23)
at getNpmPrefix (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86064:30)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86072:32)
at Object.512._process (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86120:4)
at o (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:265)
at eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:316)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:89116:20)
at Object.551.fs (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:89130:4)
at o (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:265)
at eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:316)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:70417:28)
at Object.425../fs (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:70842:4)
at o (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:265)
at eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:316)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:67474:12)
at Object.411../lib/cypress (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:67503:4)
答案 0 :(得分:1)
我们遇到了同样的错误。这是由cypress
模块的导入引起的。我猜这个模块不打算导入浏览器中加载的文件中。