[英]Cypress - adding Cucumber
這是一個非常基本的問題,但由於我從來沒有做過前端開發人員,所以 js 和 ts 對我來說很陌生。
我正在嘗試將 Cucumber 功能添加到 Cypress 測試套件中。 我已經安裝了 cypress-cucumber-preprocessor package,但是當我能找到的所有 howto 和信息都使用 js 作為示例時,我遇到了問題。
我應該把它放到 index.js 文件中:
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
由於測試套件有一個 index.ts 文件,自然無法復制粘貼。如何將其轉換為 .ts?
該特定代碼應在index.ts
中作為
import { default as cucumber } from 'cypress-cucumber-preprocessor'
// or just
import cucumber from 'cypress-cucumber-preprocessor'
export default (on, config) => {
on('file:preprocessor', cucumber())
}
安裝:
npm install --save-dev cypress-cucumber-preprocessor
npm install --save-dev @types/cypress-cucumber-preprocessor
一般來說,cypress-realworld-app有 typescript 作為例子的來源(但不是黃瓜)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.