Skip to content
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

Jasmine types mismatch between vrotest and vropkg #516

Closed
Indy-rbo opened this issue Nov 15, 2024 · 4 comments
Closed

Jasmine types mismatch between vrotest and vropkg #516

Indy-rbo opened this issue Nov 15, 2024 · 4 comments
Labels
area/tests Relates to tests and code coverage kind/bug Something isn't working priority/medium triage/needed Needs to be discussed by project maintainers version/patch The change is a non-breaking bugfix

Comments

@Indy-rbo
Copy link
Contributor

Description

The package @types/jasmine (and jasmine itself) have a version mismatch between vropkg and vrotest.
While the jasmine package itself did not give me issues, the @types/jasmine does.

The following example should work, type wise.
It will work inside the editor and (most of the time) when running mvn clean package:

let mySpy: jasmine.SpyObj<MyService>;
beforeAll(() => {
  mySpy = spyOnAllFunctions(MyService.prototype)
})

But sometimes it generates the error:

error Type 'Spy' is not assignable to type 'SpyObj<MyService>'.

As you can see in the links below, when you search for spyOnAllFunctions the definitions don't match

3.3.9: https://www.npmjs.com/package/@types/jasmine/v/3.3.9?activeTab=code

declare function spyOnAllFunctions(object: object): jasmine.Spy;

3.10.3: https://www.npmjs.com/package/@types/jasmine/v/3.10.3?activeTab=code

declare function spyOnAllFunctions<T>(object: T, includeNonEnumerable?: boolean): jasmine.SpyObj<T>;

Steps to Reproduce

  1. Create a test where you assign a variable that is defined as jasmine.SpyObj<MyService> with something from spyOnAllFunctions
  2. Run mvn clean package
  3. It sometimes(?) errors

Preconditions: Unsure

Expected behavior: To have it use the correct type definitions

Actual behavior: It (sometimes) uses the old type definitions, which then errors during type checking

Reproduces how often: Unsure, but haven't found a case where it reproduces 100%

Component/s: typescript/vrotest, typescript/vropkg

Affects Build/s: Up to 2.44.0

Related issues and PRs

#463
#332

Additional Context

Unsure if the jasmine package itself should also be upgraded, since vropkg uses ^3.3.1 and vrotest uses 4.5.0

@VenelinBakalov VenelinBakalov added kind/bug Something isn't working version/patch The change is a non-breaking bugfix area/tests Relates to tests and code coverage triage/needed Needs to be discussed by project maintainers priority/medium labels Nov 19, 2024
@Michaelpalacce
Copy link
Collaborator

vropkg has nothing to do with running jasmine tests.

@Indy-rbo
Copy link
Contributor Author

vropkg being an affected component was a guess based on what packages have references to the Jasmine types in this repo and it occurring when using mvn clean package. Sadly still haven't been able to find a good reproducible setup.

But I hope this issue will be resolved as a byproduct of #463

@pboychev-bcom
Copy link
Contributor

A few comments on the above:

  • There are on-going changes in a branch that is updating the dependencies for all TypeScript components that should update the dependency versions to the same (latest available) version.
  • As Stefan mentioned, the vropkg component isn't really playing a role in bootstrapping and running the tests, this is entirely done in the vrotest component. BTVA version 3.0.0 has changes related to how the tests are bootstrapped and executed. We should check if the issue is present there. It might still be since implementation has full backwards compatibility. The new way of bootstrapping the tests however lets the user define versions of the user define which versions of the unit tests framework and of its typedef package to use through properties in the pom file. You can check the readme of the component for more details. There is also an option to fully override the tests bootstrapping process by providing a package.json file - also available in the readme.
  • A general note on the runtime and dependencies - there is a different between the runtime of the BTVA build process and running the tests. All dependencies referenced in the BTVA components' package.json files are relevant when w're building BTVA itself. These will not impact bootstrapping and running the tests. The package.json file applied to the tests runtime will be generated on demand when the tests are being bootstrapped. The tests will be triggered within a {module-path}/target/vro-tests folder in your TS module. You can find the package.json file that will apply to bootstrapping the tests there after running mvn clean package. If you'd like to customize the bootstrapping you have two options:
    • Provide a specific unit test framework package version through the pom file properties.
    • Completely override the unit tests bootstrapping by providing your own configuration via a unit-tests.config folder in the root of your TS module. This is also documented in the readme of the vrotest component.

I hope that makes sense and gives you some direction. Let us know if you need further assistance with that.

@VenelinBakalov
Copy link
Collaborator

Hi @Indy-rbo , I will proceed with closing this issue based on the information provided above but if you need further assistance feel free to re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tests Relates to tests and code coverage kind/bug Something isn't working priority/medium triage/needed Needs to be discussed by project maintainers version/patch The change is a non-breaking bugfix
Projects
None yet
Development

No branches or pull requests

4 participants