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

Fix Failing JS Unit Tests & File Import Error #1296

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

njmulsqb
Copy link
Contributor

@njmulsqb njmulsqb commented Sep 20, 2023

The code had two failing JS unit tests which has been fixed
image

also fixes #1103

@thc202 thc202 changed the title 🐛 fix import of ava library using require Fix import of ava library using require Sep 20, 2023
@thc202
Copy link
Member

thc202 commented Sep 20, 2023

CI should be changed to run the tests, not only to ensure that this is fixed but to not regress again.

For follow ups better use a different branch name, vue3 is misleading.

@thc202 thc202 mentioned this pull request Sep 20, 2023
@njmulsqb
Copy link
Contributor Author

CI issue is different; this PR resolves the issue that was stopping the execution of tests locally (atleast)

@psiinon
Copy link
Member

psiinon commented Sep 20, 2023

So you cant run the test locally?
what error messages do you get?
I can run them, although the Firefox one always fails for me.

@njmulsqb
Copy link
Contributor Author

njmulsqb commented Sep 20, 2023

I am using npm run test to invoke ava and it is giving following error to me
image
This PR fixes it; afterwards the output is something like this:
image

@psiinon
Copy link
Member

psiinon commented Sep 20, 2023

Can you try ./gradlew check zapRunTests

@njmulsqb
Copy link
Contributor Author

Yeah its working fine. Isn't it utilizing Java tests? Why can't we run ava directly?

@thc202
Copy link
Member

thc202 commented Sep 20, 2023

This PR fixes it; afterwards the output is something like this:

That error shows utils is not defined so the fix is not complete.

@njmulsqb
Copy link
Contributor Author

The fix is just for the import statement; not for the whole unit tests file.

Second, I can see the gradle job is running java tests, and not ava ones. Should I focus on Java unit tests or on JS ones?

@psiinon
Copy link
Member

psiinon commented Sep 20, 2023

For me the java tests are the most important, but the js ones would be good to fix too..

@njmulsqb njmulsqb changed the title Fix import of ava library using require Fix Javascript Unit Tests Sep 26, 2023
@njmulsqb
Copy link
Contributor Author

This PR fixes it; afterwards the output is something like this:

That error shows utils is not defined so the fix is not complete.

It is complete now

@njmulsqb njmulsqb changed the title Fix Javascript Unit Tests Fix Javascript Unit Tests File Import Error Sep 26, 2023
@psiinon
Copy link
Member

psiinon commented Sep 26, 2023

Task :npmLintAllHud FAILED - should be an easy one to fix 😁

@njmulsqb
Copy link
Contributor Author

Is it possible to execute only the failing unit test and not zapRunTests each time?

@njmulsqb
Copy link
Contributor Author

njmulsqb commented Jan 2, 2025

Before d7019fb module was throwing error in browser resulting in failed initialization of HUD.

Now, if you run npm run test it shows two failed tests which means our unit tests (JS ones) are executing perfectly. Also HUD is loading perfectly fine in browser (tested on both Chrome & Firefox)

UPDATE
The failing unit tests have also been fixed:

image image

@psiinon
Copy link
Member

psiinon commented Jan 2, 2025

Logo
Checkmarx One – Scan Summary & Detailscf2bb209-bacd-4fcf-9239-d9c1c8ab4c38

New Issues

Severity Issue Source File / Package Checkmarx Insight
CRITICAL CVE-2023-28154 Npm-webpack-5.72.0 Vulnerable Package
CRITICAL CVE-2024-53990 Maven-org.asynchttpclient:async-http-client-2.12.3 Vulnerable Package
HIGH CVE-2021-33813 Maven-org.jdom:jdom-1.1.3 Vulnerable Package
HIGH CVE-2022-25858 Npm-terser-5.12.1 Vulnerable Package
HIGH CVE-2022-38900 Npm-decode-uri-component-0.2.0 Vulnerable Package
HIGH CVE-2023-2976 Maven-com.google.guava:guava-31.1-jre Vulnerable Package
HIGH CVE-2023-45133 Npm-@babel/traverse-7.12.12 Vulnerable Package
HIGH CVE-2023-46234 Npm-browserify-sign-4.2.1 Vulnerable Package
HIGH CVE-2024-47554 Maven-commons-io:commons-io-2.13.0 Vulnerable Package
MEDIUM CVE-2023-44270 Npm-postcss-8.4.29 Vulnerable Package
MEDIUM CVE-2024-29025 Maven-io.netty:netty-codec-http-4.1.92.Final Vulnerable Package
MEDIUM CVE-2024-55565 Npm-nanoid-3.3.6 Vulnerable Package
LOW CVE-2020-8908 Maven-com.google.guava:guava-31.1-jre Vulnerable Package

Fixed Issues

Severity Issue Source File / Package
HIGH Cx89601373-08db Npm-debug-2.6.9
MEDIUM CVE-2022-24823 Maven-io.netty:netty-common-4.1.73.Final
MEDIUM CVE-2022-41915 Maven-io.netty:netty-codec-4.1.73.Final

@njmulsqb njmulsqb changed the title Fix Javascript Unit Tests File Import Error Fix Failing JS Unit Tests Jan 2, 2025
@njmulsqb njmulsqb changed the title Fix Failing JS Unit Tests Fix Failing JS Unit Tests & File Import Error Jan 2, 2025
@njmulsqb
Copy link
Contributor Author

njmulsqb commented Jan 2, 2025

The PR is ready for review; the building failing doesn't make sense to me as ZAP HUD is working fine locally.

Signed-off-by: Najam Ul Saqib <[email protected]>
Signed-off-by: Najam Ul Saqib <[email protected]>
Signed-off-by: Najam Ul Saqib <[email protected]>
This reverts commit 3f37003.

Signed-off-by: Najam Ul Saqib <[email protected]>
This reverts commit 422853d.

Signed-off-by: Najam Ul Saqib <[email protected]>
Signed-off-by: Najam Ul Saqib <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Running ava fails with SyntaxError: Cannot use import statement outside a module
3 participants