I have a feature file with:
Scenario: List all accounts in the tenant
Given that Keith has navigated to the tenant account list
When he views the accounts in the table that include name, name2, name3
Then he should also see 1,2,3,4 in the list
I have a steps definition file with:
this.When(/^(.*?) views the accounts in the table that include (.*)$/, (accountInformation: string) => {
return stage.theActorInTheSpotlight().attemptsTo(
ViewAllAccountNames.inTheTableOf(accountInformation)
);
});
here is the ViewAllAccountNames class thats being called in the steps definition
import { includes } from '../questions/assertions.ts';
export class ViewAllAccountNames implements Task {
constructor(private accName: string) {
}
static inTheTableOf(accName: string) {
return new ViewAllAccountNames(accName);
}
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
See.if(AccountTable.isDisplayingAll, includes(this.accName))
);
}
so given all that info, I run the test and keep getting function has 1 arguments, should have 2 (if synchronous or returning a promise) or
3 (if accepting a callback) (below is the error)
I cant tell if its breakikng on the argument or an error inside my code
any ideas?
[16:25:27] I/launcher - Running 1 instances of WebDriver
[16:25:27] I/local - Starting selenium standalone server...
[16:25:29] I/local - Selenium standalone server started at http://10.4.31.17:63444/wd/h
ub
Feature: Manage the accounts associated with the tenant
In order to see all accounts for a customer
Keith would like view all accounts in the Account List
Keith would like the account list to display accounts containing Account information
Scenario: List all accounts in the tenant
√ Given that Keith has navigated to the tenant account list
× When he views the accounts in the table that include name,name2,name3
- Then he should also see 1,2,3,4 in the list
Failures:
1) Scenario: List all accounts in the tenant - e2e\features\get_account_list\get_all_ac
counts.feature:10
Step: When he views the accounts in the table that include name - e2e\features\get_a
ccount_list\get_all_accounts.feature:12
Step Definition: node_modules\serenity-js\src\serenity-cucumber\webdriver_synchronis
er.ts:47
Message:
function has 1 arguments, should have 2 (if synchronous or returning a promise) or
3 (if accepting a callback)
1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)
Have a look at the step definition:
this.When(/^(.*?) views the accounts in the table that include (.*)$/, (accountInformation: string) => {
})
The regular expression extracts two parameters from the step:
/^(.*?) views the accounts in the table that include (.*)$/
^-- first ^-- second
but the function signature only accepts one:
(accountInformation: string) => {
}
Since you're using the stage.theActorInTheSpotlight() syntax it looks like you can ignore the he word using a non-capturing group in your regular expression:
this.When(/^(?:.*?) views the accounts in the table that include (.*)$/, (accountInformation: string) => {
})
or
this.When(/^(?:he|she|they) views the accounts in the table that include (.*)$/, (accountInformation: string) => {
})
Hope that helps!
Jan
@jan-molak you are the man thanks so much now it all makes sense !
What if you're only extracting 1 parameter from the step, with 1 argument in the function, and still getting this same error?
@lexgamer - could you please provide a code sample?
Most helpful comment
Have a look at the step definition:
The regular expression extracts two parameters from the step:
but the function signature only accepts one:
Since you're using the
stage.theActorInTheSpotlight()syntax it looks like you can ignore theheword using a non-capturing group in your regular expression:or
Hope that helps!
Jan