Hi, I have a question about steps_file in CodeceptJS version 3.0
Before I use this file like:
import { actorCommon } from '../common/custom-steps';
export = () => {
return actor({
...actorCommon,
async goToCustomerArea(text: string): Promise<void> {
await actorCommon.goToPage(customerAreaUrl);
this.waitForVisible('//*[contains(text(), "' + text + '")]');
},
})
}
But now I have 2 errors, to be honest, 1 error:
- I cannot use async\await function
- I cannot send a param
text: string
Because actor expects only () => void
functions
Type '(text: string) => Promise<void>' is not assignable to type '() => void'
hey @HugWolf I guess you need to import actor like this. My following code works for me.
const { actor } = require('codeceptjs');
export = function () {
return actor({
assertNotContain(a: any, b: any) {
return expect(a).not.toContain(b);
},
});
}
It works because of your const { actor } = require('codeceptjs');
Your actor
type is any
If you change it to import {actor} from 'codeceptjs'
you will see my problem.
Anyway, my goal is:
I have the structure:
- common module
- desktop module
- mobile module
Everyone contains steps_file
. So I need to import common_step_file
to desktop and mobile.
Like this:
Common_step_file
const I = actor();
export const commonActor = {
// some common functions
}
desktop_step_file
import {commonActor} from 'Common_step_file'
export = () => {
return actor({
...commonActor,
// some desktop functions
})
}
And it works on CodeceptJS 2.X version