Using testcafe v1.17.0.
I have the configuration file .testcaferc.js
with the newly merged global hooks property. In all of my fixtures, I have a before
hook which does a certain amount of requests to an API, and with the new global hooks I wanted to move all of those API calls to the configuration file. (to remove duplicate code among other reasons)
However, it doesn't seem to be possible to import other files or packages into the configuration file as it throws the following error when I try to run testcafe:
An error has occurred while reading the "C:\Users\User\Documents\Projects\testcafe\.testcaferc.js" configuration file.
Not really sure what I need to do here to make this work.
There are two examples of what I need to import into the config file. Either one of them throws the aforementioned error.
import Shared from "./shared"; // Custom JS file containing functions for the API requests
import clonedeep from 'lodash.clonedeep';
CodePudding user response:
The .testcaferc.js
configuration file should be in the CommonJS format, so you should use require
instead of import
. Your imported modules should also be written in the cjs format.