user9347168
user9347168

Reputation:

Cypress - adding Cucumber

This is a very basic question, but since I've never been a frontend developer, js and ts is pretty new to me.

I'm trying to add Cucumber functionality to a Cypress test suite. I've installed the cypress-cucumber-preprocessor package, but I'm running into problem when all the howto's and info I can find use js as examples.

I'm supposed to put this into the index.js file:

const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = (on, config) => {
    on('file:preprocessor', cucumber())
}

Since the test suite has an index.ts file instead, this naturally can't be copy-pasted in. How do I convert it to .ts?

Upvotes: 1

Views: 1375

Answers (1)

user16695029
user16695029

Reputation: 4440

That particular code should work in index.ts as

import { default as cucumber } from 'cypress-cucumber-preprocessor'
// or just 
import cucumber from 'cypress-cucumber-preprocessor'

export default (on, config) => {
    on('file:preprocessor', cucumber())
}

Installs:

npm install --save-dev cypress-cucumber-preprocessor
npm install --save-dev @types/cypress-cucumber-preprocessor

In general cypress-realworld-app has typescript as a source of examples (but not cucumber).

Upvotes: 2

Related Questions