-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[swc-angular-plugin] Issue with inherited classes #376
Comments
code above transpiled to: class ModelBase {
constructor(model) {
Object.assign(this, model);
}
}
export class Model extends ModelBase {
constructor(model) {
super(model);
}
} see swc playground when reproduce transpiled code and use it with test: describe("failing class tests", () => {
it('should init class with all the values', () => {
const model = new Model({ id: '123', name: 'test', version: 1 });
expect(model.id).toEqual('123');
expect(model.name).toEqual('test');
expect(model.version).toEqual(1); // This fails, 'version' is undefined
})
}) it works as expected, but when use with classes and interfaces, it not working any more and fails on "version": 1 Try to dig to it soon @jahusa02 UPD: function Model(model) {
_class_call_check(this, Model);
var _this;
_this = _call_super(this, Model, [
model
]), _define_property(_this, "version", void 0);
return _this;
} and that comes to incorrect result |
We've updated @swc/core and its dependencies so it is probably fixed in swc-angular-0.19.0, could you validate it @santiagof4? |
@edbzn I just test it in the minimal reproduction repo posted in this issue and the error still occurs. Same test fails. 😢 |
I am also seeing certain tests fail when inheritance is being used (we are trying to phase it out but aren't quite there) |
Hello!
First of all, thanks a lot for the effort! This plugin has already incredible results in our huge project with more than 2000 tests.
The issue
When running our tests with plain Jest, everything works (but super slow 😉), but when running our tests with swc-angular this issue arises:
Looks like classes that extend from other class lose values of those properties that are not present in the parent class.
Example:
When testing something with that class,
version
is always undefined:This also works with Jasmine and in normal runtime.
Reproduction
https://github.com/santiagof4/jest-angular-swc-class-reproduction
npm install
nx test
The text was updated successfully, but these errors were encountered: