小编Kio*_*owa的帖子

使用 Cypress v13.4.0 设置 cypress-cucumber-preprocessor

我在 cypress-cucumber-preprocessor 的最新配置中遇到错误

您的 configFile 从以下位置抛出错误: ...\cypress.config.ts
执行 e2e.setupNodeEvents() 函数时抛出错误:
TypeError: (0 , cypress_esbuild_preprocessor_1.default) 不是函数...

版本:

"@badeball/cypress-cucumber-preprocessor": "^18.0.6",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"cypress": "^13.4.0",
Run Code Online (Sandbox Code Playgroud)

这是我使用的配置,取自cypress-cucumber-preprocessor/examples/esbuild-cjs /cypress.config.js

"@badeball/cypress-cucumber-preprocessor": "^18.0.6",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"cypress": "^13.4.0",
Run Code Online (Sandbox Code Playgroud)

配置与我使用的最后一个版本几乎相同,有以下版本:

"@badeball/cypress-cucumber-preprocessor": "^15.0.0",
"@bahmutov/cypress-esbuild-preprocessor": "^2.1.5",
"cypress": "^12.1.0",
Run Code Online (Sandbox Code Playgroud)

只是当时createEsbuildPlugin是默认导出。

我尝试了最新的默认值和命名导入,但都给出了错误。

还尝试了tsconfig.json推荐的添加(旧项目中未使用)

import { defineConfig } from "cypress";
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";

export default defineConfig({
  e2e: {
    specPattern: "**/*.feature",
    async setupNodeEvents(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): Promise<Cypress.PluginConfigOptions> …
Run Code Online (Sandbox Code Playgroud)

cypress cypress-cucumber-preprocessor

6
推荐指数
0
解决办法
288
查看次数

Cypress 无法设置本地存储

我似乎无法在 Cypress 中设置本地存储?

当我从本地存储获取项目时,它与我设置的不同(它总是返回默认值)

我是否设置了错误的存储空间?

  beforeEach(() => {
    cy.clearLocalStorage();
    cy.clearCookies();
    window.localStorage.setItem('One', 'NL');
    window.localStorage.setItem('Two', 'NL');
    window.localStorage.setItem('Three', 'NL');
    visitPage('/');

    cy.window().then((win) => {
      const myItemOne = win.localStorage.getItem('One');
      const myItemTwo = win.localStorage.getItem('Two');
      const myItemThree = win.localStorage.getItem('Three');
      cy.log(myItemOne, myItemTwo, myItemThree);
    });
Run Code Online (Sandbox Code Playgroud)

应返回日志 NL、NL、NL,但返回日志 SE、SV、SV

local-storage cypress

3
推荐指数
1
解决办法
967
查看次数