如何将柏树 - 拼写tab添加到cypress.config,js

发布于 2025-02-13 23:07:39 字数 441 浏览 1 评论 0原文

我正在努力将选项卡插件添加到cypress.config.js。 从柏树10.0.0版本开始,您需要将插件添加到柏树配置中的setupnodeevents函数中,在此之前,它们在index.js文件中。

这是Tab插件的文档 - https://www.npmjs.com/ppacks.com/ppackage /赛普拉斯 - 拼写tab 。 我不知道如何将其添加到配置文件中。该文档建议我将其添加到索引文件中,但已有3年的历史,

建议我添加

require('cypress-plugin-tab')

到索引文件中,但不适用于新的Cypress

I am struggling to add the tab plugin to the cypress.config.js.
As of Cypress version 10.0.0, you will need to add your plugin to the setupNodeEvents function in the Cypress configuration and before that, they were in the index.js file.

This is the documentation for the tab plugin - https://www.npmjs.com/package/cypress-plugin-tab .
I can't figure out how to add it to the config file. The documentation suggests I add it to the index file but it is 3 years old

It suggests I add

require('cypress-plugin-tab')

to the index file but doesn't work with the new cypress

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我为君王 2025-02-20 23:07:39

尽管该软件包被命名为cypress-plugin-tab,但它不是setupnodeevents of cypress.config.js的插件。

这只是一个自定义命令,请参见 cypress-plugin-tab/src/index.js

Cypress.Commands.add('tab', { prevSubject: ['optional', 'element'] }, 
  (subject, opts = {}) => {...

只需将其导入support/e2e.js文件,甚至在测试的顶部。

Although the package is named cypress-plugin-tab, it's not a plugin in that goes in the setupNodeEvents of cypress.config.js.

It's just a custom command, see cypress-plugin-tab/src/index.js

Cypress.Commands.add('tab', { prevSubject: ['optional', 'element'] }, 
  (subject, opts = {}) => {...

Just import it into the support/e2e.js file, or even at the top of your test.

七婞 2025-02-20 23:07:39

转到Cypress/unding/e2e.js,然后添加require('Cypress-Plugin-tab')。这应该起作用。

Go to cypress/support/e2e.js and then add require('cypress-plugin-tab'). This should work.

予囚 2025-02-20 23:07:39

我认为您不需要。

我只是将import'cypress-plugin-tab'import'放在我的TS测试文件的顶部(如果您使用JS,则将prop require('cypress-plugin-tab')< /code>),而“标签键入”现在对我有用。

无需添加任何“ index.js”文件,也不需要在“ e2e.js”文件中添加任何内容。

I don't think you need to.

I just put import 'cypress-plugin-tab' at the top of my TS test file (if you're working with JS then put require('cypress-plugin-tab') instead), and the tab typing is now working for me.

No need for adding any "index.js" file nor adding anything in the "e2e.js" file neither.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文