-
Notifications
You must be signed in to change notification settings - Fork 14
Cannot overwrite handleTestEvent because dist moves the method to the constructor #197
Comments
The workaround I am using right now looks like this: export default class AllureEnvironment extends Base {
global!: Global & {allure: JestAllureInterface};
handleTestEvent: Circus.EventHandler;
constructor(config: JestConfig.ProjectConfig, context: EnvironmentContext) {
super(config, context);
const parentHandleTestEvent = Reflect.get(this, 'handleTestEvent');
this.handleTestEvent = async (event: Circus.Event, state: Circus.State) => {
await parentHandleTestEvent.call(this, event, state);
// custom stuff
};
}
} |
Would it be possible to publish the source |
As far as I can tell this is a commentary on This is certainly because of the way I passed down the types with I'm fairly sure I know how to fix this so I will work on a PR. Good find! |
If possible, could you use my repo as your dependency to test my changes? As far as I know you can just do |
Hi, not quite yet, but I'll get to it soon! |
@lpolito I just tried it with the steps you indicated, and unfortunately declare const _default;
export default _default; Which results in |
I am also troubled by this issue. |
Describe the bug
The
dist/allure-base-environment.js
file is transpiled as:Probably the tsc compiler doesn't ship with the public class properties proposal (stage 3), but babel does! Therefore we can no longer call
super.handleTestEvent(event, state)
(as it doesn't exists) if we extend this class.Workaround
In the constructor, we would store the reference and call it in our own handleTestEvent, this is an ugly hack.
Expected behavior
The class is compiled with es6 support for class properties, and we let others decide if further transpiling is needed on their projects.
Screenshots
Additional context
I think handleTestEvent is also not a declared method in the returned type, which also makes it very tricky to call. Maybe we can return
typeof NodeEnvironment & {handleTestEvent: Circus.EventHandler}
asAllureNodeEnvironment
?The text was updated successfully, but these errors were encountered: