-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Converted Q Unit tests to Mocha Tests #1301
Conversation
These tests are falling because of the changes done in init.js file, I am fixing that right now |
Signed-off-by: THEBOSS0369 <[email protected]>
…ix-js into con-mocha-backup
@THEBOSS0369 Thank you very much for this, that's great! I'll take a look as soon as I can. Looks like a great improvement. @audiodude maybe you have some comments? |
I've done some basic tests by switching to the PR/branch, running npm install, and npm run test-unit and test-unit-coverage. Congratulations, this is very impressive conversion work! Just quickly, I noticed that running these commands create a bunch of temporary files in the Repo that have not been correctly ignored (see screenshot). If the coverage files are overwritten on each coverage run, then they can remain, but you should .gitignore the coverage folder. Regarding the .nyc_output folder, it should also be .gitignore'd, but these look like files with a PID, and so I imagine will be created every run and could become a nuisance in that folder. Ignoring the folder may not be enough. Please check if there is a way to prevent them being generated, or whether they get auto-cleaned up (which would be fine). |
I haven't yet reviewed the code itself. |
@Jaifroid Sir the temp files that you are seeing is not from the code instead it is due to the command This is a blog for a reference https://zinserjan.github.io/mocha-webpack/docs/guides/code-coverage.html |
Yes, I was aware that these reports were from running the command, but we don't want them being accidentally pushed to the server by a dev, so the folders containing them should at least be added to |
Got it sir i will do it, and yes right now it just shows the table's heading and empty value I wanted to confirm whether this feature is needed or not so i created as an example. Once conversion work of test is approved, I will make it working. |
Hey @Jaifroid sir let me know what to do further in this pr, when you get some time. |
Thanks! I noticed fallback errors in the test run due to Fetch not being supported in the test environment (see screenshot): To avoid this, we should add a test for 'Fetch' support in the files
Add this specifically on these lines: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@THEBOSS0369 It's looking good. Just some minor suggestions to clean up the output display.
Signed-off-by: THEBOSS0369 <[email protected]>
@Jaifroid Thanks you for this sir , this was such a help i was trying to fix this in files |
Progress status: I'm currently trying to fix npm run test-unit-coverage isse. Its taking longer than i expected it to plus my winter's holiday has ended 2 weeks ago so i am not getting enough time to focus only on fixing it but i will try to fix it till this weekend, if i ain't able to make it, i will probably won't add the feature in this pr. would that be fine sir? @Jaifroid |
Thanks for the update. See what you can do this weekend, and if it's too complicated, maybe you could just make it into a separate issue to "Add Unit test coverage". |
Signed-off-by: THEBOSS0369 <[email protected]>
Hello @Jaifroid sir i have fixed it but its creating so many problems in other workflow of the repo's. First is that the main test are failing if i add the functionality it shows error message in files like coverage report are showing but with error messages I am not very confident with this so i am just commiting the code to show you. I am just confirming again that i should remove this functionality from this pr and go ahead with the creating an issue or should i work on it more. Its just keep getting complicated & more complicated and i don't want to mess with the codebase. Let me know what to do thanks. |
I will revert the recent commit once you have taken a look |
@THEBOSS0369 I didn't review the whole of the latest commit, but I immediately noticed you're using the wrong type of modules. We use ES6 Modules, with Overall, my view is that you should revert the code coverage commit and make it into a separate issue. It's enough that you've converted our ancient tests to a modern format. We know the coverage is extremely poor currently, and we need to work on adding more tests for basic units of code. Being told on each run that our coverage is poor won't really help the situation, even though it's a good idea in principle! Many thanks! |
This reverts commit 444e215.
Got it sir i have reverted the changes and yess i have been searching out the internet to make it work from last 2 weeks as i have never worked on something like this before 😅🫠. |
Thanks, @THEBOSS0369 🙏. I shall review ASAP. |
Hello @Jaifroid Sir i have my exams going on and it will end on 10 march . so there won't be any problem if you can review this pr after 10th march. Thanks. |
@THEBOSS0369 I hope your exams went well! Let's get this PR finished and merged! It strikes me that what remains to be done is to integrate the new tests into the workflows, and remove testcafe, as this won't be needed going forwards. There is also the old tests.js code to remove. I notice that some security updates have introduced a conflict in your PR. You may be able to resolve this by running |
Also, |
Signed-off-by: THEBOSS0369 <[email protected]>
Signed-off-by: THEBOSS0369 <[email protected]>
Signed-off-by: THEBOSS0369 <[email protected]>
@Jaifroid Sir Thanks for that my exams went very well! Now I have integrated the test in the workflows, |
It's looking great! I've tested manually in both Windows and WSL (Ubuntu), and no issues with npm test, npm run test-unit, or npm test-unit-coverage. The one command causing issues is npm test-unit-watch. It produces this output in Windows terminal, and similar in Linux terminal:
It looks like a rogue Does the command |
Signed-off-by: THEBOSS0369 <[email protected]>
@Jaifroid sir i didn't noticed it earlier and yes its not working for me as well. Most probably the reason you stated is correct although it was working last month though am not sure what happened, i looked on google wasn't able to find anything other than Module compatible issue. So i am removing it as its not working as expected and our main command npm-test-unit shows the result in fraction of second so i don't think other developers may find any time issues while using it. Also my log shows a little bit different result npm run test-unit-watch
> kiwix-js@4.1.2 test-unit-watch
> mocha --experimental-modules --node-option experimental-specifier-resolution=node --watch --require @babel/register --require tests/unit/setup.js 'tests/unit/spec/**/*.test.js'
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/boss/realcode/opnsrc/kiwix/kiwix-js/tests/unit/spec/mocha.test.js from /home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/mocha/lib/mocha.js not supported.
Instead change the require of mocha.test.js in /home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/mocha/lib/mocha.js to a dynamic import() which is available in all CommonJS modules.
at Object.newLoader [as .js] (/home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/pirates/lib/index.js:121:7)
at /home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/mocha/lib/mocha.js:416:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/mocha/lib/mocha.js:413:14)
at Mocha.run (/home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/mocha/lib/mocha.js:988:10)
at Object.run (/home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/mocha/lib/cli/watch-run.js:263:22)
at FSWatcher.<anonymous> (/home/boss/realcode/opnsrc/kiwix/kiwix-js/node_modules/mocha/lib/cli/watch-run.js:184:14) |
No problem about removing the command, it's probably not so useful for the reasons you state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, tests are passing, and I think this is ready now! Thank you very much for this great PR 🙏😊. Please feel free to squash and merge, or tell me if you don't have access to do that (I think you should have access).
I have the access sir and i am squashing and merging it now |
This PR Fixes #1187
Description
In this PR i have converted Q Unit tests to Mocha Tests.
Tests Converted
All the tests from
unit/spec/test.js
file are converted into mocha tests. It can be found inunit/spec/mocha.test.js
Note:
In this PR i haven't deleted the test.js file as once other files are approved we can continue with deleting that file
Commands to Run the test:
npm run test-unit
: This command runs the unit tests for the application to ensure that individual units of code (such as functions or methods) are working as expected.npm run test-unit-watch
: This command allows us to continuously run tests while we work on our code. If we change a test file or the code it tests, Mocha will automatically re-run the tests.npm run test-unit-coverage
: This command runs the unit tests with code coverage reporting using NYC, which is a tool for generating code coverage reports.Test
I have done all the necessary test
npm test
no issuetests-e2e-firefox
-> All tests Passed.Screenshot for converted tests Passing