Closed AGrigorii closed 1 year ago
Why do we need to use the options.basePath
argument here? Can we just use process.cwd()
instead of options.basePath
?
Why do we need to use the
options.basePath
argument here? Can we just useprocess.cwd()
instead ofoptions.basePath
?
First of all, process.cwd()
is not suitable because some one can arrange launching via child_processes.
Here could be process.env.PWD
or process.env.INIT_CWD
. However, PWD is the first version of this MR.
But I had a lot of concerns about this approach. It will be correct for most of cases, but not for all of them.
PWD or INIT_CWD causes to major version be released. If we use options.basePath
only feature bump is needed and it will be clear while setting up repository. (you are able to setup absolute paths or relative path and rootDir settings is under your control)
@AlexKamaev just in case, do you have any doubts about option-way
to achieve it?
Any objections?
I discussed the PR with the team, and we decided that we are not ready to accept a PR with any additional options. The process.cwd()
is more appropriate way even if does not cover 100% of use cases.
Hi, we decided not to merge this PR because it uses internal API: the "options" argument. You can accomplish your task with a new onBeforeWrite hook as follows:
//.testcaferc.js
const basePath = process.cwd();
const replacePathRegExp = new RegExp(basePath);
module.exports = {
hooks: {
reporter: {
onBeforeWrite: {
xunit: (writeInfo) => {
if (writeInfo.initiator !== 'reportTaskDone')
return;
writeInfo.formattedText = writeInfo.formattedText.replace(replacePathRegExp, () => '')
}
}
}
}
}
Hello Because of this comment I've created this MR.
It already correct works for js config file. In my case, I have typescript version of. I have to type config object as
Partial<TestCafeConfigurationOptions> & { hooks: any }
, unfortunately it knows nothing aboutoptions
possibility for reporters, but it already usedNotes: If we agreed to change only reporter's repository, then I'm not able to support
cli
andcreateRunner