【问题标题】:Cypress Add multiple function/event on plugins/index.js on file preprocessorCypress 在文件预处理器上的 plugins/index.js 上添加多个函数/事件
【发布时间】:2021-02-19 09:53:08
【问题描述】:

如何在 file:preprocessor 上添加多个事件? 我正在努力将 webpack 插件和 cypress-select-tests 插件放在文件中:prep

我在下面尝试过,但它只会处理最后一个。

const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor');
const selectTestsWithGrep = require('cypress-select-tests/grep')
module.exports = (on, config) => {

on('file:preprocessor', cypressTypeScriptPreprocessor);
on('file:preprocessor', selectTestsWithGrep(config));

另外,做了下面的,但仍然无济于事。

const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor');
const selectTestsWithGrep = require('cypress-select-tests/grep')
module.exports = (on, config) => {
on('file:preprocessor', { cypressTypeScriptPreprocessor, , selectTestsWithGrep(config)});

非常感谢任何输入。 谢谢。

【问题讨论】:

  • 你在使用这个module.exports = (on, config) => { on('file:preprocessor', cypressTypeScriptPreprocessor); on('file:preprocessor', selectTestsWithGrep(config)); }时遇到了什么错误
  • @AlapanDas 我收到此错误:``` Cypress throwing SyntaxError: 'import' and 'export' may only appear with 'sourceType: module' (17:0) ``` 因为webpack 预处理器被 cypress-select-tests 插件覆盖。

标签: javascript cypress


【解决方案1】:

如果您有 Cypress v4.4 或更高版本,则不需要cy-ts-preprocessor, 见TypeScript Support

历史

Version Changes
5.0.0 Raised minimum required TypeScript version from 2.9+ to 3.4+
4.4.0 Added support for TypeScript without needing your own transpilation through preprocessors

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-25
    • 2012-03-30
    • 2022-10-14
    • 1970-01-01
    • 2021-03-15
    • 2019-12-06
    • 1970-01-01
    • 2015-07-02
    相关资源
    最近更新 更多