diff --git a/lib/helper/ApiDataFactory.js b/lib/helper/ApiDataFactory.js index 12a587c0d..e8f9c5dd6 100644 --- a/lib/helper/ApiDataFactory.js +++ b/lib/helper/ApiDataFactory.js @@ -309,7 +309,8 @@ class ApiDataFactory extends Helper { } catch (e) { modulePath = path.join(global.codecept_dir, modulePath); } - const builder = require(modulePath); + // check if the new syntax `export default new Factory()` is used and loads the builder, otherwise loads the module that used old syntax `module.exports = new Factory()`. + const builder = require(modulePath).default || require(modulePath); return builder.build(data, options); } catch (err) { throw new Error(`Couldn't load factory file from ${modulePath}, check that