3

使用 迁移到最新的赛普拉斯版本(7.0.1、7.2.0、7.3.0)webpack-dev-server后,我在使用赛普拉斯 docker 映像在 IC(Jenkins)中运行我的 React 组件测试时遇到了同样的问题,cypress/browsers:node14.16.0-chrome89-ff86而在本地一切正常(Windows 10)。工作继续进行:

ℹ 「wdm」: wait until bundle finished: /__cypress/src/index.html

由于超时,在 15 分钟后停止之前。

这是启动测试的脚本:

cypress run-ct --browser chrome --headless --config screenshotsFolder=/reports/cypress/screenshots

这是我的cypress/plugins/index.js

const { startDevServer } = require('@cypress/webpack-dev-server')
const injectReactScriptsDevServer = require('@cypress/react/plugins/react-scripts')
const webpackConfig = require('../webpack.config.js')

module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config

  if (config.testingType === 'component') {
    injectReactScriptsDevServer(on, config)
    on('dev-server:start', async (options) => startDevServer({options, webpackConfig}))
  }

  return config
}

这是我的cypress/webpack.config.js

module.exports = {
    resolve: {
        extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts", ".json"]
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                exclude: /node_modules/,
                loader: 'ts-loader',
                options: {
                    compilerOptions: {
                        "noEmit": false
                    }
                }
            },
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['@babel/preset-env','@babel/react']
                }
            }
        ]
    }
};

这些是我使用的依赖项:

"cypress": "7.3.0",
"@cypress/react": "5.7.0",
"@cypress/webpack-dev-server": "1.3.0",
"ts-loader": "8.2.0",

有任何想法吗 ?

谢谢你的帮助

4

0 回答 0