-
-
Notifications
You must be signed in to change notification settings - Fork 744
Description
What are you trying to achieve?
I have a codeceptjs project where I use typescript. If I want to use the ApiDataFactory helper and create a factory file like
export default new Factory().attr('test', 'test')
I would expect that the ApiDataFactory helper is working. But as this ES6 Module export results in an object of {default: factoryObject }
and the helper expects a direct factory object from importing the factory file, it cannot handle the ES6 Module exports. Returns an error:
Couldn't load factory file from /Users/dwentland/projects/dd-e2e-test-automation/dd-e2e-tests-ts/factories/user.ts, check that
"factories": {
"account": {
"factory": "./path/to/factory"
points to valid factory file.
Factory file should export an object with build method.
Current file error: Assignment to constant variable.
I am not that deep into typescript right now, but is this behavior intended? Or do I miss any configuration to get the ES6 export to run with the helper? Or do I have to use the commonjs exports in my typescript files?
Actually it would be possible to check in the ApiDataFactory.js if the builder variable has a default property make it handle the commonjs and es6 module exports.
What do you get instead?
I would expect the helper to create the data.
Details
- CodeceptJS version: 3.3.5
- NodeJS Version: 18.11.0
- Operating System: mac
- Configuration file:
factories: {
account: {
fetchId: (data: any) => data.userId,
factory: "./factories/user.ts",
create: (data: any) => ({
method: "post",
url: "/rest/api/user",
data: data,
}),
delete: (id: any) => ({
method: "delete",
url: `users/${id}`,
}),
},
},
},