1

我按照概述( https://github.com/jaredpalmer/cypress-image-snapshot )配置了插件,但赛普拉斯无法识别它。如果我在 cy.matchImageSnapshot(); 行前面添加@ts-ignore,插件就可以工作,但我宁愿能够正确配置框架,这样赛普拉斯就不会抱怨。任何的想法?

index.js:

const cucumber = require('cypress-cucumber-preprocessor').default;
const browserify = require('@cypress/browserify-preprocessor');
const resolve = require('resolve');
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');

module.exports = (on, config) => {
    const options = {
        ...browserify.defaultOptions,
        typescript: resolve.sync('typescript', { baseDir: config.projectRoot })
    };
    on('file:preprocessor', cucumber(options));
    addMatchImageSnapshotPlugin(on, config);
};

命令.js

import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
addMatchImageSnapshotCommand();
4

1 回答 1

0

首先,您需要@types/cypress-image-snapshot为 TypeScript 类型检查添加包。

然后加入cypress-image-snapshottsconfig.jsoncompilerOptions.types数组。

于 2021-12-15T21:33:48.927 回答