Сбой производственной сборки Webpack : “Не удается разрешить” fs » при использовании cypress e2e

#typescript #cypress

Вопрос:

Я пытаюсь преобразовать проект cypress из javascript в машинописный текст.

мой пакет.json выглядит так

   "dependencies": {
    "@shelex/cypress-allure-plugin": "^2.5.1",
    "allure-commandline": "^2.13.8",
    "cypress": "^7.3.0",
    "file-system": "^2.2.2",
    "i": "^0.3.6"
  },
  "devDependencies": {
    "@cypress/webpack-preprocessor": "^5.9.0",
    "cypress-file-upload": "^5.0.7",
    "cypress-xpath": "^1.6.2",
    "gmail-tester": "^1.3.2",
    "mailslurp-client": "^12.0.0",
    "cypress-iframe": "^1.0.1",
    "mocha": "^8.3.2",
    "mochawesome": "^6.2.2",
    "ts-loader": "^9.2.2",
    "typescript": "^4.3.2",
    "webpack": "^5.38.1"
  }
 

в разделе Плагин у меня есть следующий процессор

 const wp = require('@cypress/webpack-preprocessor');

const webpackOptions = {
    // webpackOptions: require('../../webpack.config'),
    resolve: {
        extensions: ['.ts', '.js'],
    },
    module: {
        rules: [
            {
                test: /.ts$/,
                exclude: [/node_modules/],
                use: [
                    {
                        loader: 'ts-loader',
                    },
                ],
            },
        ],
    },
};

const options = {
    webpackOptions,
};

module.exports = wp(options);
 

и под Plugins/index.js У меня есть следующий код

 const allureWriter = require("@shelex/cypress-allure-plugin/writer");
const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor');
module.exports = (on, config) => {
  on('file:preprocessor', cypressTypeScriptPreprocessor);
  allureWriter(on, config); // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config
  on('task', {
    log(message) {
      console.log(message)
      return null
    }
  });
  return config;
};
 

теперь, когда я пытаюсь запустить тесты, которые я уже преобразовал в машинописный текст. Я получаю следующую ошибку:

 Error: Webpack CompLooked for and couldn't find the file at the following paths:resolve 'fs' in 'c:e2enode_modulespropertieslib'
 

Несмотря на то, что мне не нужна файловая система, я добавил ее, потому что я решил, что это может помочь. но этого не произошло. есть какие-нибудь идеи

Комментарии:

1. Начиная с версии 4.4 cypress поставляется с полной поддержкой typescript и не нуждается в каком-либо препроцессоре для переноса кода. Взгляните на официальные документы и посмотрите, поможет ли это вам docs.cypress.io/guides/tooling/…