柏树10+ '无法解析"fs"'和'无法解析"密码"&#



我更新到Cypress 10+。我尝试将插件配置从cypress/plugins/index.js转移到cypress.config.ts。我阅读了我使用的每个插件的新文档并对其进行了预配置。然而,我遇到了一些奇怪的问题,我在互联网上找不到任何解决方案。

这是我的cypress.config。但是我认为真正的问题不在于迁移。

import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild";
// import { setupMaster } from "cluster";
// Call cy-verify-downloads plugin library.
const { verifyDownloadTasks } = require('cy-verify-downloads');
export default defineConfig({
projectId: '7emkc5',
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'cypress/report/mochawesome-report',
overwrite: false,
html: true,
json: true,
timestamp: 'dd-mm-yyyy_HH-MM-ss',
},
// theme: 'dark',
chromeWebSecurity: false,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
async setupNodeEvents(on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions): Promise<Cypress.PluginConfigOptions> {
// This is required for the preprocessor to be able to generate JSON reports after each run, and more,
await addCucumberPreprocessorPlugin(on, config);
on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin(config)],
})
);
// This is required to reading data from the excel file.
const xlsx = require('node-xlsx').default;
const fs = require('fs'); // for file
const path = require('path'); // for file path
on('task', {
parseXlsx({ filePath }) {
return new Promise((resolve, reject) => {
try {
const jsonData = xlsx.parse(fs.readFileSync(filePath));
resolve(jsonData);
} catch (e) {
reject(e);
}
});
}
});
const readXlsx = require('./cypress/support/DataDrivenTestingWithExcel/read-xlsx')
module.exports = (on, config) => {
on('task', {
'readXlsx': readXlsx.read
})
}
// Call cy-verify-downloads plugin.
on('task', verifyDownloadTasks);
// Make sure to return the config object as it might have been modified by the plugin.
return config;
},
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx,feature}',
// Time, in milliseconds, to wait for page transition events or cy.visit(), cy.go(), cy.reload() commands to fire their page load events. Network requests are limited by the underlying operating system, and may still time out if this value is increased.
pageLoadTimeout: 60000,
},
})

这是我在尝试执行一些随机的柏树测试时收到的错误。我不知道出了什么问题。我试着安装"fs"手动,但没有阳性结果。我发现了"密码"。已弃用,默认情况下包含在节点中。node_modules/cy- verification -downloads/src/index.js:2:44: ERROR: Could not resolve "node_modules/cy- verification -downloads/src/index.js:3:32: ERROR: Could not resolve "crypto">

我不知道是什么问题。我撤消了更改并再次进行了迁移。也许我做错了什么。我想我没有更改cy-verify-downloads插件的版本,但是我为最后一个版本做了配置。

相关内容

  • 没有找到相关文章

最新更新