I am trying to write my Cucumber tests using TypScript, like this:
import { browser, $$ } from 'protractor';
import { Given, Then } from 'cucumber'
import { expect } from 'chai';
Given('I navigate to the homepage', function (callback) {
browser.get('http://localhost:4200');
callback();
});
Then('I want to see the welcome message {string}', function (message, callback) {
expect($$('h1').first().getText()).to.eventually.equal(message).and.notify(callback);
});
However, Protractor complains:
Error: Invalid Chai property: eventually
How can I import this? I have tried:
import { eventual } from 'chai-as-promised';
but this doesn't work. How can I accomplish this? I have also tried rewriting the Then call using await, but the compiler complains that you cannot mix callbacks with async functions. Aargh!
In your protractor configuration, add the following lines at the end of the
onPreparefunction :When using async function you should remove the callback from the function signature.