The documentation tells, that in order to use custom actions, you need to use a JavaScript based configuration file and define your methods.
In my case, I want to add a customMethod that needs already defined selectors, enums etc. everything in TypeScript.
Is there a good way to use TypeScript only for defining a custom method?
Unfortunately, t.customActions
is readonly, so I can not add it myself and since there is not t.addCustomActions
method or something, I'm unsure how to add custom actions via TypeScript only.
I'm using TestCafe 2.6.2.
TestCafe doesn't support config files of the TypeScript syntax. The only way is to create a config with the TypeScript syntax and compile it with TypeScript before running tests with TestCafe. For example:
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "ESNext"
}
}
testcaferc.ts
export = {
browser: 'chrome',
src: './test.js'
}
will compile:
testcaferc.js
"use strict";
module.exports = {
browser: 'chrome',
src: './test.js'
};